O'Reilly logo

Erlang Programming by Francesco Cesarini, Simon Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The dbg Tracer

You probably realize that although the trace BIFs are extremely powerful and handy, they are also very low-level and are not very user-friendly. After all, they are there to provide a base on which to build other tools such as the dbg tracer.

The dbg tracer is a text-based debugger providing a user-friendly interface to the trace and trace_pattern BIFs, but using the tracing principles and mechanisms introduced in the preceding section. You can use the dbg tool as a complement to the process manager we discussed in the section The Process Manager in Chapter 4, especially when you are tracing on text-based terminals and do not have access to the display or you have to divert the output. The dbg tool has a small impact on system performance, making it a suitable candidate for tracing large live systems.

Getting Started with dbg

The dbg:h() call provides you with a list of helpful functions; to find out more details about any of these functions, you can pass their names to dbg:h/1. The last thing you want to do when under pressure debugging a live system after a support call in the middle of the night is to have to look at the Erlang manual pages. The help function always comes in handy:

1> dbg:h(). The following help items are available: p, c - Set trace flags for processes tp, tpl, ctp, ctpl, ctpg, ltp, dtp, wtp, rtp - Manipulate trace patterns for functions n, cn, ln - Add/remove traced nodes. tracer, trace_port, trace_client, get_tracer, stop, stop_clear - Manipulate ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required