23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_LIB 27 # include <execinfo.h> 29 #include <sys/types.h> 31 #include <linux/limits.h> 52 #ifdef ENABLE_DETAILED_BACKTRACE 53 static void arch_backtrace_detailed(
void)
55 const char *gdb_path =
"/usr/bin/gdb";
56 const char *gdb_cmd =
"thread apply all bt";
59 char path_str[PATH_MAX];
62 fprintf(stderr,
"Trying to recover detailed backtrace...\n");
65 snprintf(pid_str,
sizeof(pid_str),
"%ld", (
long) getpid());
66 path_str_len = readlink(
"/proc/self/exe",
67 path_str,
sizeof(path_str) - 1);
68 if (path_str_len == -1)
70 path_str[path_str_len] =
'\0';
75 waitpid(pid,
NULL, 0);
76 }
else if (pid == 0) {
78 dup2(STDERR_FILENO, STDOUT_FILENO);
79 execl(gdb_path, gdb_path,
"-batch",
"-nx",
"-ex", gdb_cmd,
80 path_str, pid_str,
NULL);
96 backtrace_symbols_fd(trace,
nr, STDERR_FILENO);
98 #ifdef ENABLE_DETAILED_BACKTRACE 99 arch_backtrace_detailed();
116 "Motr panic: %s at %s() %s:%i (errno: %i) (last failed: %s)" 117 " [git: %s] pid: %u %s\n",
118 c->pc_expr,
c->pc_func,
c->pc_file,
c->pc_lineno, errno,
121 if (
c->pc_fmt !=
NULL) {
122 fprintf(stderr,
"Motr panic reason: ");
123 vfprintf(stderr,
c->pc_fmt, ap);
124 fprintf(stderr,
"\n");
138 if (debugger ==
NULL) {
140 }
else if (!strcmp(debugger,
"wait")) {
141 fprintf(stderr,
"Motr pid %u waits for debugger.\n", getpid());
151 volatile bool stop =
true;
156 }
else if (
rc == 0) {
166 #undef M0_TRACE_SUBSYSTEM
M0_INTERNAL const char * m0_trace_file_path_get(void)
M0_INTERNAL const char * m0_failed_condition
const struct m0_build_info * m0_build_info_get(void)
static struct m0_addb2_callback c
M0_INTERNAL void m0_debugger_invoke(void)
M0_INTERNAL void m0_arch_backtrace(void)
const char * bi_git_describe
M0_EXTERN char * m0_debugger_args[4]
M0_INTERNAL void m0_arch_panic(const struct m0_panic_ctx *ctx, va_list ap) __attribute__((noreturn))
#define M0_IMPOSSIBLE(fmt,...)