mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.8 KiB
C++
78 lines
1.8 KiB
C++
4 years ago
|
/**
|
||
7 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
7 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2020 Software Radio Systems Limited
|
||
7 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
7 years ago
|
*
|
||
|
*/
|
||
|
|
||
|
#include <pthread.h>
|
||
|
#include <signal.h>
|
||
5 years ago
|
#include <stdio.h>
|
||
7 years ago
|
#include <stdlib.h>
|
||
|
|
||
7 years ago
|
#include "srslte/common/crash_handler.h"
|
||
4 years ago
|
|
||
|
#if HAVE_BACKWARD
|
||
|
#include "srslte/common/backward.hpp"
|
||
|
using namespace backward;
|
||
|
void srslte_debug_handle_crash(int argc, char** argv)
|
||
|
{
|
||
|
backward::SignalHandling sh;
|
||
|
}
|
||
|
#else // HAVE_BACKWARD
|
||
|
#include "srslte/common/backtrace.h"
|
||
6 years ago
|
#include "srslte/version.h"
|
||
7 years ago
|
|
||
|
const static char crash_file_name[] = "./srsLTE.backtrace.crash";
|
||
5 years ago
|
static int bt_argc;
|
||
|
static char** bt_argv;
|
||
7 years ago
|
|
||
5 years ago
|
static void crash_handler(int sig)
|
||
|
{
|
||
|
FILE* f = fopen(crash_file_name, "a");
|
||
7 years ago
|
if (!f) {
|
||
|
printf("srsLTE crashed... we could not save backtrace in '%s'...\n", crash_file_name);
|
||
|
} else {
|
||
5 years ago
|
time_t lnTime;
|
||
5 years ago
|
struct tm stTime;
|
||
5 years ago
|
char strdate[32];
|
||
7 years ago
|
|
||
|
time(&lnTime);
|
||
5 years ago
|
gmtime_r(&lnTime, &stTime);
|
||
7 years ago
|
|
||
5 years ago
|
strftime(strdate, sizeof(strdate), "%d/%m/%Y %H:%M:%S", &stTime);
|
||
7 years ago
|
|
||
|
fprintf(f, "--- command='");
|
||
|
for (int i = 0; i < bt_argc; i++) {
|
||
|
fprintf(f, "%s%s", (i == 0) ? "" : " ", bt_argv[i]);
|
||
|
}
|
||
|
fprintf(f, "' version=%s signal=%d date='%s' ---\n", SRSLTE_VERSION_STRING, sig, strdate);
|
||
|
|
||
6 years ago
|
srslte_backtrace_print(f);
|
||
7 years ago
|
fprintf(f, "\n");
|
||
|
|
||
|
printf("srsLTE crashed... backtrace saved in '%s'...\n", crash_file_name);
|
||
|
fclose(f);
|
||
|
}
|
||
|
printf("--- exiting ---\n");
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
5 years ago
|
void srslte_debug_handle_crash(int argc, char** argv)
|
||
|
{
|
||
7 years ago
|
bt_argc = argc;
|
||
|
bt_argv = argv;
|
||
|
|
||
|
signal(SIGSEGV, crash_handler);
|
||
|
signal(SIGABRT, crash_handler);
|
||
|
signal(SIGILL, crash_handler);
|
||
|
signal(SIGFPE, crash_handler);
|
||
|
signal(SIGPIPE, crash_handler);
|
||
|
}
|
||
4 years ago
|
|
||
|
#endif // HAVE_BACKWARD
|