Enlightenment CVS committal Author : raster Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: Makefile.am e_includes.h e_main.c e_signals.c e_signals.h Added Files: e_alert.c e_alert.h Log Message: segv/bus/ill/fpe handler to trap all the nasties and allow debug or recovery =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/Makefile.am,v retrieving revision 1.33 retrieving revision 1.34 diff -u -3 -r1.33 -r1.34 --- Makefile.am 7 Jun 2005 13:05:18 -0000 1.33 +++ Makefile.am 15 Jun 2005 05:06:29 -0000 1.34 @@ -4,6 +4,7 @@ -I$(top_srcdir)/src/bin \ -I$(top_srcdir)/src/lib \ @e_cflags@ \ + @x_cflags@ \ @EDJE_DEF@ bin_PROGRAMS = enlightenment enlightenment_remote enlightenment_eapp @@ -58,7 +59,8 @@ e_prefix.h \ e_datastore.h \ e_msg.h \ -e_winlist.h +e_winlist.h \ +e_alert.h enlightenment_SOURCES = \ e_main.c \ @@ -108,9 +110,10 @@ e_datastore.c \ e_msg.c \ e_winlist.c \ +e_alert.c \ $(ENLIGHTENMENTHEADERS) -enlightenment_LDFLAGS = -export-dynamic @e_libs@ @dlopen_libs@ +enlightenment_LDFLAGS = -export-dynamic @e_libs@ @x_libs@ @dlopen_libs@ enlightenment_remote_SOURCES = \ e.h \ =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_includes.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -3 -r1.22 -r1.23 --- e_includes.h 7 Jun 2005 13:05:18 -0000 1.22 +++ e_includes.h 15 Jun 2005 05:06:45 -0000 1.23 @@ -47,3 +47,4 @@ #include "e_datastore.h" #include "e_msg.h" #include "e_winlist.h" +#include "e_alert.h" =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_main.c,v retrieving revision 1.97 retrieving revision 1.98 diff -u -3 -r1.97 -r1.98 --- e_main.c 13 Jun 2005 04:18:29 -0000 1.97 +++ e_main.c 15 Jun 2005 05:06:45 -0000 1.98 @@ -61,15 +61,30 @@ int after_restart = 0; char buf[1024]; char *s; -#if 0 - /* install the signal handlers. */ - struct sigaction sigsegv_action; - - sigsegv_action.sa_sigaction = &e_sigseg_act; - sigsegv_action.sa_flags = 0; - sigemptyset(&sigsegv_action.sa_mask); - sigaction(SIGSEGV, &sigsegv_action, NULL); -#endif + struct sigaction action; + + /* trap deadly bug signals and allow some form of sane recovery */ + /* or ability to gdb attach and debug at this point - better than your */ + /* wm/desktop vanishing and not knowing what happened */ + action.sa_sigaction = e_sigseg_act; + action.sa_flags = SA_ONSTACK | SA_NODEFER | SA_RESETHAND | SA_ONESHOT | SA_NOMASK | SA_SIGINFO; + sigemptyset(&action.sa_mask); + sigaction(SIGSEGV, &action, NULL); + + action.sa_sigaction = e_sigill_act; + action.sa_flags = SA_ONSTACK | SA_NODEFER | SA_RESETHAND | SA_ONESHOT | SA_NOMASK | SA_SIGINFO; + sigemptyset(&action.sa_mask); + sigaction(SIGILL, &action, NULL); + + action.sa_sigaction = e_sigfpe_act; + action.sa_flags = SA_ONSTACK | SA_NODEFER | SA_RESETHAND | SA_ONESHOT | SA_NOMASK | SA_SIGINFO; + sigemptyset(&action.sa_mask); + sigaction(SIGFPE, &action, NULL); + + action.sa_sigaction = e_sigbus_act; + action.sa_flags = SA_ONSTACK | SA_NODEFER | SA_RESETHAND | SA_ONESHOT | SA_NOMASK | SA_SIGINFO; + sigemptyset(&action.sa_mask); + sigaction(SIGBUS, &action, NULL); /* FIXME: this is the init code for letting e be relocatable. right now * its not used - so i want to see if it can reliably determine its exe @@ -219,6 +234,14 @@ _e_main_shutdown(-1); } _e_main_shutdown_push(_e_main_x_shutdown); + /* init x */ + if (!e_alert_init(NULL)) + { + e_error_message_show(_("Enlightenment cannot initialize its emergency alert system.\n" + "Have you set your DISPLAY variable?")); + _e_main_shutdown(-1); + } + _e_main_shutdown_push(e_alert_shutdown); if (!e_xinerama_init()) { e_error_message_show(_("Enlightenment cannot setup xinerama wrapping.\n" @@ -458,7 +481,7 @@ /* run any testing code now we are set up */ e_test(); - + /* no longer starting up */ starting = 0; /* start our main loop */ =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_signals.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- e_signals.c 11 Apr 2005 20:25:52 -0000 1.6 +++ e_signals.c 15 Jun 2005 05:06:45 -0000 1.7 @@ -22,15 +22,105 @@ write(2, "**** Printing Backtrace... *****\n\n", 34); size = backtrace(array, 255); backtrace_symbols_fd(array, size, 2); + e_alert_show("This is very bad. Enlightenment has segfaulted.\n" + "This is not meant to happen and is likely a sign of a\n" + "bug in Enlightenment or the libraries it relies on.\n" + "\n" + "You can gdb attach to this process now to try debug it\n" + "or you could exit, or just hit restart to try and get\n" + "your desktop back the way it was. This may not always\n" + "work perfectly, but it is the bext we can do for now.\n" + "\n" + "Please help us debug this by compiling Enlightenment and\n" + "all its dependency libraries with gdb debugging enabled\n" + "and gdb attach to E when this happens and try figure out\n" + "what's going on and set us gdb backtraces, variable dumps\n" + "etc."); exit(-11); } #else -void e_sigseg_act(int x, siginfo_t *info, void *data) +void +e_sigseg_act(int x, siginfo_t *info, void *data) { write(2, "**** SEGMENTATION FAULT ****\n", 29); - write(2, "**** Backtrace disabled... *****\n\n", 34); + e_alert_show("This is very bad. Enlightenment has segfaulted.\n" + "This is not meant to happen and is likely a sign of a\n" + "bug in Enlightenment or the libraries it relies on.\n" + "\n" + "You can gdb attach to this process now to try debug it\n" + "or you could exit, or just hit restart to try and get\n" + "your desktop back the way it was. This may not always\n" + "work perfectly, but it is the bext we can do for now.\n" + "\n" + "Please help us debug this by compiling Enlightenment and\n" + "all its dependency libraries with gdb debugging enabled\n" + "and gdb attach to E when this happens and try figure out\n" + "what's going on and set us gdb backtraces, variable dumps\n" + "etc."); exit(-11); } #endif - +void +e_sigill_act(int x, siginfo_t *info, void *data) +{ + write(2, "**** ILLEGAL INSTRUCTION ****\n", 30); + e_alert_show("This is very bad. Enlightenment has executed and illegal\n" + "instruction. This is most likely because Enlightenment or\n" + "a library it depends on has been compiled for a CPU type\n" + "that you don't have.\n" + "\n" + "You can gdb attach to this process now to try debug it\n" + "or you could exit, or just hit restart to try and get\n" + "your desktop back the way it was. This may not always\n" + "work perfectly, but it is the bext we can do for now.\n" + "\n" + "Please help us debug this by compiling Enlightenment and\n" + "all its dependency libraries with gdb debugging enabled\n" + "and gdb attach to E when this happens and try figure out\n" + "what's going on and set us gdb backtraces, variable dumps\n" + "etc."); + exit(-11); +} + +void +e_sigfpe_act(int x, siginfo_t *info, void *data) +{ + write(2, "**** FLOATING POINT EXCEPTION ****\n", 35); + e_alert_show("This is very bad. Enlightenment has recieved a floating\n" + "point exception. This is probably due to a divide by 0\n" + "in Enlightenment or a library it depends on.\n" + "\n" + "You can gdb attach to this process now to try debug it\n" + "or you could exit, or just hit restart to try and get\n" + "your desktop back the way it was. This may not always\n" + "work perfectly, but it is the bext we can do for now.\n" + "\n" + "Please help us debug this by compiling Enlightenment and\n" + "all its dependency libraries with gdb debugging enabled\n" + "and gdb attach to E when this happens and try figure out\n" + "what's going on and set us gdb backtraces, variable dumps\n" + "etc."); + exit(-11); +} + +void +e_sigbus_act(int x, siginfo_t *info, void *data) +{ + write(2, "**** BUS ERROR ****\n", 21); + e_alert_show("This is very bad. Enlightenment has recieved a bus error.\n" + "This could be for many reasons - accessing memory not in\n" + "its available address space or unable to be paged in.\n" + "\n" + "You can gdb attach to this process now to try debug it\n" + "or you could exit, or just hit restart to try and get\n" + "your desktop back the way it was. This may not always\n" + "work perfectly, but it is the bext we can do for now.\n" + "\n" + "Please help us debug this by compiling Enlightenment and\n" + "all its dependency libraries with gdb debugging enabled\n" + "and gdb attach to E when this happens and try figure out\n" + "what's going on and set us gdb backtraces, variable dumps\n" + "etc."); + exit(-11); +} =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_signals.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- e_signals.h 7 Feb 2005 13:51:09 -0000 1.2 +++ e_signals.h 15 Jun 2005 05:06:45 -0000 1.3 @@ -1,9 +1,16 @@ /* * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ +#ifdef E_TYPEDEFS + +#else #ifndef E_SIGNALS_H #define E_SIGNALS_H -/* signal handler functions for e */ -void e_sigseg_act(int x, siginfo_t *info, void *data); +EAPI void e_sigseg_act(int x, siginfo_t *info, void *data); +EAPI void e_sigill_act(int x, siginfo_t *info, void *data); +EAPI void e_sigfpe_act(int x, siginfo_t *info, void *data); +EAPI void e_sigbus_act(int x, siginfo_t *info, void *data); + +#endif #endif ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs