Changeset 19222 in vbox for trunk/src/VBox/Main/xpcom/server.cpp
- Timestamp:
- Apr 27, 2009 4:25:38 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 46592
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/xpcom/server.cpp
r18265 r19222 63 63 #ifndef RT_OS_OS2 64 64 # include <sys/resource.h> 65 #endif66 67 // for the backtrace signal handler68 #if defined(DEBUG) && defined(RT_OS_LINUX)69 # define USE_BACKTRACE70 #endif71 #if defined(USE_BACKTRACE)72 # include <execinfo.h>73 // get REG_EIP/RIP from ucontext.h74 # ifndef __USE_GNU75 # define __USE_GNU76 # endif77 # include <ucontext.h>78 # ifdef RT_ARCH_AMD6479 # define REG_PC REG_RIP80 # else81 # define REG_PC REG_EIP82 # endif83 65 #endif 84 66 … … 785 767 } 786 768 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_t801 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 else805 Log (("Got signal %d\n", sig));806 807 trace_size = backtrace (trace, 16);808 // overwrite sigaction with caller's address809 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 #endif820 821 769 int main (int argc, char **argv) 822 770 { … … 1014 962 #endif // ifdef RT_OS_OS2 1015 963 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 #endif1028 1029 964 /* 1030 965 * Initialize the VBox runtime without loading
Note:
See TracChangeset
for help on using the changeset viewer.