diff options
author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2008-07-04 19:57:57 -0300 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2008-07-04 19:57:57 -0300 |
commit | 7ebff5f725c632fe3f8ff364e961e34471f58656 (patch) | |
tree | e34e1b8a025f01c1c99eb953025a06f8925fffcf /hardinfo2 | |
parent | e102d515fb20d154aade1f680d793ebaeea1786f (diff) |
Add crash handler (based on old Sylpheed Claws code)
Diffstat (limited to 'hardinfo2')
-rw-r--r-- | hardinfo2/Makefile.in | 2 | ||||
-rwxr-xr-x | hardinfo2/configure | 1 | ||||
-rw-r--r-- | hardinfo2/crash.c | 5 | ||||
-rw-r--r-- | hardinfo2/hardinfo.c | 3 | ||||
-rw-r--r-- | hardinfo2/hardinfo.h | 1 | ||||
-rw-r--r-- | hardinfo2/util.c | 25 |
6 files changed, 34 insertions, 3 deletions
diff --git a/hardinfo2/Makefile.in b/hardinfo2/Makefile.in index d177784c..968bc90d 100644 --- a/hardinfo2/Makefile.in +++ b/hardinfo2/Makefile.in @@ -7,7 +7,7 @@ CFLAGS = -fPIC -pipe -Wall -g $(GTK_CFLAGS) $(GLADE_CFLAGS) $(SOUP_CFLAGS) -I. OBJECTS = hardinfo.o shell.o util.o iconcache.o loadgraph.o sha1.o md5.o \ menu.o stock.o callbacks.o expr.o report.o blowfish.o binreloc.o \ - vendor.o socket.o fbench.o syncmanager.o + vendor.o socket.o fbench.o syncmanager.o crash.o MODULES = computer.so devices.so benchmark.so all: $(OBJECTS) $(MODULES) diff --git a/hardinfo2/configure b/hardinfo2/configure index 0b4d0371..9c3335c4 100755 --- a/hardinfo2/configure +++ b/hardinfo2/configure @@ -229,6 +229,7 @@ fi echo "#define ENABLE_BINRELOC 1" >> config.h echo "#define RELEASE $RELEASE" >> config.h +echo "#define CRASH_DIALOG 1" >> config.h echo -e "\n#endif /* __CONFIG_H__ */" >> config.h diff --git a/hardinfo2/crash.c b/hardinfo2/crash.c index 7f749947..1c0b7a39 100644 --- a/hardinfo2/crash.c +++ b/hardinfo2/crash.c @@ -125,9 +125,10 @@ crash_main(const char *arg) pid, g_strsignal(atol(tokens[1]))); output = g_string_new(""); - crash_debug(pid, tokens[2], output); + crash_debug(pid, tokens[2], output); crash_dialog_show(text, output->str); + g_string_free(output, TRUE); g_free(text); g_strfreev(tokens); @@ -255,7 +256,7 @@ crash_create_debugger_file(void) } /* - * ! \brief launches debugger and attaches it to crashed publicit + * ! \brief launches debugger and attaches it to crashed hardinfo */ static void crash_debug(unsigned long crash_pid, diff --git a/hardinfo2/hardinfo.c b/hardinfo2/hardinfo.c index 4f87eb90..fd65603c 100644 --- a/hardinfo2/hardinfo.c +++ b/hardinfo2/hardinfo.c @@ -25,6 +25,7 @@ #include <stock.h> #include <binreloc.h> +#include <crash.h> ProgramParameters params = { 0 }; @@ -116,10 +117,12 @@ int main(int argc, char **argv) /* initialize gui and start gtk+ main loop */ icon_cache_init(); stock_icons_init(); + crash_install_handlers(); shell_init(modules); DEBUG("entering gtk+ main loop"); + gtk_main(); } else if (params.create_report) { /* generate report */ diff --git a/hardinfo2/hardinfo.h b/hardinfo2/hardinfo.h index 43514be2..534a3123 100644 --- a/hardinfo2/hardinfo.h +++ b/hardinfo2/hardinfo.h @@ -39,6 +39,7 @@ struct _ProgramParameters { gchar **use_modules; gchar *path_lib; gchar *path_data; + gchar *argv0; }; struct _FileTypes { diff --git a/hardinfo2/util.c b/hardinfo2/util.c index d742233a..7d27b966 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -41,6 +41,8 @@ #include <sys/stat.h> #include <sys/types.h> +#include <crash.h> + #define KiB 1024 #define MiB 1048576 #define GiB 1073741824 @@ -324,8 +326,19 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param) static gboolean autoload_deps = FALSE; static gchar *report_format = NULL; static gchar **use_modules = NULL; +#ifdef CRASH_DIALOG + static gchar *crash_args = NULL; +#endif static GOptionEntry options[] = { +#ifdef CRASH_DIALOG + { + .long_name = "crash", + .short_name = 'c', + .arg = G_OPTION_ARG_STRING, + .arg_data = &crash_args, + .description = "invokes HardInfo crash handler; do not use directly"}, +#endif { .long_name = "generate-report", .short_name = 'r', @@ -387,6 +400,18 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param) param->list_modules = list_modules; param->use_modules = use_modules; param->autoload_deps = autoload_deps; + param->argv0 = *(argv)[0]; + +#ifdef CRASH_DIALOG + if (crash_args) { + DEBUG("invoking crash handler: %s", crash_args); + + gtk_init(argc, argv); + crash_main(crash_args); + + exit(0); + } +#endif if (report_format && g_str_equal(report_format, "html")) param->report_format = REPORT_FORMAT_HTML; |