2 * Copyright (c) 2008, 2009 Nicira Networks.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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%tx)\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);