[ELDK] ELDK 5.2 and backtrace on ARM Kirkwood not working
Andreas Huber
andreas.huber at keymile.com
Tue Jul 3 13:26:24 CEST 2012
Hello,
we use glibc's backtrace function to gather some information when our
software crashes.
(see http://www.kernel.org/doc/man-pages/online/pages/man3/backtrace.3.html)
The program at the bottom of the man page produces the expected result
for ELDK 4.2. But for ELDK 5.2 it does not work any more:
ELDK 4.2:
$ gcc -rdynamic -o prog prog.c
$ ./prog 3
backtrace() returned 7 addresses
./prog(puts+0x100) [0x8544]
./prog(puts+0x1bc) [0x8600]
./prog(backtrace_symbols+0x248) [0x8644]
./prog(backtrace_symbols+0x240) [0x863c]
./prog(backtrace_symbols+0x240) [0x863c]
./prog(backtrace_symbols+0x2c0) [0x86bc]
/lib/libc.so.6(__libc_start_main+0x1ac) [0x400a2a5c]
ELDK 5.2:
$ gcc -rdynamic -o prog prog.c
$ ./prog 3
backtrace() returned 0 addresses
Trying different compiler flags did not help (-O0,
-fno-omit-frame-pointer, -g, ...). Maybe I missed the important one for
this problem.
Has anybody an idea what goes wrong?
Regards,
Andreas
### prog.c from man page
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void
myfunc3(void)
{
int j, nptrs;
#define SIZE 100
void *buffer[100];
char **strings;
nptrs = backtrace(buffer, SIZE);
printf("backtrace() returned %d addresses\n", nptrs);
/* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO)
would produce similar output to the following: */
strings = backtrace_symbols(buffer, nptrs);
if (strings == NULL) {
perror("backtrace_symbols");
exit(EXIT_FAILURE);
}
for (j = 0; j < nptrs; j++)
printf("%s\n", strings[j]);
free(strings);
}
static void /* "static" means don't export the symbol... */
myfunc2(void)
{
myfunc3();
}
void
myfunc(int ncalls)
{
if (ncalls > 1)
myfunc(ncalls - 1);
else
myfunc2();
}
int
main(int argc, char *argv[])
{
if (argc != 2) {
fprintf(stderr, "%s num-calls\n", argv[0]);
exit(EXIT_FAILURE);
}
myfunc(atoi(argv[1]));
exit(EXIT_SUCCESS);
}
More information about the eldk
mailing list