Skip to content

Commit

Permalink
HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
mpickering committed Apr 19, 2024
1 parent 310da2c commit 5c94676
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/Plugin/TraceForeignCalls.hs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ mkWrapper (orig, renamed) sig = do
return (
noLocA $
TypeSig
EpAnnNotUsed
noAnn
[wrapperName]
HsWC {
hswc_ext = []
Expand All @@ -184,10 +184,10 @@ mkWrapper (orig, renamed) sig = do
fun_ext = mkNameSet [unLoc renamed] -- TODO: what is this?
, fun_id = wrapperName
, fun_matches = MG {
mg_ext = Generated
mg_ext = Generated OtherExpansion SkipPmc
, mg_alts = noLocA . map noLocA $ [
Match {
m_ext = EpAnnNotUsed
m_ext = noAnn
, m_ctxt = FunRhs {
mc_fun = wrapperName
, mc_fixity = Prefix
Expand All @@ -198,7 +198,7 @@ mkWrapper (orig, renamed) sig = do
grhssExt = emptyComments
, grhssGRHSs = map noLocA [
GRHS
EpAnnNotUsed
noAnn
[] -- guards
(noLocA $
HsDo
Expand Down Expand Up @@ -248,7 +248,7 @@ mkWrapper (orig, renamed) sig = do
NoExtField
( noLocA $
HsApp
EpAnnNotUsed
noExtField
(noLocA $ HsVar NoExtField (noLocA returnMName))
(noLocA $ HsVar NoExtField result)
)
Expand All @@ -262,9 +262,9 @@ mkWrapper (orig, renamed) sig = do
NoExtField
( noLocA $
HsApp
EpAnnNotUsed
noExtField
(noLocA $ HsVar NoExtField (noLocA traceEventIO))
( noLocA $ HsLit EpAnnNotUsed $ HsString NoSourceText $
( noLocA $ HsLit noExtField $ HsString NoSourceText $
fsLit $ label ++ wrapperNameString
)
)
Expand Down
5 changes: 3 additions & 2 deletions src/Plugin/TraceForeignCalls/Instrument.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Control.Monad.IO.Class
import Control.Monad.Trans.Class
import Control.Monad.Trans.Reader
import Debug.Trace qualified
import qualified Language.Haskell.TH.Syntax as TH

import GHC
import GHC.Plugins
Expand Down Expand Up @@ -115,10 +116,10 @@ data Names = Names {

initNames :: TcM Names
initNames = do
nameTraceEventIO <- resolveTHName 'Debug.Trace.traceEventIO
nameTraceEventIO <- resolveTHName (TH.mkNameG TH.VarName "ghc-internal" "GHC.Internal.Debug.Trace" "traceEventIO")
return Names {
nameTraceEventIO
}

findName :: (Names -> a) -> Instrument a
findName f = Wrap $ asks (f . tracerEnvNames)
findName f = Wrap $ asks (f . tracerEnvNames)
2 changes: 1 addition & 1 deletion trace-foreign-calls.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ library
build-depends:
, exceptions >= 0.10 && < 0.11
, ghc >= 9.10
, template-haskell >= 2.20 && < 2.21
, template-haskell-next
, transformers >= 0.6 && < 0.7

test-suite test-trace-foreign-calls
Expand Down

0 comments on commit 5c94676

Please sign in to comment.