This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
`backtrace' implemented on MIPS?
- From: Pan ruochen <panruochen at gmail dot com>
- To: libc-help at sourceware dot org
- Date: Tue, 22 Feb 2011 10:46:50 +0800
- Subject: `backtrace' implemented on MIPS?
Hi All,
I tried the example code along with the backtrace manpage. But the
executabe didn't seem to work on MIPS.
$cat test_backtrace.c
=============================================================
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void do_backtrace(void)
{
const int SIZE = 100;
int j, nptrs;
void *buffer[SIZE];
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)
{
do_backtrace();
}
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(-1);
}
myfunc(atoi(argv[1]));
exit(0);
}
=============================================================
$mips-linux-gcc -EL -O2 test_backtrace.c
/ # ./a.out 6
backtrace() returned 1 addresses
[0x7ff54868]
The results were totally different from thoes on x86.
$gcc test_backtrace.c
$./a.out 6
backtrace() returned 11 addresses
./bt [0x804864d]
./bt [0x80486dc]
./bt [0x80486ff]
./bt [0x80486f8]
./bt [0x80486f8]
./bt [0x80486f8]
./bt [0x80486f8]
./bt [0x80486f8]
./bt [0x8048766]
/lib/libc.so.6(__libc_start_main+0xe6) [0x7275d6]
./bt [0x80484f1]
So, has backtrace been implemented on MIPS yet?
PRC
Feb 22,2011