How to convert Solaris MDB addresses into file names and line numbers?

635 views Asked by At

Say you have a MDB stack trace that look like this:

             libumem.so.1`vmem_seg_alloc+0x170
             libumem.so.1`vmem_xalloc+0x628
             libumem.so.1`vmem_alloc+0x1f8
             libumem.so.1`umem_alloc+0xec
             libumem.so.1`malloc+0x40
             compute+0x14
             main+0x54
             _start+0x12c

For example a stack trace that is generated when applying ::vmem_seg -v to an address that is listed by ::findleaks.

The corresponding binary has debugging symbols included, thus it should be pretty easy to convert an address like compute+0x14 to a file name and a line number.

How do I do that?

In case MDB does not directly support this - using other tools like dbx would be fine, as well.

The utility gaddr2line does not seem to understand compute+0x14.

2

There are 2 answers

2
Mark Plotnick On BEST ANSWER

You can pipe the list of address expressions to = K to convert them into pointer-sized hex numbers. The numbers will be all on one line, which can then be shell-piped into xargs gaddr2line.

::your_dcmds | = K ! xargs gaddr2line -e executablename
3
Andrew Henle On

Since dbx is acceptable, you can just use dbx's built-in run-time checking. With debugging information available, that will tell you the line number directly.

There are also other tools in the Studio suite that you may find useful. The bcheck utility uses the same underlying dbx functionality to produce the same data.

Be aware, though, there can be a significant performance penalty with dbx and bcheck memory tracking, especially if you use check -all.

The Performance Analyzer (collect, analyze, er_print, etc) can also provide memory leak information at a lower performance penalty, although in my experience that tool suite is more geared toward profiling application performance. (And IMO it blows perf away as a profiling tool...)