2 * Copyright (c) 2008, 2009 Nicira Networks.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28 #define THIS_MODULE VLM_fault
31 fault_handler(int sig_nr)
33 VLOG_EMER("Caught signal %d.", sig_nr);
38 signal(sig_nr, SIG_DFL);
47 frame[0] points to the next frame.
48 frame[1] points to the return address. */
50 for (frame = __builtin_frame_address(0);
51 frame != NULL && frame[0] != NULL;
54 if (!dladdr(frame[1], &addrinfo) || !addrinfo.dli_sname) {
55 fprintf(stderr, " 0x%08"PRIxPTR"\n", (uintptr_t) frame[1]);
57 fprintf(stderr, " 0x%08"PRIxPTR" (%s+0x%x)\n",
58 (uintptr_t) frame[1], addrinfo.dli_sname,
59 (char *) frame[1] - (char *) addrinfo.dli_saddr);
66 register_fault_handlers(void)
68 signal(SIGABRT, fault_handler);
69 signal(SIGBUS, fault_handler);
70 signal(SIGFPE, fault_handler);
71 signal(SIGILL, fault_handler);
72 signal(SIGSEGV, fault_handler);