If you’ve ever used the dbg module in Erlang you’ve seen the esoteric names of the functions it exports. I recently watched Jeffery Utter’s excellent ElixirConf talk on Debugging Live Systems on the BEAM. In the talk when he covers the dbg:tpl/3
function he guesses that it might stand for "tuple". This reminded me that I didn’t know what most of the functions names in the dbg module stood for, even though I learned how to use dbg years ago. This got me searching for the meanings behind the dbg function names.
Searching
First I did some Google searches hoping to find some StackOverflow answers or perhaps some old threads on the Erlang questions mailing list. The searches I tried turned up no results, so I looked at the Erlang Git repository and found earliest commit of the dbg.erl
file. The commit message didn’t contain anything useful, and the comments in the module source code weren’t any more helpful than the ones present in the latest version of the code. I decided to try to figure out the meanings of the function names on my own.
After reading through the dbg API documentation it was clear to me that the function names were acronyms (except for the ones that aren’t like get_tracer/0
and stop/0
). For example, p
clearly stood for process. Some of the acrynoms were not so obvious. I wrote a list of what I thought each acronym meant and posted the list on the erlang-questions mailing list. I got some good feedback, and Lucas Larsson confirmed my assumptions.
Meanings
Here is a complete list of dbg function name acronyms.
Function Name | Meaning |
---|---|
|
call |
|
clear node |
|
clear trace pattern |
|
clear trace pattern event |
|
clear trace pattern global |
|
clear trace pattern local |
|
delete trace pattern |
|
help |
|
information |
|
list nodes |
|
list trace patterns |
|
node |
|
process |
|
read trace pattern |
|
trace pattern |
|
trace pattern event |
|
trace pattern local |
|
write trace pattern |
Conclusion
I find this list of definitions makes it much easier for me to remember the function names. It’s easier for me to remember "clear trace patterns for local function calls" that it is for me to remember ctpl
. After discussing this on the mailing list I opened up a PR to add this information to the documentation. Hopefully this info will make the dbg API seem a little less esoteric to newcomers.
References
-
Jeffery Utter’s talk: https://www.youtube.com/watch?v=sR9h3DZAA74
-
Initial Git commit containing the
dbg.erl
file: https://github.com/erlang/otp/commit/84adefa331c4159d432d22840663c38f155cd4c1 -
Mailing list post: http://erlang.org/pipermail/erlang-questions/2021-August/101275.html
-
Joe Armstrong tweet on code documentation: https://twitter.com/joeerl/status/934473378601291776
-
Pull request: https://github.com/erlang/otp/pull/5117