This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Unwind table
- From: Brian Dessent <brian at dessent dot net>
- To: Rodrigo Dominguez <roddomi at hotmail dot com>
- Cc: binutils at sourceware dot org
- Date: Fri, 27 Jun 2008 04:41:41 -0700
- Subject: Re: Unwind table
- References: <BAY109-DAV8C4CA41F24FDE32A7AA54B9A20@phx.gbl>
- Reply-to: binutils at sourceware dot org
Rodrigo Dominguez wrote:
> I am looking into the unwind table for C++ programs. I created a small test
> program with a try/catch region. I compiled the program with g++. I would
> like to see the unwind table. I tried using 'readelf -u a.out' but I get a
> message saying the there's no unwind information. What would be the best way
> to print the unwind table?
libdwarf comes with a sample app 'dwarfdump' that can be used to decode
this information:
$ echo 'int main() { std::cout << "Hello world!" << std::endl; }' \
| g++ -include iostream -x c++ -
$ dwarfdump -F a.out
.eh_frame
fde:
< 0><0x8048634:0x8048679><><fde offset 0x1c length: 0x18><eh aug data len 0x0>
08048634: cfa=04(r4/a0) r8/t0=-4(cfa)
08048635: cfa=08(r4/a0) r5/a1=-8(cfa) r8/t0=-4(cfa)
08048637: cfa=08(r5/a1) r5/a1=-8(cfa) r8/t0=-4(cfa)
< 0><0x804867a:0x8048691><><fde offset 0x38 length: 0x18><eh aug data len 0x0>
0804867a: cfa=04(r4/a0) r8/t0=-4(cfa)
0804867b: cfa=08(r4/a0) r5/a1=-8(cfa) r8/t0=-4(cfa)
0804867d: cfa=08(r5/a1) r5/a1=-8(cfa) r8/t0=-4(cfa)
< 0><0x8048692:0x80486a6><><fde offset 0x54 length: 0x18><eh aug data len 0x0>
08048692: cfa=04(r4/a0) r8/t0=-4(cfa)
08048693: cfa=08(r4/a0) r5/a1=-8(cfa) r8/t0=-4(cfa)
08048695: cfa=08(r5/a1) r5/a1=-8(cfa) r8/t0=-4(cfa)
< 0><0x80486a6:0x80486e9><><fde offset 0x70 length: 0x24><eh aug data len 0x0>
080486a6: cfa=04(r4/a0) r8/t0=-4(cfa)
080486aa: cfa=00(r1/at) r4/a0=r1/at r8/t0=-4(cfa)
080486b0: cfa=04(r4/a0) r4/a0=r1/at r8/t0=-4(cfa)
080486b1: cfa=08(r4/a0) r4/a0=r1/at r5/a1=-8(cfa) r8/t0=-4(cfa)
080486b3: cfa=08(r5/a1) r4/a0=r1/at r5/a1=-8(cfa) r8/t0=-4(cfa)
080486b4: cfa=08(r5/a1) r4/a0=-12(cfa) r5/a1=-8(cfa) r8/t0=-4(cfa)
You can use -v or -vv to get more details. Unfortunately it doesn't seem
to have a regnum mapping for x86 so you get generic register names instead
of eax/ebx/esp/etc but I'm sure you can figure it out. Or maybe you don't
care about x86, you didn't specify.
Brian