[arm-gnu] Regarding backtrace from glibc-2.10/stdlib/abort.c
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[arm-gnu] Regarding backtrace from glibc-2.10/stdlib/abort.c



Hi All,

I want function backtrace just before abort()  function call.
For that I have done following backtrace modification  in
glibc-2.10/stdlib/abort.c file

/* Cause an abnormal program termination with core-dump.  */
void abort (void) {
        struct sigaction act;
        sigset_t sigs;
+#if 1
+        int j, nptrs;
+#define SIZE 10
+        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);
+#endif
/* First acquire the lock.  */
  __libc_lock_lock_recursive (lock);

I am using  codesourcery. tool chain sorce for 2009q3.
I am testing with sample test (test.c) application.

#include <stdio.h>
#include <stdlib.h>
int main(void)
{
        printf("##### abort() syscall test...\n");
        abort();
        return 0;
}

The following out put i am getting
# ./test
/lib/libc.so.6(__libc_start_main+0x118) [0x400593ac]
backtrace() returned 10 addresses
/lib/libc.so.6(abort+0x14) [0x40075c6c]
/lib/libc.so.6(abort+0x14) [0x40075c6c]
/lib/libc.so.6(abort+0x14) [0x40075c6c]
/lib/libc.so.6(abort+0x14) [0x40075c6c]
/lib/libc.so.6(abort+0x14) [0x40075c6c]
/lib/libc.so.6(abort+0x14) [0x40075c6c]
/lib/libc.so.6(abort+0x14) [0x40075c6c]
/lib/libc.so.6(abort+0x14) [0x40075c6c]
/lib/libc.so.6(abort+0x14) [0x40075c6c]
/lib/libc.so.6(abort+0x14) [0x40075c6c]
Aborted

Can some one explain where i am wrong?

Thanks,
Trisha