summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/crashhandler.c
diff options
context:
space:
mode:
authorracarr <racarr@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-12-23 08:13:28 +0000
committerracarr <racarr@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-12-23 08:13:28 +0000
commit25017b81675d9537e0c4030043e7253f8a582ba9 (patch)
treee95993812aedc1947cdc332214cbcfeb52cc33b8 /beryl-plugins/src/crashhandler.c
parentc2a520a050f814519a7f0b7f79e9fa577de27bac (diff)
downloadmarex-dev-25017b81675d9537e0c4030043e7253f8a582ba9.tar.gz
marex-dev-25017b81675d9537e0c4030043e7253f8a582ba9.tar.bz2
Indent script
git-svn-id: file:///beryl/trunk@2015 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/crashhandler.c')
-rw-r--r--beryl-plugins/src/crashhandler.c416
1 files changed, 206 insertions, 210 deletions
diff --git a/beryl-plugins/src/crashhandler.c b/beryl-plugins/src/crashhandler.c
index 2f50fe5..3bcbb36 100644
--- a/beryl-plugins/src/crashhandler.c
+++ b/beryl-plugins/src/crashhandler.c
@@ -50,255 +50,251 @@ static CompDisplay *cDisplay;
typedef struct _CrashhandlerDisplay
{
- int screenPrivateIndex;
- CompOption opt[CRASHHANDLER_DISPLAY_OPTION_NUM];
+ 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->advanced=False;
-o->name = "enabled";
- o->group = N_("Misc. settings");
- 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->advanced=False;
-o->name = "start_window_manager";
- o->group = N_("Misc. settings");
- 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->advanced=False;
-o->name = "window_manager_command_line";
- o->group = N_("Misc. settings");
- 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->advanced = False;
+ o->name = "enabled";
+ o->group = N_("Misc. settings");
+ 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->advanced = False;
+ o->name = "start_window_manager";
+ o->group = N_("Misc. settings");
+ 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->advanced = False;
+ o->name = "window_manager_command_line";
+ o->group = N_("Misc. settings");
+ 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",
- "devel",
+ "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",
+ "devel",
0,
0,
};
-CompPluginVTable *
-getCompPluginInfo (void)
+CompPluginVTable *getCompPluginInfo(void)
{
- return &crashhandlerVTable;
+ return &crashhandlerVTable;
}