By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,305 Members | 1,619 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,305 IT Pros & Developers. It's quick & easy.

Unable to print function names in stacktrace

P: n/a
hi friends,

I am using backtrace() and backtrace_symbols() functions from execinfo.h.

when I print backtrace I get only hex address of every function call. I know
that to get functions names, binary format of executable file must be ELF.

I set -rdynamic option during compilation but I don't get functions names.
is there any other otion we have to set?

pls help me.

my code is as follows

void *btArray[128];
int btSize;
char** btSymbols;

cout << endl << "########## Backtrace ##########" << endl;
btSize = backtrace(btArray, sizeof(btArray) / sizeof(void *));
cout << "Number of elements in backtrace: " << btSize << endl;

if (btSize > 0) {

btSymbols = backtrace_symbols(btArray, btSize);
if (btSymbols) {
for (int i = btSize - 1; i >= 0; --i) {
cout << btSymbols[i] << endl;
}
}
}

I am using
gcc -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.2.2 [FreeBSD] 20030205 (release)

Thanks in advance.
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Hitesh Patel" <hi*********@rediffmail.com> wrote...
I am using backtrace() and backtrace_symbols() functions from execinfo.h.
[...]


Neither 'backtrace' nor 'backtrace_symbols' is a standard function.
Perhaps you should ask in a newsgroup where they would be on topic,
like gnu.gcc.help or the newsgroup for FreeBDS.

Jul 22 '05 #2

P: n/a
"Victor Bazarov" <v.********@comAcast.net> wrote in message news:<RH2Ab.429984$HS4.3395724@attbi_s01>...
"Hitesh Patel" <hi*********@rediffmail.com> wrote...
I am using backtrace() and backtrace_symbols() functions from execinfo.h.
[...]


Neither 'backtrace' nor 'backtrace_symbols' is a standard function.
Perhaps you should ask in a newsgroup where they would be on topic,
like gnu.gcc.help or the newsgroup for FreeBDS.


I found one utility named addr2line in freeBSD. which gives function name,
file name and line number if code is compiled in debug mode. otherwise only
give function name.

Hitesh Patel
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.