1 /* Copyright (C) 2007 Board of Trustees, Leland Stanford Jr. University.
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to
5 * deal in the Software without restriction, including without limitation the
6 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 * sell copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
32 #define THIS_MODULE VLM_fault
35 fault_handler(int sig_nr)
37 VLOG_EMER("Caught signal %d.", sig_nr);
42 signal(sig_nr, SIG_DFL);
51 frame[0] points to the next frame.
52 frame[1] points to the return address. */
54 for (frame = __builtin_frame_address(0);
55 frame != NULL && frame[0] != NULL;
58 if (!dladdr(frame[1], &addrinfo) || !addrinfo.dli_sname) {
59 fprintf(stderr, " 0x%08"PRIxPTR"\n", (uintptr_t) frame[1]);
61 fprintf(stderr, " 0x%08"PRIxPTR" (%s+0x%x)\n",
62 (uintptr_t) frame[1], addrinfo.dli_sname,
63 (char *) frame[1] - (char *) addrinfo.dli_saddr);
70 register_fault_handlers(void)
72 signal(SIGABRT, fault_handler);
73 signal(SIGBUS, fault_handler);
74 signal(SIGFPE, fault_handler);
75 signal(SIGILL, fault_handler);
76 signal(SIGSEGV, fault_handler);