Code Comments
Programming Forum and web based access to our favorite programming groups.Hello,
I am trying to use the glibc functions backtrace*() to dump the stack. It
works but only partially - is there any way to have the functions' names?
snd_pcm_writei(hw:0) error: Broken pipe
./p2p [0x804995e]
./p2p [0x8049940]
./p2p [0x804ac07]
./p2p [0x80495be]
/lib/tls/libc.so.6(__libc_start_main+0xd3) [0x3e1e23]
./p2p [0x80493f5]
The code looks like:
void *array[ STACK_DUMP_SZ ];
size_t size;
char **strings;
size = backtrace( array, STACK_DUMP_SZ );
strings = backtrace_symbols( array, size );
if ( strings ) {
int i;
for ( i = 0; i < size; i++ )
fprintf( fp, "%s\n", strings[i] );
free( strings );
}
Regards
a.
Post Follow-up to this messageHiya, Valh wrote: > I am trying to use the glibc functions backtrace*() to dump the stack. It > works but only partially - is there any way to have the functions' names? That'll probably be because be because you didn't link with -rdynamic (assuming that your platform uses ELF): > Currently, the function name and offset only be obtained on systems > that use the ELF binary format for programs and libraries. On other > systems, only the hexadecimal return address will be present. Also, > you may need to pass additional flags to the linker to make the > function names available to the program. (For example, on systems > using GNU ld, you must pass (-rdynamic.) Cheers, -- John McCallum Emerson Network Power - Embedded Computing, Edinburgh, UK For email, leave the web and we're not so small.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.