diff options
author | Roy Marples <roy@marples.name> | 2008-03-24 11:43:03 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2008-03-24 11:43:03 +0000 |
commit | 821166fbfd4bd81716fc0b5f87259bf6caf7b7b1 (patch) | |
tree | e8e60648203c4f25f2498bbbe53548ce2c69a93a /src | |
parent | 79719b538693c10cf8881da4357dd16a1117af34 (diff) |
Fix debug support to work without gmake and bundle -ggdb in properly.
Diffstat (limited to 'src')
-rw-r--r-- | src/libeinfo/Makefile | 1 | ||||
-rw-r--r-- | src/librc/Makefile | 1 | ||||
-rw-r--r-- | src/rc/Makefile | 4 | ||||
-rw-r--r-- | src/rc/rc.c | 43 |
4 files changed, 20 insertions, 29 deletions
diff --git a/src/libeinfo/Makefile b/src/libeinfo/Makefile index bcbfa62b..4c381cea 100644 --- a/src/libeinfo/Makefile +++ b/src/libeinfo/Makefile @@ -9,4 +9,5 @@ CFLAGS+= -I../includes MK= ../../mk include ${MK}/lib.mk include ${MK}/cc.mk +include ${MK}/debug.mk include ${MK}/${MKTERMCAP}.mk diff --git a/src/librc/Makefile b/src/librc/Makefile index f47f5b07..c18f2224 100644 --- a/src/librc/Makefile +++ b/src/librc/Makefile @@ -14,3 +14,4 @@ CFLAGS+= -I../includes MK= ../../mk include ${MK}/lib.mk include ${MK}/cc.mk +include ${MK}/debug.mk diff --git a/src/rc/Makefile b/src/rc/Makefile index 76e635dc..f60fc313 100644 --- a/src/rc/Makefile +++ b/src/rc/Makefile @@ -32,13 +32,11 @@ CLEANFILES+= ${ALL_LINKS} LDFLAGS+= -L../librc -L../libeinfo LDADD+= -lutil -lrc -leinfo -#CFLAGS+= -ggdb -CPPFLAGS+= $(shell test "x$(DEBUG)" = x && echo -DRC_DEBUG=0 || echo -DRC_DEBUG=1) -LDFLAGS+= $(shell test -d ../../.git && echo -Wl,--rpath=../librc -Wl,--rpath=../libeinfo) MK= ../../mk include ${MK}/prog.mk include ${MK}/cc.mk +include ${MK}/debug.mk CFLAGS+= -I../includes -I../librc -I../libeinfo CFLAGS+= -DLIB=\"${LIBNAME}\" diff --git a/src/rc/rc.c b/src/rc/rc.c index 65501c6a..6c0a3fed 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -898,43 +898,30 @@ interactive_option: } -static void catch_a_baddie(int sig) +#ifdef RC_DEBUG +static void handle_bad_signal(int sig) { + char pid[10]; + int status; pid_t crashed_pid = getpid(); switch (fork()) { - case -1: _exit(sig); - case 0: { - char pid[10]; + case -1: + _exit(sig); + /* NOTREACHED */ + case 0: sprintf(pid, "%i", crashed_pid); printf("\nAuto launching gdb!\n\n"); _exit(execlp("gdb", "gdb", "--quiet", "--pid", pid, "-ex", "bt full", NULL)); - } - default: { - int status; + /* NOTREACHED */ + default: wait(&status); - } } _exit(1); + /* NOTREACHED */ } -static void init_bad_signals(void) -{ - struct sigaction sa; - sigset_t full; - - if (!RC_DEBUG) - return; - - memset(&sa, 0, sizeof(sa)); - sa.sa_handler = catch_a_baddie; - sigfillset(&full); - sa.sa_mask = full; - - sigaction(SIGBUS, &sa, NULL); - sigaction(SIGILL, &sa, NULL); - sigaction(SIGSEGV, &sa, NULL); -} +#endif #include "_usage.h" #define getoptstring "o:" getoptstring_COMMON @@ -970,7 +957,11 @@ int main(int argc, char **argv) char *token; #endif - init_bad_signals(); +#ifdef RC_DEBUG + signal_setup(SIGBUS, handle_bad_signal); + signal_setup(SIGILL, handle_bad_signal); + signal_setup(SIGSEGV, handle_bad_signal); +#endif applet = basename_c(argv[0]); LIST_INIT(&service_pids); |