]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | /* SPDX-License-Identifier: BSD-3-Clause |
2 | * Copyright(c) 2010-2014 Intel Corporation | |
3 | */ | |
4 | ||
5 | #ifdef RTE_BACKTRACE | |
6 | #include <execinfo.h> | |
7 | #endif | |
8 | #include <stdarg.h> | |
9 | #include <signal.h> | |
10 | #include <stdlib.h> | |
11 | #include <stdio.h> | |
12 | #include <stdint.h> | |
13 | ||
14 | #include <rte_log.h> | |
15 | #include <rte_debug.h> | |
16 | #include <rte_common.h> | |
17 | #include <rte_eal.h> | |
18 | ||
19 | #define BACKTRACE_SIZE 256 | |
20 | ||
21 | /* dump the stack of the calling core */ | |
22 | void rte_dump_stack(void) | |
23 | { | |
24 | #ifdef RTE_BACKTRACE | |
25 | void *func[BACKTRACE_SIZE]; | |
26 | char **symb = NULL; | |
27 | int size; | |
28 | ||
29 | size = backtrace(func, BACKTRACE_SIZE); | |
30 | symb = backtrace_symbols(func, size); | |
31 | ||
32 | if (symb == NULL) | |
33 | return; | |
34 | ||
35 | while (size > 0) { | |
36 | rte_log(RTE_LOG_ERR, RTE_LOGTYPE_EAL, | |
37 | "%d: [%s]\n", size, symb[size - 1]); | |
38 | size --; | |
39 | } | |
40 | ||
41 | free(symb); | |
42 | #endif /* RTE_BACKTRACE */ | |
43 | } | |
44 | ||
45 | /* not implemented in this environment */ | |
46 | void rte_dump_registers(void) | |
47 | { | |
48 | return; | |
49 | } | |
50 | ||
51 | /* call abort(), it will generate a coredump if enabled */ | |
52 | void __rte_panic(const char *funcname, const char *format, ...) | |
53 | { | |
54 | va_list ap; | |
55 | ||
56 | rte_log(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, "PANIC in %s():\n", funcname); | |
57 | va_start(ap, format); | |
58 | rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap); | |
59 | va_end(ap); | |
60 | rte_dump_stack(); | |
61 | rte_dump_registers(); | |
62 | abort(); | |
63 | } | |
64 | ||
65 | /* | |
66 | * Like rte_panic this terminates the application. However, no traceback is | |
67 | * provided and no core-dump is generated. | |
68 | */ | |
69 | void | |
70 | rte_exit(int exit_code, const char *format, ...) | |
71 | { | |
72 | va_list ap; | |
73 | ||
74 | if (exit_code != 0) | |
75 | RTE_LOG(CRIT, EAL, "Error - exiting with code: %d\n" | |
76 | " Cause: ", exit_code); | |
77 | ||
78 | va_start(ap, format); | |
79 | rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap); | |
80 | va_end(ap); | |
81 | ||
82 | #ifndef RTE_EAL_ALWAYS_PANIC_ON_ERROR | |
83 | if (rte_eal_cleanup() != 0) | |
84 | RTE_LOG(CRIT, EAL, | |
85 | "EAL could not release all resources\n"); | |
86 | exit(exit_code); | |
87 | #else | |
88 | rte_dump_stack(); | |
89 | rte_dump_registers(); | |
90 | abort(); | |
91 | #endif | |
92 | } |