5

Is there a tracing debugger like dbg available for Haskell or OCaml?

Very informally, it's printf-style debugging only better, completely configurable at runtime. In essence, the user can register a trace handler when a system is running, which will be called on each action from a set of actions supported by the runtime (e.g. on each function call/return, on each message sent/received etc.). Such a handler may log every operation, which gives a nice sequence of all the steps happening in (part of) the system.

This mechanism can be used for logging/debugging, profiling certain parts of the system, but in many cases just for discovering how a new (unknown to the programmer) system works.

erszcz
  • 1,630
  • 10
  • 16
  • `ocamldebug` doesn't have the trace style debugging you're talking about, but does support breakpoints and time-travel. There is also profiling support from additional tools / flags. – nlucaroni Sep 02 '14 at 13:37
  • 1
    Although not a debugger per se, the OCaml top-level has `#trace` and `#install_printer` which can go a long way. – Nikos Sep 03 '14 at 15:03

1 Answers1

4

For Haskell, GHCi provides a simple imperative style debugger. Look it's documentation to find more details about it. Some of its feature are

  • Ability to set a breakpoint
  • Stepping through execution
  • Inspecting local variables
  • Treating Exceptions as breakpoints
  • Typing in any code to execute it immediately
AndrewC
  • 32,300
  • 7
  • 79
  • 115
Sibi
  • 47,472
  • 16
  • 95
  • 163
  • Indeed. For the record, I find GHCi's ability to run any code I like from within scope with whatever arguments I like _far_ more useful than any set of traditional debugging tools. – AndrewC Sep 01 '14 at 11:06
  • 1
    @AndrewC That's fine. :) In fact I only use `ghci` for the feature you listed on. – Sibi Sep 01 '14 at 14:20
  • 2
    GHCi also has the `:trace` command, which is probably the most relevant feature for *this* question. (Although it might be less powerful than what erszcz is looking for and only works starting from a breakpoint.) – Tikhon Jelvis Sep 01 '14 at 17:37