|
From: Lemmih <lemmih <at> gmail.com>
Subject: Debugging with GHCi. Newsgroups: gmane.comp.lang.haskell.cvs.ghc Date: 2006-04-01 12:03:15 GMT (3 years, 13 weeks, 4 days, 17 hours and 3 minutes ago) Greetings, A few days ago I wondered whether it would be possible to call GHCi from interpreted byte-code. It turned out that it was, and it was even fairly easy. Here's a preliminary result: Test.lhs: > import GHC.Base > run :: Int -> () > run i > = let b = False > c x = x + a + i > in breakPoint () > where d = "str" > a = 10 > runIO :: IO String > runIO = do putStr "Enter line: " > line1 <- getLine > breakPoint $ do > putStr "Enter another line: " > line2 <- getLine > return (unwords [line1,line2]) Output from a GHCi session: ghc/compiler/stage2/ghc-inplace --interactive Test.lhs -v0 *Main> run 100 Local bindings in scope: a :: Int, c :: Int -> Int, b :: Bool, i :: Int, d :: [Char] Test.lhs:6> (a, b, c 10, d) (10,False,120,"str") Test.lhs:6> :q Returning to normal execution... () *Main> runIO Enter line: Hello Local bindings in scope: line1 :: String Test.lhs:12> map Char.toUpper line1 "HELLO" Test.lhs:12> :q Returning to normal execution... Enter another line: World "Hello World" *Main> :q Note that the problems with the representation of variables and their laziness has been delegated to the user. Has this approach been tried before? Simon PJ: You mentioned something about some ideas for building a debugger into GHCi in your call for interns two months ago. Care to elaborate on those or can I perhaps reach them online? -- Friendly, Lemmih |
|
|