[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
backtrace() / backtrace_symbols() results are confusing
From: |
Chris Markle |
Subject: |
backtrace() / backtrace_symbols() results are confusing |
Date: |
Thu, 08 May 2003 12:13:13 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 |
All,
Confused about backtrace() and backtrace_symbols() results... In the
following sample program which has basically main() -> dummy_func1() ->
dummy_func2() -> dummy_func3() -> print_trace() -> backtrace(),
backtrace() returns 7 stack frames. I understand the last 6 which show
libc -> main() -> f1() -> f2() -> f3() -> print_trace() ->
backtrace()... But what is the first entry?
test1(backtrace_symbols+0x3d) [0x8048681]
When I try an addr2line on 8048681 (0x8048681) it returns "??"
I haven't even called backtrace_symbols() yet just backtrace().
Can someone shed some light on this please?
Chris
output of execution follows:
$ ./test1
obtained 7 stack frames
test1(print_trace+0x1d) [0x804877d]
test1(dummy_func3+0xb) [0x8048857]
test1(dummy_func2+0xb) [0x8048847]
test1(dummy_func1+0xb) [0x8048837]
test1(main+0xb) [0x8048823]
/lib/i686/libc.so.6(__libc_start_main+0x93) [0x4003e657]
test1(backtrace_symbols+0x3d) [0x8048681]
code follows:
/*
* Basic test program to see how glibc backtrace() and
* backtrace_symbols() work.
*/
#include <stdio.h>
#include <execinfo.h>
#include <stdlib.h>
void dummy_func1(void);
void dummy_func2(void);
void dummy_func3(void);
void
print_trace(void)
{
void *array[200];
size_t size;
char **strings;
size_t i;
size = backtrace(array, 200);
printf("obtained %zd stack frames\n", size);
strings = backtrace_symbols(array, size);
for (i = 0; i < size; i++)
printf("%s\n", strings[i]);
free(strings);
}
int
main(void)
{
dummy_func1();
return 0;
}
void
dummy_func1(void)
{
dummy_func2();
}
void
dummy_func2(void)
{
dummy_func3();
}
void
dummy_func3(void)
{
print_trace();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- backtrace() / backtrace_symbols() results are confusing,
Chris Markle <=