Backtrace in uClibC

ANDY KENNEDY ANDY.KENNEDY at adtran.com
Wed Feb 23 05:03:53 UTC 2011


> >
> > So, initially it looks like this would (at least) work for mips32r2
> >
> 
> Fine, please let us to know your outcomes.


Doh!  Stupid question:  How would I test that this _actually_ works?

I mean, I tried this:


#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <execinfo.h>

void *barray[128];

static void segfault(int sgn) {
        size_t size = backtrace(barray, sizeof(barray));
        fprintf(stderr, "Backtrace: \n");
        backtrace_symbols_fd(barray, size, 2);
        abort();
}

int f1(int *ptr)
{
        printf("Pointer = %i\n", *ptr);
        return 0;
}

int f2(int *ptr)
{
        f1((int *)(ptr + 0x5555aaaa));
        return 0;
}

int main(void)
{
        signal(11, segfault);
        f2((int *)109324);
        return 0;
}

but I only got this:

Backtrace: 
Aborted


When I compile I have to specify -lubacktrace; however, when linking
against
glibc, the backtrace family is apparently included by default.

FYI:  I get no linker errors, and no warnings.

Please advise.

Andy




More information about the uClibc mailing list