Moved sigsegv function to wee-debug.c
This commit is contained in:
parent
af12f3e99c
commit
b7513da92b
@ -26,12 +26,15 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#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_home>/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
|
||||
*/
|
||||
|
@ -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 */
|
||||
|
@ -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_home>/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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user