VirtualBox

Ignore:
Timestamp:
Apr 27, 2009 4:25:38 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
46592
Message:

Main: remove debugging signal handler from VBoxSVC that prevented it from dumping core

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xpcom/server.cpp

    r18265 r19222  
    6363#ifndef RT_OS_OS2
    6464# include <sys/resource.h>
    65 #endif
    66 
    67 // for the backtrace signal handler
    68 #if defined(DEBUG) && defined(RT_OS_LINUX)
    69 # define USE_BACKTRACE
    70 #endif
    71 #if defined(USE_BACKTRACE)
    72 # include <execinfo.h>
    73 // get REG_EIP/RIP from ucontext.h
    74 # ifndef __USE_GNU
    75 #  define __USE_GNU
    76 # endif
    77 # include <ucontext.h>
    78 # ifdef RT_ARCH_AMD64
    79 #  define REG_PC REG_RIP
    80 # else
    81 #  define REG_PC REG_EIP
    82 # endif
    8365#endif
    8466
     
    785767}
    786768
    787 #if defined(USE_BACKTRACE)
    788 /**
    789  * the signal handler that prints out a backtrace of the call stack.
    790  * the code is taken from http://www.linuxjournal.com/article/6391.
    791  */
    792 static void bt_sighandler (int sig, siginfo_t *info, void *secret)
    793 {
    794 
    795     void *trace[16];
    796     char **messages = (char **)NULL;
    797     int i, trace_size = 0;
    798     ucontext_t *uc = (ucontext_t *)secret;
    799 
    800     // Do something useful with siginfo_t
    801     if (sig == SIGSEGV)
    802         Log (("Got signal %d, faulty address is %p, from %p\n",
    803                sig, info->si_addr, uc->uc_mcontext.gregs[REG_PC]));
    804     else
    805         Log (("Got signal %d\n", sig));
    806 
    807     trace_size = backtrace (trace, 16);
    808     // overwrite sigaction with caller's address
    809     trace[1] = (void *) uc->uc_mcontext.gregs [REG_PC];
    810 
    811     messages = backtrace_symbols (trace, trace_size);
    812     // skip first stack frame (points here)
    813     Log (("[bt] Execution path:\n"));
    814     for (i = 1; i < trace_size; ++i)
    815         Log (("[bt] %s\n", messages[i]));
    816 
    817     exit (0);
    818 }
    819 #endif
    820 
    821769int main (int argc, char **argv)
    822770{
     
    1014962#endif // ifdef RT_OS_OS2
    1015963
    1016 #if defined(USE_BACKTRACE)
    1017     {
    1018         /* install our signal handler to backtrace the call stack */
    1019         struct sigaction sa;
    1020         sa.sa_sigaction = bt_sighandler;
    1021         sigemptyset (&sa.sa_mask);
    1022         sa.sa_flags = SA_RESTART | SA_SIGINFO;
    1023         sigaction (SIGSEGV, &sa, NULL);
    1024         sigaction (SIGBUS, &sa, NULL);
    1025         sigaction (SIGUSR1, &sa, NULL);
    1026     }
    1027 #endif
    1028 
    1029964    /*
    1030965     * Initialize the VBox runtime without loading
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette