Unify tmate-debug.c with tmate-ssh-server

This commit is contained in:
Nicolas Viennot 2019-11-10 14:05:14 -05:00
parent 9fc6e96444
commit e5f6e68fad
2 changed files with 10 additions and 2 deletions

View File

@ -11,6 +11,7 @@
void tmate_print_stack_trace(void) {} void tmate_print_stack_trace(void) {}
void tmate_catch_sigsegv(void) {} void tmate_catch_sigsegv(void) {}
void tmate_preload_trace_lib(void) {}
#else #else
@ -84,8 +85,7 @@ void tmate_print_stack_trace(void)
free (strings); free (strings);
} }
static void handle_crash(int sig)
static void handle_crash(__unused int sig)
{ {
/* TODO send stack trace to server */ /* TODO send stack trace to server */
const char *what = sig == SIGSEGV ? "SIGSEGV" : "SIGABRT"; const char *what = sig == SIGSEGV ? "SIGSEGV" : "SIGABRT";
@ -102,4 +102,11 @@ void tmate_catch_sigsegv(void)
signal(SIGSEGV, handle_crash); signal(SIGSEGV, handle_crash);
signal(SIGABRT, handle_crash); signal(SIGABRT, handle_crash);
} }
void tmate_preload_trace_lib(void)
{
void *array[1];
backtrace(array, 1);
}
#endif #endif

View File

@ -203,6 +203,7 @@ extern void tmate_reconnect_session(struct tmate_session *session, const char *m
/* tmate-debug.c */ /* tmate-debug.c */
extern void tmate_print_stack_trace(void); extern void tmate_print_stack_trace(void);
extern void tmate_catch_sigsegv(void); extern void tmate_catch_sigsegv(void);
extern void tmate_preload_trace_lib(void);
/* tmate-msg.c */ /* tmate-msg.c */