Parsing Stack Traces

Ramon Fernandez edited this page Feb 8, 2016 · 1 revision


addr2line is a utility to translate addresses into filenames and line numbers.

addr2line -e mongod -ifC <offset>


Use c++filt to demangle function names by pasting the whole stack trace to stdin.

Finding the Right Binary

To find the correct binary for a specific log you need to:

  1. Get the commit from the header of the logs.
  2. Use git to locate that commit and check for the surrounding "version bump" commit.
  3. Download and open the binary:
curl -O

You can also get the debugsymbols archive for official builds through the Downloads page. In the Archived Releases section, click on the appropriate platform link to view the available archives. Select the appropriate debug symbols archive.

Example: Reading the Log

Note that the log has lines like this:

/home/abc/mongod(_ZN5mongo15printStackTraceERSo+0x27) [0x689280]

You want to use the address in between the brackets 0x689280. Note that you will get more than one stack frame for the address if the code is inlined.

Example: Using addr2line

Actual example from a v1.8.1 64-bit Linux build:

$ curl > out.tgz
$ tar -xzf out.tgz
$ cd mongodb-linux-x86_64-debugsymbols-1.8.1/
$ cd bin
$ addr2line --help
$ addr2line -i -e mongod 0x6d6a74
$ addr2line -i -e mongod 0x6d0694