|
From: | Carsten Edenfeld |
Subject: | [Libunwind-devel] Signal SIGSEGV clears Callstack |
Date: | Wed, 13 Jun 2012 18:18:26 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120421 Thunderbird/12.0 |
Hi, I am trying to use the libunwind library for getting a callstack while my application crashes with a segmentation fault signal. But, if the app crashes, I do not get a correct callstack, but always this output: _ZL13check_sys_sigi __restore_rt If I am using the unwind code without a (forced) exception, but instead directly calling the following function, everything works as expected: void show_backtrace (void) { char name[256]; unw_cursor_t cursor; unw_context_t uc; unw_word_t ip, sp, offp; unw_getcontext(&uc); unw_init_local(&cursor, &uc); while (unw_step(&cursor) > 0) { char file[256]; int line = 0; name[0] = '\0'; int iResult = unw_get_proc_name(&cursor, name, 256, &offp); if ( iResult != UNW_ESUCCESS ) { DEBUGERROR("no proc name"); } unw_get_reg(&cursor, UNW_REG_IP, &ip); unw_get_reg(&cursor, UNW_REG_SP, &sp); printf ("%s ip = %lx, sp = %lx\n", name, (long) ip, (long) sp); DEBUGERROR(name); //getFileAndLine((long)ip, file, 256, &line); //printf("%s in file %s line %d\n", name, file, line); } } Any clues what I am doing wrong ? I am using Suse 12.1 with libunwind version 0.98.6-39.1.2. All object files are compiled with the "-g" and "-rdynamic" flags. The signal handling is initialized with the following code: static void check_sys_sig ( int sig_nr ) { show_backtrace(); } bool register_sys_signal_handler() { sys_signal_add (SIGSEGV, check_sys_sig); } void main () { . . . register_sys_signal_handler(); // a) force crash *(int*)0=0; // <- wrong/empty callstack // OR b) using directly show_backtrace(); show_backtrace(); // <- correct callstack } Thanks, Carsten Edenfeld |
[Prev in Thread] | Current Thread | [Next in Thread] |