|
|
@ -63,7 +63,6 @@ static struct
|
|
|
|
int signum;
|
|
|
|
int signum;
|
|
|
|
pid_t pid;
|
|
|
|
pid_t pid;
|
|
|
|
std::optional<siginfo_t> siginfo;
|
|
|
|
std::optional<siginfo_t> siginfo;
|
|
|
|
char buf[1024];
|
|
|
|
|
|
|
|
} crash_info;
|
|
|
|
} crash_info;
|
|
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
namespace
|
|
|
@ -128,8 +127,6 @@ namespace
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int (*cc_user_info)(char*, char*);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void gdb_info(pid_t pid)
|
|
|
|
static void gdb_info(pid_t pid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char respfile[64];
|
|
|
|
char respfile[64];
|
|
|
@ -265,8 +262,6 @@ static void crash_catcher(int signum, siginfo_t* siginfo, void* context)
|
|
|
|
crash_info.siginfo = std::nullopt;
|
|
|
|
crash_info.siginfo = std::nullopt;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
crash_info.siginfo = *siginfo;
|
|
|
|
crash_info.siginfo = *siginfo;
|
|
|
|
if (cc_user_info)
|
|
|
|
|
|
|
|
cc_user_info(crash_info.buf, crash_info.buf + sizeof(crash_info.buf));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Fork off to start a crash handler */
|
|
|
|
/* Fork off to start a crash handler */
|
|
|
|
switch ((dbg_pid = fork()))
|
|
|
|
switch ((dbg_pid = fork()))
|
|
|
@ -367,8 +362,6 @@ static void crash_handler(const char* logfile)
|
|
|
|
|
|
|
|
|
|
|
|
sys_info();
|
|
|
|
sys_info();
|
|
|
|
|
|
|
|
|
|
|
|
crash_info.buf[sizeof(crash_info.buf) - 1] = '\0';
|
|
|
|
|
|
|
|
printf("%s\n", crash_info.buf);
|
|
|
|
|
|
|
|
fflush(stdout);
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
|
|
|
|
if (crash_info.pid > 0)
|
|
|
|
if (crash_info.pid > 0)
|
|
|
@ -425,8 +418,7 @@ static void getExecPath(char** argv)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int crashCatcherInstallHandlers(
|
|
|
|
int crashCatcherInstallHandlers(int argc, char** argv, int num_signals, int* signals, const char* logfile)
|
|
|
|
int argc, char** argv, int num_signals, int* signals, const char* logfile, int (*user_info)(char*, char*))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct sigaction sa;
|
|
|
|
struct sigaction sa;
|
|
|
|
stack_t altss;
|
|
|
|
stack_t altss;
|
|
|
@ -435,8 +427,6 @@ int crashCatcherInstallHandlers(
|
|
|
|
if (argc == 2 && strcmp(argv[1], crash_switch) == 0)
|
|
|
|
if (argc == 2 && strcmp(argv[1], crash_switch) == 0)
|
|
|
|
crash_handler(logfile);
|
|
|
|
crash_handler(logfile);
|
|
|
|
|
|
|
|
|
|
|
|
cc_user_info = user_info;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getExecPath(argv);
|
|
|
|
getExecPath(argv);
|
|
|
|
|
|
|
|
|
|
|
|
/* Set an alternate signal stack so SIGSEGVs caused by stack overflows
|
|
|
|
/* Set an alternate signal stack so SIGSEGVs caused by stack overflows
|
|
|
@ -534,7 +524,7 @@ void crashCatcherInstall(int argc, char** argv, const std::filesystem::path& cra
|
|
|
|
if ((argc == 2 && strcmp(argv[1], crash_switch) == 0) || !is_debugger_present())
|
|
|
|
if ((argc == 2 && strcmp(argv[1], crash_switch) == 0) || !is_debugger_present())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int s[5] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS, SIGABRT };
|
|
|
|
int s[5] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS, SIGABRT };
|
|
|
|
if (crashCatcherInstallHandlers(argc, argv, 5, s, crashLogPath.c_str(), nullptr) == -1)
|
|
|
|
if (crashCatcherInstallHandlers(argc, argv, 5, s, crashLogPath.c_str()) == -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log(Debug::Warning) << "Installing crash handler failed";
|
|
|
|
Log(Debug::Warning) << "Installing crash handler failed";
|
|
|
|
}
|
|
|
|
}
|
|
|
|