summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/crashhandler.c
diff options
context:
space:
mode:
authorkristian <kristian@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-12-02 16:26:33 +0000
committerkristian <kristian@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-12-02 16:26:33 +0000
commitc31c5e2d5c6b525350c2f807095f8b2819a59bd5 (patch)
treead9bf35f3a435cdb444fff636424005fb608b4ce /beryl-plugins/src/crashhandler.c
parentd85d0131318217e03b20d15639fced7af7957eb5 (diff)
downloadmarex-dev-c31c5e2d5c6b525350c2f807095f8b2819a59bd5.tar.gz
marex-dev-c31c5e2d5c6b525350c2f807095f8b2819a59bd5.tar.bz2
indent -i8 -kr . All whitespace-changes.
See man indent for details of what -kr does. git-svn-id: file:///beryl/trunk@1499 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/crashhandler.c')
-rw-r--r--beryl-plugins/src/crashhandler.c399
1 files changed, 191 insertions, 208 deletions
diff --git a/beryl-plugins/src/crashhandler.c b/beryl-plugins/src/crashhandler.c
index 45c6fc2..1c8234e 100644
--- a/beryl-plugins/src/crashhandler.c
+++ b/beryl-plugins/src/crashhandler.c
@@ -48,251 +48,234 @@
static int displayPrivateIndex = 0;
static CompDisplay *cDisplay;
-typedef struct _CrashhandlerDisplay
-{
- int screenPrivateIndex;
- CompOption opt[CRASHHANDLER_DISPLAY_OPTION_NUM];
+typedef struct _CrashhandlerDisplay {
+ int screenPrivateIndex;
+ CompOption opt[CRASHHANDLER_DISPLAY_OPTION_NUM];
} CrashhandlerDisplay;
-static void
-crash_handler (int sig)
+static void crash_handler(int sig)
{
- if (sig == SIGSEGV || sig == SIGFPE || sig == SIGILL || sig == SIGABRT)
- {
- CRASHHANDLER_DISPLAY (cDisplay);
- static int count = 0;
- if (++count > 1)
- exit (1);
- // backtrace
- char cmd[1024];
- sprintf (cmd,
- "echo -e \"set prompt\nthread apply all bt full\necho \\\\\\n\necho \\\\\\n\nbt\nquit\" > /tmp/gdb.tmp; gdb -q %s %i < /tmp/gdb.tmp | grep -v \"No symbol table\" | tee /tmp/beryl_crash-%i.out; rm -f /tmp/gdb.tmp; echo \"\n[CRASH_HANDLER]: \\\"/tmp/beryl_crash-%i.out\\\" created!\n\"",
- getProgramName(), getpid (), getpid (), getpid ());
- system (cmd);
-
- if (cd->opt[CRASHHANDLER_DISPLAY_OPTION_START_WM].value.b)
- {
- if (fork () == 0)
- {
- setsid ();
- putenv (cDisplay->displayString);
- execl ("/bin/sh", "/bin/sh", "-c",
- cd->opt[CRASHHANDLER_DISPLAY_OPTION_WM].value.s, NULL);
- exit (0);
- }
- }
-
- exit (1);
- }
+ if (sig == SIGSEGV || sig == SIGFPE || sig == SIGILL
+ || sig == SIGABRT) {
+ CRASHHANDLER_DISPLAY(cDisplay);
+ static int count = 0;
+ if (++count > 1)
+ exit(1);
+ // backtrace
+ char cmd[1024];
+ sprintf(cmd,
+ "echo -e \"set prompt\nthread apply all bt full\necho \\\\\\n\necho \\\\\\n\nbt\nquit\" > /tmp/gdb.tmp; gdb -q %s %i < /tmp/gdb.tmp | grep -v \"No symbol table\" | tee /tmp/beryl_crash-%i.out; rm -f /tmp/gdb.tmp; echo \"\n[CRASH_HANDLER]: \\\"/tmp/beryl_crash-%i.out\\\" created!\n\"",
+ getProgramName(), getpid(), getpid(), getpid());
+ system(cmd);
+
+ if (cd->opt[CRASHHANDLER_DISPLAY_OPTION_START_WM].value.b) {
+ if (fork() == 0) {
+ setsid();
+ putenv(cDisplay->displayString);
+ execl("/bin/sh", "/bin/sh", "-c",
+ cd->
+ opt[CRASHHANDLER_DISPLAY_OPTION_WM].
+ value.s, NULL);
+ exit(0);
+ }
+ }
+
+ exit(1);
+ }
}
static Bool
-crashhandlerSetDisplayOption (CompDisplay * display, char *name,
- CompOptionValue * value)
+crashhandlerSetDisplayOption(CompDisplay * display, char *name,
+ CompOptionValue * value)
{
- CompOption *o;
- int index;
-
- CRASHHANDLER_DISPLAY (display);
-
- o = compFindOption (cd->opt, NUM_OPTIONS (cd), name, &index);
- if (!o)
- return FALSE;
-
- switch (index)
- {
- case CRASHHANDLER_DISPLAY_OPTION_ENABLED:
- if (compSetBoolOption (o, value))
- {
- if (value->b)
- {
- // enable crash handler
- signal (SIGSEGV, crash_handler);
- signal (SIGFPE, crash_handler);
- signal (SIGILL, crash_handler);
- signal (SIGABRT, crash_handler);
- }
- else
- {
- // disable crash handler
- signal (SIGSEGV, SIG_DFL);
- signal (SIGFPE, SIG_DFL);
- signal (SIGILL, SIG_DFL);
- signal (SIGABRT, SIG_DFL);
- }
- return TRUE;
- }
- break;
- case CRASHHANDLER_DISPLAY_OPTION_START_WM:
- if (compSetBoolOption (o, value))
- return TRUE;
- break;
- case CRASHHANDLER_DISPLAY_OPTION_WM:
- if (compSetStringOption (o, value))
- return TRUE;
- break;
- default:
- break;
- }
-
- return FALSE;
+ CompOption *o;
+ int index;
+
+ CRASHHANDLER_DISPLAY(display);
+
+ o = compFindOption(cd->opt, NUM_OPTIONS(cd), name, &index);
+ if (!o)
+ return FALSE;
+
+ switch (index) {
+ case CRASHHANDLER_DISPLAY_OPTION_ENABLED:
+ if (compSetBoolOption(o, value)) {
+ if (value->b) {
+ // enable crash handler
+ signal(SIGSEGV, crash_handler);
+ signal(SIGFPE, crash_handler);
+ signal(SIGILL, crash_handler);
+ signal(SIGABRT, crash_handler);
+ } else {
+ // disable crash handler
+ signal(SIGSEGV, SIG_DFL);
+ signal(SIGFPE, SIG_DFL);
+ signal(SIGILL, SIG_DFL);
+ signal(SIGABRT, SIG_DFL);
+ }
+ return TRUE;
+ }
+ break;
+ case CRASHHANDLER_DISPLAY_OPTION_START_WM:
+ if (compSetBoolOption(o, value))
+ return TRUE;
+ break;
+ case CRASHHANDLER_DISPLAY_OPTION_WM:
+ if (compSetStringOption(o, value))
+ return TRUE;
+ break;
+ default:
+ break;
+ }
+
+ return FALSE;
}
-static void
-crashhandlerDisplayInitOptions (CrashhandlerDisplay * cd)
+static void crashhandlerDisplayInitOptions(CrashhandlerDisplay * cd)
{
- CompOption *o;
-
- o = &cd->opt[CRASHHANDLER_DISPLAY_OPTION_ENABLED];
- o->name = "enabled";
- o->group=N_("");
-o->subGroup=N_("");
-o->displayHints="";
-o->shortDesc = N_("Enabled");
- o->longDesc = N_("Activate crash handler");
- o->type = CompOptionTypeBool;
- o->value.b = CRASHHANDLER_DISPLAY_OPTION_ENABLED_DEFAULT;
-
- o = &cd->opt[CRASHHANDLER_DISPLAY_OPTION_START_WM];
- o->name = "start_window_manager";
- o->group=N_("");
-o->subGroup=N_("");
-o->displayHints="";
-o->shortDesc = N_("Start Window Manager");
- o->longDesc = N_("Start other window manager on crash");
- o->type = CompOptionTypeBool;
- o->value.b = CRASHHANDLER_DISPLAY_OPTION_START_WM_DEFAULT;
-
- o = &cd->opt[CRASHHANDLER_DISPLAY_OPTION_WM];
- o->name = "window_manager_command_line";
- o->group=N_("");
-o->subGroup=N_("");
-o->displayHints="command;";
-o->shortDesc = N_("Window manager command line");
- o->longDesc = N_("Window manager command line. DO NOT ENTER BERYL HERE!!!");
- o->type = CompOptionTypeString;
- o->value.s = strdup (CRASHHANDLER_DISPLAY_OPTION_WM_DEFAULT);
- o->rest.s.string = 0;
- o->rest.s.nString = 0;
+ CompOption *o;
+
+ o = &cd->opt[CRASHHANDLER_DISPLAY_OPTION_ENABLED];
+ o->name = "enabled";
+ o->group = N_("");
+ o->subGroup = N_("");
+ o->displayHints = "";
+ o->shortDesc = N_("Enabled");
+ o->longDesc = N_("Activate crash handler");
+ o->type = CompOptionTypeBool;
+ o->value.b = CRASHHANDLER_DISPLAY_OPTION_ENABLED_DEFAULT;
+
+ o = &cd->opt[CRASHHANDLER_DISPLAY_OPTION_START_WM];
+ o->name = "start_window_manager";
+ o->group = N_("");
+ o->subGroup = N_("");
+ o->displayHints = "";
+ o->shortDesc = N_("Start Window Manager");
+ o->longDesc = N_("Start other window manager on crash");
+ o->type = CompOptionTypeBool;
+ o->value.b = CRASHHANDLER_DISPLAY_OPTION_START_WM_DEFAULT;
+
+ o = &cd->opt[CRASHHANDLER_DISPLAY_OPTION_WM];
+ o->name = "window_manager_command_line";
+ o->group = N_("");
+ o->subGroup = N_("");
+ o->displayHints = "command;";
+ o->shortDesc = N_("Window manager command line");
+ o->longDesc =
+ N_("Window manager command line. DO NOT ENTER BERYL HERE!!!");
+ o->type = CompOptionTypeString;
+ o->value.s = strdup(CRASHHANDLER_DISPLAY_OPTION_WM_DEFAULT);
+ o->rest.s.string = 0;
+ o->rest.s.nString = 0;
}
-static CompOption *
-crashhandlerGetDisplayOptions (CompDisplay * display, int *count)
+static CompOption *crashhandlerGetDisplayOptions(CompDisplay * display,
+ int *count)
{
- if (display)
- {
- CRASHHANDLER_DISPLAY (display);
-
- *count = NUM_OPTIONS (cd);
- return cd->opt;
- }
- else
- {
- CrashhandlerDisplay * cd = malloc(sizeof(CrashhandlerDisplay));
- crashhandlerDisplayInitOptions(cd);
- *count = NUM_OPTIONS(cd);
- return cd->opt;
- }
+ if (display) {
+ CRASHHANDLER_DISPLAY(display);
+
+ *count = NUM_OPTIONS(cd);
+ return cd->opt;
+ } else {
+ CrashhandlerDisplay *cd =
+ malloc(sizeof(CrashhandlerDisplay));
+ crashhandlerDisplayInitOptions(cd);
+ *count = NUM_OPTIONS(cd);
+ return cd->opt;
+ }
}
-static Bool
-crashhandlerInitDisplay (CompPlugin * p, CompDisplay * d)
+static Bool crashhandlerInitDisplay(CompPlugin * p, CompDisplay * d)
{
- //Generate a bench display
- CrashhandlerDisplay *cd =
- (CrashhandlerDisplay *) malloc (sizeof (CrashhandlerDisplay));
- //Allocate a private index
- cd->screenPrivateIndex = allocateScreenPrivateIndex (d);
- //Check if its valid
- if (cd->screenPrivateIndex < 0)
- {
- //Its invalid so free memory and return
- free (cd);
- return FALSE;
- }
- crashhandlerDisplayInitOptions (cd);
- cDisplay = d;
-
- if (cd->opt[CRASHHANDLER_DISPLAY_OPTION_ENABLED].value.b)
- {
- // segmentation fault
- signal (SIGSEGV, crash_handler);
- // floating point exception
- signal (SIGFPE, crash_handler);
- // illegal instruction
- signal (SIGILL, crash_handler);
- // abort
- signal (SIGABRT, crash_handler);
- }
-
-
-
- //Record the display
- d->privates[displayPrivateIndex].ptr = cd;
- return TRUE;
+ //Generate a bench display
+ CrashhandlerDisplay *cd =
+ (CrashhandlerDisplay *) malloc(sizeof(CrashhandlerDisplay));
+ //Allocate a private index
+ cd->screenPrivateIndex = allocateScreenPrivateIndex(d);
+ //Check if its valid
+ if (cd->screenPrivateIndex < 0) {
+ //Its invalid so free memory and return
+ free(cd);
+ return FALSE;
+ }
+ crashhandlerDisplayInitOptions(cd);
+ cDisplay = d;
+
+ if (cd->opt[CRASHHANDLER_DISPLAY_OPTION_ENABLED].value.b) {
+ // segmentation fault
+ signal(SIGSEGV, crash_handler);
+ // floating point exception
+ signal(SIGFPE, crash_handler);
+ // illegal instruction
+ signal(SIGILL, crash_handler);
+ // abort
+ signal(SIGABRT, crash_handler);
+ }
+
+
+ //Record the display
+ d->privates[displayPrivateIndex].ptr = cd;
+ return TRUE;
}
-static void
-crashhandlerFiniDisplay (CompPlugin * p, CompDisplay * d)
+static void crashhandlerFiniDisplay(CompPlugin * p, CompDisplay * d)
{
- signal (SIGSEGV, SIG_DFL);
- CRASHHANDLER_DISPLAY (d);
- //Free the private index
- freeScreenPrivateIndex (d, cd->screenPrivateIndex);
- //Free the pointer
- free (cd);
+ signal(SIGSEGV, SIG_DFL);
+ CRASHHANDLER_DISPLAY(d);
+ //Free the private index
+ freeScreenPrivateIndex(d, cd->screenPrivateIndex);
+ //Free the pointer
+ free(cd);
}
-static Bool
-crashhandlerInit (CompPlugin * p)
+static Bool crashhandlerInit(CompPlugin * p)
{
- displayPrivateIndex = allocateDisplayPrivateIndex ();
+ displayPrivateIndex = allocateDisplayPrivateIndex();
- if (displayPrivateIndex < 0)
- return FALSE;
+ if (displayPrivateIndex < 0)
+ return FALSE;
- return TRUE;
+ return TRUE;
}
-static void
-crashhandlerFini (CompPlugin * p)
+static void crashhandlerFini(CompPlugin * p)
{
- if (displayPrivateIndex >= 0)
- freeDisplayPrivateIndex (displayPrivateIndex);
+ if (displayPrivateIndex >= 0)
+ freeDisplayPrivateIndex(displayPrivateIndex);
}
CompPluginVTable crashhandlerVTable = {
- "crashhandler",
- N_("Crash handler"),
- N_("Beryl crash handler plugin"),
- crashhandlerInit,
- crashhandlerFini,
- crashhandlerInitDisplay,
- crashhandlerFiniDisplay,
- 0,
- 0,
- 0,
- 0,
- crashhandlerGetDisplayOptions,
- crashhandlerSetDisplayOption,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- BERYL_ABI_INFO,
- "beryl-plugins"
+ "crashhandler",
+ N_("Crash handler"),
+ N_("Beryl crash handler plugin"),
+ crashhandlerInit,
+ crashhandlerFini,
+ crashhandlerInitDisplay,
+ crashhandlerFiniDisplay,
+ 0,
+ 0,
+ 0,
+ 0,
+ crashhandlerGetDisplayOptions,
+ crashhandlerSetDisplayOption,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ BERYL_ABI_INFO,
+ "beryl-plugins"
};
-CompPluginVTable *
-getCompPluginInfo (void)
+CompPluginVTable *getCompPluginInfo(void)
{
- return &crashhandlerVTable;
+ return &crashhandlerVTable;
}