|
From: | Pallav Singh |
Subject: | Re: [Libunwind-devel] Help : Lowest address of stack frame causing segfault |
Date: | Sun, 23 Mar 2014 02:04:12 +0530 |
Hi Arun,
Thanks for the explanation given. It’s really Useful.
We are trying to use libunwind to unwind function call stack, But
We need to have Both the boundary of stack frame with –O3 optimization
where frame pointers are omitted by Compilers.
1. Considering the below example, Can we make assumption that stack pointer
returned by API “unw_get_reg(&cursor, UNW_REG_SP, &sp)” will be always
be at 16 byte displacement to previous stack frame bottom using
show_backtrace(void) of libunwind.
Previous stack frame bottom = sp + 16.
http://stackoverflow.com/questions/7534420/gas-explanation-of-cfi-def-cfa-offset
2. Can we get bottom of stack frame, causing segfault using libunwind.
We are only getting instruction pointer as bottom most address.
#define UNW_LOCAL_ONLY
#include <libunwind.h>
void show_backtrace (void) {
unw_cursor_t cursor; unw_context_t uc;
unw_word_t ip, sp;
unw_getcontext(&uc);
unw_init_local(&cursor, &uc);
while (unw_step(&cursor) > 0) {
unw_get_reg(&cursor, UNW_REG_IP, &ip);
unw_get_reg(&cursor, UNW_REG_SP, &sp);
printf ("ip = %lx, sp = %lx\n", (long) ip, (long) sp);
}
}
PS : we are fine with tail recursion optimization of compilers.
Thanks
Pallav Singh
[Prev in Thread] | Current Thread | [Next in Thread] |