how can I get a listing of everything that's done in a program

Hi. I'm working with GHC 6.10.4 on Solaris. I'm new at Haskell and have inherited a rather large and complex program to maintain and modify. I'd like to get a listing of everything - every single step - that's done in a run of the program. Something similar to the output of the :step command, but I'd like the entire run (which would involve tens of thousands of steps). Is there a way to just do this - have it run and print everything it does to the screen? I've tried doing the following, after starting a "script" to capture all of the screen output... ghci -fglasgow-exts parsequery.hs :break 36 main which takes me to this prompt... Loading package mtl-1.1.0.2 ... linking ... done. Stopped at lesearch.hs:36:13-39 _result :: IO SearchState = _ input :: [String] = _ st :: SearchState = _ [lesearch.hs:36:13-39] *Main> This takes me to the call before the one that I want to output each step of so that I can then manually, with hardcopy, read it and get an idea of what happened. So I start a step through the next call. [lesearch.hs:36:13-39] *Main> :step process_query_loop st input Stopped at lesearch.hs:(46,0)-(69,39) _result :: IO SearchState = _ ... [lesearch.hs:(46,0)-(69,39)] *Main> So far so good. This is what I want to see - a listing like this for every (interpreted of course) line of haskell code that runs, all the way to the end. Since this is a very large program, at this point I started pasting this to the terminal - 4 steps at a time... :step :step :step :step This gave me the listing I wanted. But after a certain point, it inevitably fails with a core dump, and what I capture from the screen is garbled up to that point anyway. I'm hoping there's a simpler way to do this. Thanks for taking the time to read this. Ralph

On 20/10/2009 14:54, Ralph Crawford wrote:
Hi. I'm working with GHC 6.10.4 on Solaris. I'm new at Haskell and have inherited a rather large and complex program to maintain and modify. I'd like to get a listing of everything - every single step - that's done in a run of the program. Something similar to the output of the :step command, but I'd like the entire run (which would involve tens of thousands of steps). Is there a way to just do this - have it run and print everything it does to the screen?
I've tried doing the following, after starting a "script" to capture all of the screen output...
ghci -fglasgow-exts parsequery.hs :break 36 main
which takes me to this prompt...
Loading package mtl-1.1.0.2 ... linking ... done. Stopped at lesearch.hs:36:13-39 _result :: IO SearchState = _ input :: [String] = _ st :: SearchState = _ [lesearch.hs:36:13-39] *Main>
This takes me to the call before the one that I want to output each step of so that I can then manually, with hardcopy, read it and get an idea of what happened.
So I start a step through the next call.
[lesearch.hs:36:13-39] *Main> :step process_query_loop st input Stopped at lesearch.hs:(46,0)-(69,39) _result :: IO SearchState = _ ... [lesearch.hs:(46,0)-(69,39)] *Main>
So far so good. This is what I want to see - a listing like this for every (interpreted of course) line of haskell code that runs, all the way to the end. Since this is a very large program, at this point I started pasting this to the terminal - 4 steps at a time...
:step :step :step :step
This gave me the listing I wanted. But after a certain point, it inevitably fails with a core dump, and what I capture from the screen is garbled up to that point anyway. I'm hoping there's a simpler way to do this. Thanks for taking the time to read this.
If you get a core dump, that's obviously a bug. If you can supply us with a small program that illustrates the bug, please submit a bug report at http://hackage.haskell.org/trac/ghc/wiki/ReportABug As for getting a list of the evaluation steps, we don't have anything that does exactly what you want at the moment, but it probably wouldn't be hard to implement on top of the existing debugging functionality. Feel free to make a feature request, describing exactly what functionality you'd like to see: http://hackage.haskell.org/trac/ghc/newticket?type=feature+request Cheers, Simon

Simon Marlow wrote:
On 20/10/2009 14:54, Ralph Crawford wrote:
So far so good. This is what I want to see - a listing like this for every (interpreted of course) line of haskell code that runs, all the way to the end. Since this is a very large program, at this point I started pasting this to the terminal - 4 steps at a time...
:step :step :step :step
This gave me the listing I wanted. But after a certain point, it inevitably fails with a core dump, and what I capture from the screen is garbled up to that point anyway. I'm hoping there's a simpler way to do this. Thanks for taking the time to read this.
If you get a core dump, that's obviously a bug. If you can supply us with a small program that illustrates the bug, please submit a bug report at
http://hackage.haskell.org/trac/ghc/wiki/ReportABug
As for getting a list of the evaluation steps, we don't have anything that does exactly what you want at the moment, but it probably wouldn't be hard to implement on top of the existing debugging functionality.
If you want to execute one command more times you can do it by scripting ghci. Add something like this to your ~/.ghci file: :{ let { cmdHlp _ msg longMsg "--help" = let fullMsg = if null longMsg then msg++"\n" else msg ++ ('\n':longMsg) in return $ "putStr "++show fullMsg ; cmdHlp _ msg _ "-h" = return $ "putStrLn "++show msg ; cmdHlp action _ _ args = action args } :} :{ :def * cmdHlp ( \cntCmd -> case break Data.Char.isSpace cntCmd of { ( cnt, _:cmd ) -> return $unlines $replicate (read cnt) cmd ; _ -> return "putStrLn \"usage: :* <count> <cmd>...\"" } ) ":* <count> <cmd>... -- run <cmd> <count> times" "" :} Then you can use it like this: % ghci GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> :* -h :* <count> <cmd>... -- run <cmd> <count> times Prelude> :* --help :* <count> <cmd>... -- run <cmd> <count> times Prelude> :* 3 :type sqrt 2 sqrt 2 :: (Floating t) => t sqrt 2 :: (Floating t) => t sqrt 2 :: (Floating t) => t Prelude> :quit Leaving GHCi. % More information about ghci scripting: http://www.haskell.org/pipermail/haskell-cafe/2007-September/032260.html More examples of how can you script ghci: http://permalink.gmane.org/gmane.comp.lang.haskell.glasgow.user/16912 Peter.

On 22/10/2009, at 12:52, Peter Hercek wrote:
As for getting a list of the evaluation steps, we don't have anything that does exactly what you want at the moment, but it probably wouldn't be hard to implement on top of the existing debugging functionality.
If you want to execute one command more times you can do it by scripting ghci.
Yes! That's a great idea Peter, we always underestimate/forget what can be done with the scripting capabilities of ghci. In this case, Ralph can get what he wants (modulo core dumps) with: *Main> :def listStep (\_ -> return ":list\n :step") *Main> :set stop :listStep *Main> :step <your function call here> Cheers pepe
participants (4)
-
Jose Iborra
-
Peter Hercek
-
Ralph Crawford
-
Simon Marlow