HTML_Lectures/Virtualization_Lecture/vbox/src/VBox/Frontends/VirtualBox/src/main.cpp
/** X11, Linux, Debug: The signal handler that prints out a backtrace of the call stack.
  * @remarks The code is taken from http://www.linuxjournal.com/article/6391. */
X11, Linux, Debug: The signal handler that prints out a backtrace of the call stack.
X11 Linux Debug : The signal handler that prints out a backtrace of the call stack .
static void BackTraceSignalHandler(int sig, siginfo_t *pInfo, void *pSecret)
{
    void *trace[16];
    char **messages = (char **)0;
    int i, iTraceSize = 0;
    ucontext_t *uc = (ucontext_t *)pSecret;
    if (sig == SIGSEGV)
        Log(("GUI: Got signal %d, faulty address is %p, from %p\n",
             sig, pInfo->si_addr, uc->uc_mcontext.gregs[REG_PC]));
    else
        Log(("GUI: Got signal %d\n", sig));
    iTraceSize = backtrace(trace, 16);
    trace[1] = (void *)uc->uc_mcontext.gregs[REG_PC];
    messages = backtrace_symbols(trace, iTraceSize);
    Log(("GUI: [bt] Execution path:\n"));
    for (i = 1; i < iTraceSize; ++i)
        Log(("GUI: [bt] %s\n", messages[i]));
    exit(0);
}
static void BackTraceSignalHandler ( int sig , siginfo_t * pInfo , void * pSecret ) { void * trace [ 16 ] ; char * * messages = ( char * * ) 0 ; int i , iTraceSize = 0 ; ucontext_t * uc = ( ucontext_t * ) pSecret ; if ( sig == SIGSEGV ) Log ( ( " \n " , sig , pInfo -> si_addr , uc -> uc_mcontext . gregs [ REG_PC ] ) ) ; else Log ( ( " \n " , sig ) ) ; iTraceSize = backtrace ( trace , 16 ) ; trace [ 1 ] = ( void * ) uc -> uc_mcontext . gregs [ REG_PC ] ; messages = backtrace_symbols ( trace , iTraceSize ) ; Log ( ( " \n " ) ) ; for ( i = 1 ; i < iTraceSize ; ++ i ) Log ( ( " \n " , messages [ i ] ) ) ; exit ( 0 ) ; }
X11, Linux, Debug: The signal handler that prints out a backtrace of the call stack.
X11 Linux Debug : The signal handler that prints out a backtrace of the call stack .
/* Do something useful with siginfo_t: */ /* Or do nothing by default: */ /* Acquire backtrace of 16 lvls depth: */ /* Overwrite sigaction with caller's address: */ /* Translate the addresses into an array of messages: */ /* Skip first stack frame (points here): */