Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Break and continue in GHCi debugger without use of breakpoints

Tags:

In a traditional imperative debugger such as gdb it is possible to break into program executing with SIGINT, inspect the program state, and eventually resume execution.

While GHCi allows one to break into program execution at an arbitrary point with -fbreak-on-exception, attempting to resume execution with :continue will only lead to the interpreter continuing on with the exception handler and terminating the program,

> let main = findCureForCancer
> :set -fbreak-on-exception
> :trace main
[twiddle thumbs]
[why is this taking so long?]
[maybe something is wrong, I better see what it's doing]
^CStopped at <exception thrown>
_exception :: e = GHC.Exception.SomeException
                    GHC.IO.Exception.UserInterrupt
> :hist
...
[ahh, looks like this will just take a bit longer]
> :continue
[program should keep running]

Is it possible to break into execution and still resume execution after poking about a bit with the GHCi debugger?

like image 519
bgamari Avatar asked Sep 18 '13 15:09

bgamari


People also ask

Why we use breakpoints in debugging?

Breakpoints are one of the most important debugging techniques in your developer's toolbox. You set breakpoints wherever you want to pause debugger execution. For example, you may want to see the state of code variables or look at the call stack at a certain breakpoint.


1 Answers

I’m no GHC expert, but I am extremely confident that neither stable GHC nor the current GHC HEAD supports this. The manual mentions nothing about it, and I’ve sourcedived the current HEAD to make sure there’s nothing undocumented, commented out, or surrounded in an #if FALSE. (If you’re interested, the currently-impemented GHCi commands are defined at /ghc/InteractiveUI.hs:136.) Nothing has been posted on the mailing list about this, at least since January 2013, and nobody has filed or closed a bug about it (see the relevant bug tracker search).

This sounds like it would be a useful feature to have – would you file a feature request?

like image 97
Benjamin Barenblat Avatar answered Oct 22 '22 11:10

Benjamin Barenblat