Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Stack dumping with gcc
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.



Report this thread to moderator Post Follow-up to this message
Old Post
Valh
07-13-06 01:01 PM


Re: Stack dumping with gcc
Hiya,

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.

Report this thread to moderator Post Follow-up to this message
Old Post
John McCallum
07-13-06 11:59 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 03:20 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.