From b7513da92b969fa681dd9d21ae8930e90a7ee4ca Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 24 Feb 2008 18:10:11 +0100 Subject: [PATCH] Moved sigsegv function to wee-debug.c --- src/core/wee-debug.c | 36 ++++++++++++++++++++++++++++++++++++ src/core/wee-debug.h | 1 + src/core/weechat.c | 36 +----------------------------------- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/src/core/wee-debug.c b/src/core/wee-debug.c index d10039849..2682e4e16 100644 --- a/src/core/wee-debug.c +++ b/src/core/wee-debug.c @@ -26,12 +26,15 @@ #include #include "weechat.h" +#include "wee-backtrace.h" #include "wee-config-file.h" #include "wee-log.h" #include "wee-hook.h" +#include "wee-string.h" #include "../gui/gui-buffer.h" #include "../gui/gui-chat.h" #include "../gui/gui-hotlist.h" +#include "../gui/gui-main.h" #include "../gui/gui-window.h" #include "../plugins/plugin.h" @@ -101,6 +104,39 @@ debug_dump_cb (void *data, char *signal, char *type_data, void *signal_data) return WEECHAT_RC_OK; } +/* + * debug_sigsegv: SIGSEGV handler: save crash log to + * /weechat.log and exit + */ + +void +debug_sigsegv () +{ + debug_dump (1); + unhook_all (); + gui_main_end (); + + string_iconv_fprintf (stderr, "\n"); + string_iconv_fprintf (stderr, "*** Very bad! WeeChat is crashing (SIGSEGV received)\n"); + if (!log_crash_rename ()) + string_iconv_fprintf (stderr, + "*** Full crash dump was saved to %s/weechat.log file.\n", + weechat_home); + string_iconv_fprintf (stderr, "***\n"); + string_iconv_fprintf (stderr, "*** Please help WeeChat developers to fix this bug:\n"); + string_iconv_fprintf (stderr, "*** 1. If you have a core file, please run: gdb weechat-curses core\n"); + string_iconv_fprintf (stderr, "*** then issue \"bt\" command and send result to developers\n"); + string_iconv_fprintf (stderr, "*** To enable core files with bash shell: ulimit -c 10000\n"); + string_iconv_fprintf (stderr, "*** 2. Otherwise send backtrace (below) and weechat.log\n"); + string_iconv_fprintf (stderr, "*** (be careful, private info may be in this file since\n"); + string_iconv_fprintf (stderr, "*** part of chats are displayed, so remove lines if needed)\n\n"); + + weechat_backtrace (); + + /* shutdown with error code */ + weechat_shutdown (EXIT_FAILURE, 1); +} + /* * debug_buffer_cb: callback for "debug_buffer" signal hooked */ diff --git a/src/core/wee-debug.h b/src/core/wee-debug.h index 2878ccb1d..72bdfa701 100644 --- a/src/core/wee-debug.h +++ b/src/core/wee-debug.h @@ -23,6 +23,7 @@ struct t_gui_window_tree; extern void debug_dump (int crash); +extern void debug_sigsegv (); extern void debug_init (); #endif /* wee-debug.h */ diff --git a/src/core/weechat.c b/src/core/weechat.c index bf115989b..c98a3a4a0 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -51,7 +51,6 @@ #endif #include "weechat.h" -#include "wee-backtrace.h" #include "wee-command.h" #include "wee-config.h" #include "wee-debug.h" @@ -479,39 +478,6 @@ weechat_shutdown (int return_code, int crash) exit (return_code); } -/* - * weechat_sigsegv: SIGSEGV handler: save crash log to - * /weechat.log and exit - */ - -void -weechat_sigsegv () -{ - debug_dump (1); - unhook_all (); - gui_main_end (); - - string_iconv_fprintf (stderr, "\n"); - string_iconv_fprintf (stderr, "*** Very bad! WeeChat is crashing (SIGSEGV received)\n"); - if (!log_crash_rename ()) - string_iconv_fprintf (stderr, - "*** Full crash dump was saved to %s/weechat.log file.\n", - weechat_home); - string_iconv_fprintf (stderr, "***\n"); - string_iconv_fprintf (stderr, "*** Please help WeeChat developers to fix this bug:\n"); - string_iconv_fprintf (stderr, "*** 1. If you have a core file, please run: gdb weechat-curses core\n"); - string_iconv_fprintf (stderr, "*** then issue \"bt\" command and send result to developers\n"); - string_iconv_fprintf (stderr, "*** To enable core files with bash shell: ulimit -c 10000\n"); - string_iconv_fprintf (stderr, "*** 2. Otherwise send backtrace (below) and weechat.log\n"); - string_iconv_fprintf (stderr, "*** (be careful, private info may be in this file since\n"); - string_iconv_fprintf (stderr, "*** part of chats are displayed, so remove lines if needed)\n\n"); - - weechat_backtrace (); - - /* shutdown with error code */ - weechat_shutdown (EXIT_FAILURE, 1); -} - /* * main: WeeChat startup */ @@ -537,7 +503,7 @@ main (int argc, char *argv[]) util_catch_signal (SIGQUIT, SIG_IGN); /* ignore SIGQUIT signal */ util_catch_signal (SIGPIPE, SIG_IGN); /* ignore SIGPIPE signal */ util_catch_signal (SIGSEGV, - &weechat_sigsegv); /* crash dump for SIGSEGV signal */ + &debug_sigsegv); /* crash dump for SIGSEGV signal */ hook_init (); /* initialize hooks */ debug_init (); /* hook signals for debug */ gui_main_pre_init (&argc, &argv); /* pre-initiliaze interface */