libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libunwind-devel] Signal SIGSEGV clears Callstack


From: Prabhat Verma
Subject: Re: [Libunwind-devel] Signal SIGSEGV clears Callstack
Date: Thu, 14 Jun 2012 02:16:10 +0000

Please disregard my earlier post. Apologies…

 

-Prabhat

 

From: libunwind-devel-bounces+address@hidden [mailto:libunwind-devel-bounces+address@hidden On Behalf Of Carsten Edenfeld
Sent: Wednesday, June 13, 2012 12:18 PM
To: address@hidden
Subject: [Libunwind-devel] Signal SIGSEGV clears Callstack

 

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]