2010-08-04 12:00:15 -07:00
|
|
|
/*
|
|
|
|
* NOTE TO FreeBSD users. Install libexecinfo from
|
2005-03-18 09:02:47 -08:00
|
|
|
* ports/devel/libexecinfo and add -lexecinfo to LDFLAGS
|
|
|
|
* to add backtrace support.
|
2005-01-27 02:14:22 -08:00
|
|
|
*/
|
|
|
|
#include "e.h"
|
2009-03-26 19:23:13 -07:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
|
2009-11-11 13:04:21 -08:00
|
|
|
#ifdef HAVE_EXECINFO_H
|
|
|
|
# include <execinfo.h>
|
|
|
|
#endif
|
|
|
|
|
2009-03-26 19:23:13 -07:00
|
|
|
static volatile Eina_Bool _e_x_composite_shutdown_try = 0;
|
2010-08-18 11:32:48 -07:00
|
|
|
|
2009-03-26 19:23:13 -07:00
|
|
|
static void
|
|
|
|
_e_x_composite_shutdown(void)
|
|
|
|
{
|
|
|
|
Ecore_X_Display *dpy;
|
|
|
|
Ecore_X_Window root;
|
|
|
|
|
|
|
|
if (_e_x_composite_shutdown_try) return; /* we failed :-( */
|
|
|
|
_e_x_composite_shutdown_try = 1;
|
|
|
|
|
|
|
|
dpy = ecore_x_display_get();
|
|
|
|
root = DefaultRootWindow(dpy);
|
|
|
|
|
|
|
|
/* ignore errors, we really don't care at this point */
|
|
|
|
ecore_x_composite_unredirect_subwindows(root, ECORE_X_COMPOSITE_UPDATE_MANUAL);
|
|
|
|
_e_x_composite_shutdown_try = 0;
|
|
|
|
}
|
2005-03-30 19:21:58 -08:00
|
|
|
|
2009-07-11 09:27:37 -07:00
|
|
|
#define _e_write_safe(fd, buf) _e_write_safe_int(fd, buf, sizeof(buf))
|
2010-08-18 11:32:48 -07:00
|
|
|
|
2009-07-11 09:27:37 -07:00
|
|
|
static void
|
|
|
|
_e_write_safe_int(int fd, const char *buf, size_t size)
|
|
|
|
{
|
|
|
|
while (size > 0)
|
|
|
|
{
|
|
|
|
ssize_t done = write(fd, buf, size);
|
|
|
|
if (done >= 0)
|
|
|
|
{
|
|
|
|
buf += done;
|
|
|
|
size -= done;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((errno == EAGAIN) || (errno == EINTR))
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
perror("write");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gdb_print_backtrace(int fd)
|
|
|
|
{
|
|
|
|
char cmd[1024];
|
|
|
|
size_t size;
|
2010-08-18 11:32:48 -07:00
|
|
|
int ret;
|
2009-07-11 09:27:37 -07:00
|
|
|
|
2009-10-22 17:56:41 -07:00
|
|
|
// FIXME: we are in a segv'd state. do as few function calls and things
|
|
|
|
// depending on a known working state as possible. this also prevents the
|
|
|
|
// white box allowing recovery or deeper gdbing, thus until this works
|
|
|
|
// properly, it's disabled (properly means always reliable, always
|
|
|
|
// printf bt and allows e to continue and pop up box, perferably allowing
|
|
|
|
// debugging in the gui etc. etc.
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (getenv("E_NO_GDB_BACKTRACE"))
|
2009-08-29 17:19:10 -07:00
|
|
|
return;
|
|
|
|
|
2009-07-11 09:27:37 -07:00
|
|
|
size = snprintf(cmd, sizeof(cmd),
|
|
|
|
"gdb --pid=%d "
|
|
|
|
"-ex 'thread apply all bt' "
|
|
|
|
"-ex detach -ex quit", getpid());
|
|
|
|
|
|
|
|
if (size >= sizeof(cmd))
|
|
|
|
return;
|
|
|
|
|
|
|
|
_e_write_safe(fd, "EXECUTING GDB AS: ");
|
|
|
|
_e_write_safe_int(fd, cmd, size);
|
|
|
|
_e_write_safe(fd, "\n");
|
2010-08-18 11:32:48 -07:00
|
|
|
ret = system(cmd); // TODO: use popen() or fork()+pipe()+exec() and save to 'fd'
|
2009-07-11 09:27:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#define _e_backtrace(msg) _e_backtrace_int(2, msg, sizeof(msg))
|
|
|
|
static void
|
2010-08-18 11:32:48 -07:00
|
|
|
_e_backtrace_int(int fd __UNUSED__, const char *msg __UNUSED__, size_t msg_len __UNUSED__)
|
2009-07-11 09:27:37 -07:00
|
|
|
{
|
2010-08-18 11:32:48 -07:00
|
|
|
/*
|
2009-07-11 09:27:37 -07:00
|
|
|
char attachmsg[1024];
|
|
|
|
void *array[255];
|
|
|
|
size_t size;
|
2010-08-18 11:32:48 -07:00
|
|
|
*/
|
2009-07-11 09:27:37 -07:00
|
|
|
|
2009-11-01 17:18:26 -08:00
|
|
|
return; // disable. causes hangs and problems
|
2010-04-12 02:05:37 -07:00
|
|
|
/*
|
2009-07-11 09:27:37 -07:00
|
|
|
_e_write_safe_int(fd, msg, msg_len);
|
|
|
|
_e_write_safe(fd, "\nBEGIN TRACEBACK\n");
|
|
|
|
size = backtrace(array, 255);
|
|
|
|
backtrace_symbols_fd(array, size, fd);
|
|
|
|
_e_write_safe(fd, "END TRACEBACK\n");
|
|
|
|
|
|
|
|
size = snprintf(attachmsg, sizeof(attachmsg),
|
|
|
|
"debug with: gdb --pid=%d\n", getpid());
|
|
|
|
if (size < sizeof(attachmsg))
|
|
|
|
_e_write_safe_int(fd, attachmsg, size);
|
|
|
|
|
|
|
|
_e_gdb_print_backtrace(fd);
|
2010-04-12 02:05:37 -07:00
|
|
|
*/
|
2009-07-11 09:27:37 -07:00
|
|
|
}
|
|
|
|
|
2005-01-27 02:14:22 -08:00
|
|
|
/* a tricky little devil, requires e and it's libs to be built
|
|
|
|
* with the -rdynamic flag to GCC for any sort of decent output.
|
|
|
|
*/
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2010-08-18 11:32:48 -07:00
|
|
|
e_sigseg_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__)
|
2005-04-11 13:25:52 -07:00
|
|
|
{
|
2009-07-11 09:27:37 -07:00
|
|
|
_e_backtrace("**** SEGMENTATION FAULT ****");
|
2009-03-26 19:23:13 -07:00
|
|
|
_e_x_composite_shutdown();
|
2005-06-15 23:29:32 -07:00
|
|
|
ecore_x_pointer_ungrab();
|
|
|
|
ecore_x_keyboard_ungrab();
|
|
|
|
ecore_x_ungrab();
|
|
|
|
ecore_x_sync();
|
2007-09-11 04:57:48 -07:00
|
|
|
e_alert_show("This is very bad. Enlightenment SEGV'd.\n"
|
2005-06-14 22:06:45 -07:00
|
|
|
"\n"
|
2007-09-11 04:57:48 -07:00
|
|
|
"This is not meant to happen and is likely a sign of\n"
|
|
|
|
"a bug in Enlightenment or the libraries it relies\n"
|
|
|
|
"on. You can gdb attach to this process now to try\n"
|
|
|
|
"debug it or you could exit, or just hit restart to\n"
|
|
|
|
"try and get your desktop back the way it was.\n"
|
2005-06-14 22:06:45 -07:00
|
|
|
"\n"
|
2007-09-11 04:57:48 -07:00
|
|
|
"Please compile everything with -g in your CFLAGS\n");
|
2005-04-11 13:25:52 -07:00
|
|
|
exit(-11);
|
2005-01-27 02:14:22 -08:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2010-08-18 11:32:48 -07:00
|
|
|
e_sigill_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__)
|
2005-06-14 22:06:45 -07:00
|
|
|
{
|
2009-07-11 09:27:37 -07:00
|
|
|
_e_backtrace("**** ILLEGAL INSTRUCTION ****");
|
2009-03-26 19:23:13 -07:00
|
|
|
_e_x_composite_shutdown();
|
2005-06-15 23:29:32 -07:00
|
|
|
ecore_x_pointer_ungrab();
|
|
|
|
ecore_x_keyboard_ungrab();
|
|
|
|
ecore_x_ungrab();
|
|
|
|
ecore_x_sync();
|
2007-09-11 04:57:48 -07:00
|
|
|
e_alert_show("This is very bad. Enlightenment SIGILL'd.\n"
|
2005-06-14 22:06:45 -07:00
|
|
|
"\n"
|
2007-09-11 04:57:48 -07:00
|
|
|
"This is not meant to happen and is likely a sign of\n"
|
|
|
|
"a bug in Enlightenment or the libraries it relies\n"
|
|
|
|
"on. You can gdb attach to this process now to try\n"
|
|
|
|
"debug it or you could exit, or just hit restart to\n"
|
|
|
|
"try and get your desktop back the way it was.\n"
|
2005-06-14 22:06:45 -07:00
|
|
|
"\n"
|
2007-09-11 04:57:48 -07:00
|
|
|
"Please compile everything with -g in your CFLAGS\n");
|
2005-06-14 22:06:45 -07:00
|
|
|
exit(-11);
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2010-08-18 11:32:48 -07:00
|
|
|
e_sigfpe_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__)
|
2005-06-14 22:06:45 -07:00
|
|
|
{
|
2009-07-11 09:27:37 -07:00
|
|
|
_e_backtrace("**** FLOATING POINT EXCEPTION ****");
|
2009-03-26 19:23:13 -07:00
|
|
|
_e_x_composite_shutdown();
|
2005-06-15 23:29:32 -07:00
|
|
|
ecore_x_pointer_ungrab();
|
|
|
|
ecore_x_keyboard_ungrab();
|
|
|
|
ecore_x_ungrab();
|
|
|
|
ecore_x_sync();
|
2007-09-11 04:57:48 -07:00
|
|
|
e_alert_show("This is very bad. Enlightenment SIGFPE'd.\n"
|
2005-06-14 22:06:45 -07:00
|
|
|
"\n"
|
2007-09-11 04:57:48 -07:00
|
|
|
"This is not meant to happen and is likely a sign of\n"
|
|
|
|
"a bug in Enlightenment or the libraries it relies\n"
|
|
|
|
"on. You can gdb attach to this process now to try\n"
|
|
|
|
"debug it or you could exit, or just hit restart to\n"
|
|
|
|
"try and get your desktop back the way it was.\n"
|
2005-06-14 22:06:45 -07:00
|
|
|
"\n"
|
2007-09-11 04:57:48 -07:00
|
|
|
"Please compile everything with -g in your CFLAGS\n");
|
2005-06-14 22:06:45 -07:00
|
|
|
exit(-11);
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2010-08-18 11:32:48 -07:00
|
|
|
e_sigbus_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__)
|
2005-06-14 22:06:45 -07:00
|
|
|
{
|
2009-07-11 09:27:37 -07:00
|
|
|
_e_backtrace("**** BUS ERROR ****");
|
2009-03-26 19:23:13 -07:00
|
|
|
_e_x_composite_shutdown();
|
2005-06-15 23:29:32 -07:00
|
|
|
ecore_x_pointer_ungrab();
|
|
|
|
ecore_x_keyboard_ungrab();
|
|
|
|
ecore_x_ungrab();
|
|
|
|
ecore_x_sync();
|
2007-09-11 04:57:48 -07:00
|
|
|
e_alert_show("This is very bad. Enlightenment SIGILL'd.\n"
|
2005-06-14 22:06:45 -07:00
|
|
|
"\n"
|
2007-09-11 04:57:48 -07:00
|
|
|
"This is not meant to happen and is likely a sign of\n"
|
|
|
|
"a bug in Enlightenment or the libraries it relies\n"
|
|
|
|
"on. You can gdb attach to this process now to try\n"
|
|
|
|
"debug it or you could exit, or just hit restart to\n"
|
|
|
|
"try and get your desktop back the way it was.\n"
|
2005-06-14 22:06:45 -07:00
|
|
|
"\n"
|
2007-09-11 04:57:48 -07:00
|
|
|
"Please compile everything with -g in your CFLAGS\n");
|
2005-06-14 22:06:45 -07:00
|
|
|
exit(-11);
|
|
|
|
}
|
2006-04-01 20:18:18 -08:00
|
|
|
|
|
|
|
EAPI void
|
2010-08-18 11:32:48 -07:00
|
|
|
e_sigabrt_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__)
|
2006-04-01 20:18:18 -08:00
|
|
|
{
|
2009-07-11 09:27:37 -07:00
|
|
|
_e_backtrace("**** ABORT ****");
|
2009-03-26 19:23:13 -07:00
|
|
|
_e_x_composite_shutdown();
|
2006-04-01 20:18:18 -08:00
|
|
|
ecore_x_pointer_ungrab();
|
|
|
|
ecore_x_keyboard_ungrab();
|
|
|
|
ecore_x_ungrab();
|
|
|
|
ecore_x_sync();
|
2007-09-11 04:57:48 -07:00
|
|
|
e_alert_show("This is very bad. Enlightenment SIGABRT'd.\n"
|
2006-04-01 20:18:18 -08:00
|
|
|
"\n"
|
2007-09-11 04:57:48 -07:00
|
|
|
"This is not meant to happen and is likely a sign of\n"
|
|
|
|
"a bug in Enlightenment or the libraries it relies\n"
|
|
|
|
"on. You can gdb attach to this process now to try\n"
|
|
|
|
"debug it or you could exit, or just hit restart to\n"
|
|
|
|
"try and get your desktop back the way it was.\n"
|
2006-04-01 20:18:18 -08:00
|
|
|
"\n"
|
2007-09-11 04:57:48 -07:00
|
|
|
"Please compile everything with -g in your CFLAGS\n");
|
2006-04-01 20:18:18 -08:00
|
|
|
exit(-11);
|
|
|
|
}
|