[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] pstack for ARM


Please find attached a patch to add support for ARM binaries in
pstack. It replaces the x86 specific stuff with the ARM equivalent.
Currently it works only for target binaries which aren't compiled with
the thumb instruction set (the same goes for the shared libraries).
Note that pstack itself may be compiled as thumb or ARM.

For running pstack on ARM, the target binary should also be compiled
with frame pointer support and should be unstripped (or
--debug-strip'd; preserving the symbol and string tables). Same goes
for the corresponding shared libraries, although its optional
(otherwise we'd only get a limited stack trace, as shown below ).

I compiled the following program with a uClibc based buildroot distro
for ARMv5 (gcc 4.0.1):

#include <stdio.h>

static int foo3()
{  while (1) sleep(1); }

static int foo2()
{  foo3(); }

static int foo1()
{ foo2(); }

int main()
{ foo1();  return 0; }


Compiled using:
arm-linux-gcc -o hello hello.c

Ran pstack:
/ # hello &
/ # ps | grep hello | cut -d' ' -f2
/ # pstack 45

45: hello
(No symbols found in /lib/libgcc_s.so.1)
(No symbols found in /lib/libc.so.0)
(No symbols found in /lib/ld-uClibc.so.0)
0x4003dfb8: ????
0x000085bc: foo2() [at 0x000085ac]
0x000085d0: foo1() [at 0x000085c0]
0x000085e4: main() [at 0x000085d4]

The shared libraries were neither compiled with frame-pointer support
nor were they unstripped. So the stack trace shows only those function
names which could be resolved using the symbol tables of the 'hello'
binary. In case the shared libraries are optimized (O[s123]) an
explicit '-fno-omit-frame-pointer' might be necessary while compiling

Abhishek Sagar

P.S: I hope I'm mailing to the right forum. I couldn't find for any
active development on this package elsewhere.

Attachment: pstack-1.2_arm.patch
Description: Binary data

Reply to: