1 -----------------------------------------------------------------------------
\r
3 -- GHC API breakpoints. This module includes the main API (BkptHandler) and
\r
4 -- utility code for implementing a client to this API used in GHCi
\r
6 -- Pepe Iborra (supported by Google SoC) 2006
\r
8 -----------------------------------------------------------------------------
\r
10 module Breakpoints where
\r
13 import {-#SOURCE#-} ByteCodeLink ( HValue )
\r
16 import {-#SOURCE#-} HscTypes ( Session )
\r
21 import GHC.Exts ( unsafeCoerce# )
\r
23 data BkptHandler a = BkptHandler {
\r
24 handleBreakpoint :: forall b. Session -> [(Id,HValue)] -> BkptLocation a -> String -> b -> IO b
\r
25 , isAutoBkptEnabled :: Session -> BkptLocation a -> IO Bool
\r
28 nullBkptHandler = BkptHandler {
\r
29 isAutoBkptEnabled = \ _ _ -> return False,
\r
30 handleBreakpoint = \_ _ _ _ b -> putStrLn "null Bkpt Handler" >> return b
\r
33 type BkptLocation a = (a, SiteNumber)
\r
34 type SiteNumber = Int
\r
36 type SiteMap = [(SiteNumber, Coord)]
\r
37 type Coord = (Int, Int)
\r
39 noDbgSites :: SiteMap
\r
42 -- | Returns the 'identity' jumps
\r
43 -- Used to deal with spliced code, where we don't want breakpoints
\r
45 lookupBogusBreakpointVal :: Name -> Maybe HValue
\r
46 lookupBogusBreakpointVal name
\r
47 | name == breakpointJumpName = Just$ unsafeCoerce# (\_ _ _ _ a->a)
\r
48 | name == breakpointAutoJumpName = Just$ unsafeCoerce# (\_ _ _ _ a->a)
\r
49 | name == breakpointCondJumpName = Just$ unsafeCoerce# (\_ _ _ _ _ a->a)
\r
50 | otherwise = Nothing
\r
52 lookupBogusBreakpointVal _ = Nothing
\r