Tuning the rdbg event printer

rdbg hooks

Functions (named hooks) are called each time the RdbgStdLib.next function is called. This is the case for example by the following functions of RdbgStdLib: next, nexti, next_cond, rev_cond, step, stepi.

It is therefore also the case for Level0 commands that change the current event: n, ni, s, si, b, bi, c, nm.

In order to add, remove, or change a hook, you can use one of the following function:

(rdbg) apropos hook
(rdbg) help add_hook

Changing the “print_event” hook

One of the hook functions that is defined by default1 is named “print_event” and is associated to a function that prints the current event using the RdbgStdLib.print_event: Event.t -> unit function.

In other words, each time you use the n command, the function associated to “print_event” (if it exists in the hooks table) is called on the current event (!e). Hence, if you have defined a function my_print_event of type Event.t -> unit that you want to use instead of the current one, you just need to do:

(rdbg) add_hook "print_event" my_print_event

Note that when your (or the default) event printer hides information you’d like to see, you can always get access to it via the current event reference:

(rdbg) e;;

  1. unless the my-rdbg-tuning.ml file contains code to do things differently. [return]