在传统的命令式调试器中,例如gdb
可以使用 中断程序执行SIGINT
,检查程序状态,并最终恢复执行。
虽然 GHCi 允许在任意点中断程序执行-fbreak-on-exception
,但尝试恢复执行:continue
只会导致解释器继续执行异常处理程序并终止程序,
> 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]
用 GHCi 调试器戳了一下之后,是否可以中断执行并仍然恢复执行?