[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libunwind-devel] Stack not completely resolved
From: |
Eugen-Andrei Gavriloaie |
Subject: |
[Libunwind-devel] Stack not completely resolved |
Date: |
Thu, 24 Apr 2014 07:58:15 +0300 |
Hello to all,
I have to make some stack traces when SIGSEGV is triggered. Unfortunately, it
doesn’t work as expected. My environment is based on OpenWRT running on ARM
using uClibc 0.9.32.2 and gcc-linaro-4.7
Here is my signal handler (I have copied portions of the code from here:
http://lists.nongnu.org/archive/html/libunwind-devel/2011-08/txt2FG_DI1UdS.txt)
void DumpStack(int signal, siginfo_t *pInfo, void *pCastedContext) {
unw_cursor_t cursor;
unw_context_t uc;
unw_getcontext(&uc);
unw_init_local(&cursor, &uc);
int ret;
do {
unw_word_t ip, sp, offp;
char buf[512];
unw_get_reg(&cursor, UNW_REG_IP, &ip);
unw_get_reg(&cursor, UNW_REG_SP, &sp);
unw_get_proc_name(&cursor, buf, sizeof (buf), &offp);
if (unw_is_signal_frame(&cursor))
printf("signal frame\tip: %10p, sp: %10p %s\n",
(void*) ip, (void*) sp, buf);
else
printf("standard frame\tip: %10p, sp: %10p %s\n",
(void*) ip, (void*) sp, buf);
} while ((ret = unw_step(&cursor)) > 0);
}
And somewhere inside the test app I have:
…
free((void *)0x1234);
…
The output is:
standard frame ip: 0x259e8, sp: 0xbee01438 _start
signal frame ip: 0x402d8b58, sp: 0xbee056a8 __default_rt_sa_restorer
standard frame ip: 0x40309868, sp: 0xbee05a18 free
Notice that it doesn’t get past the free() function call.
However, when I insert the following code:
…
((uint8_t *)0x1234)[0]=0;
…
I get a correct stack trace:
standard frame ip: 0x259e8, sp: 0xbef55458 _start
signal frame ip: 0x4024eb58, sp: 0xbef596c8 __default_rt_sa_restorer
standard frame ip: 0x38858, sp: 0xbef59a38
_ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_
standard frame ip: 0xdc08, sp: 0xbef59a48 _init
standard frame ip: 0x40286d0c, sp: 0xbef59c40 __uClibc_main
What needs to be done to get past libc and further into the stack?
Best regards,
Andrei
- [Libunwind-devel] Stack not completely resolved,
Eugen-Andrei Gavriloaie <=