Re: [HTCondor-devel] [htcondor-fw] debug/stripped/unstripped binaries. didn't work, need help.


Date: Fri, 07 Dec 2012 16:33:59 -0600
From: Todd Tannenbaum <tannenba@xxxxxxxxxxx>
Subject: Re: [HTCondor-devel] [htcondor-fw] debug/stripped/unstripped binaries. didn't work, need help.
[conversation moved from htcondor-fw to htcondor-devel]

Given all the below is now getting quite involved, is it time we made a debug symbols package for HTCondor? We used to create one (or at least a debug symbols tarball), it disappeared when we moved to cmake.

regards,
Todd


On 12/7/2012 4:28 PM, Zachary Miller wrote:
On Mon, Dec 03, 2012 at 07:47:34PM -0600, Todd Tannenbaum wrote:
Say you have a.out.stripped and a.out.with_symbols.  And say you have a
core file from a.out.stripped.  The trick is you still want to gdb the
file that produced the core, but load symbols from the unstripped binary
into the text segment of the file you are debugging.

% gdb a.out.stripped core
   ... gdb will complain about missing debug info ...

(gdb) maint info sections     <--- enter this command

In the output from 'maint info sections', look for .text section. The
address that is in the first column is what you want to use in the next
command.  For instance, one of the output lines from 'maint info
sections' will be

   0x00400390->0x00400588 at 0x00000390: .text ALLOC LOAD READONLY CODE
HAS_CONTENTS

The address in the first column, 0x00400390 in this example, is used in
the next gdb command:

(gdb) add-symbol-file a.out.with_symbols 0x00400390

Of course, substitute 0x00400390 with the proper text segment address.

Now you should be able to do a backtrace, etc.

That will get your symbols loaded for the main executable, but you still won't
have any symbols for libraries that were dynamically loaded, which these days
is most of HTCondor.

So, to get those, you need to do a couple things.

First, run gdb on the unstripped version of the .so you would like to load and
find the .text segment just like above, and write down the offset (the first
column), you'll need it later.

Second, go back to gdb with the stripped binary and the core. If you look at
any particular stack frame, you'll see the instruction pointer in the second
column:

     #7  0x00007f034f8c1834 in KeyCache::remove ()

Now comes the black-magic portion. Run "maint info sections" again and look at
the first column. Find the entry that contains the above instruction pointer.
It should be marked "ALLOC READONLY CODE". Now, add that address to the offset
of the .text segment from the .so file you found above. Finally, you can add
the symbols from the shared library with

     add-symbol-file unstripped.so 0xMagicAddress

You'll have to do this for each shared library (libcondor_util, libclassad,
etc.) if you need the symbols for that particular stack frame.


Note: I added the above wisdom to
    https://htcondor-wiki.cs.wisc.edu/index.cgi/wiki?p=DaemonDebugging
Feel free to improve it.

i did.


cheers,
-zach



--
Todd Tannenbaum <tannenba@xxxxxxxxxxx> University of Wisconsin-Madison
Center for High Throughput Computing   Department of Computer Sciences
HTCondor Technical Lead                1210 W. Dayton St. Rm #4257
Phone: (608) 263-7132                  Madison, WI 53706-1685
[← Prev in Thread] Current Thread [Next in Thread→]
  • Re: [HTCondor-devel] [htcondor-fw] debug/stripped/unstripped binaries. didn't work, need help., Todd Tannenbaum <=