Fix debug support to work without gmake and bundle -ggdb in properly.
This commit is contained in:
parent
79719b5386
commit
821166fbfd
@ -9,4 +9,5 @@ CFLAGS+= -I../includes
|
|||||||
MK= ../../mk
|
MK= ../../mk
|
||||||
include ${MK}/lib.mk
|
include ${MK}/lib.mk
|
||||||
include ${MK}/cc.mk
|
include ${MK}/cc.mk
|
||||||
|
include ${MK}/debug.mk
|
||||||
include ${MK}/${MKTERMCAP}.mk
|
include ${MK}/${MKTERMCAP}.mk
|
||||||
|
@ -14,3 +14,4 @@ CFLAGS+= -I../includes
|
|||||||
MK= ../../mk
|
MK= ../../mk
|
||||||
include ${MK}/lib.mk
|
include ${MK}/lib.mk
|
||||||
include ${MK}/cc.mk
|
include ${MK}/cc.mk
|
||||||
|
include ${MK}/debug.mk
|
||||||
|
@ -32,13 +32,11 @@ CLEANFILES+= ${ALL_LINKS}
|
|||||||
|
|
||||||
LDFLAGS+= -L../librc -L../libeinfo
|
LDFLAGS+= -L../librc -L../libeinfo
|
||||||
LDADD+= -lutil -lrc -leinfo
|
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
|
MK= ../../mk
|
||||||
include ${MK}/prog.mk
|
include ${MK}/prog.mk
|
||||||
include ${MK}/cc.mk
|
include ${MK}/cc.mk
|
||||||
|
include ${MK}/debug.mk
|
||||||
|
|
||||||
CFLAGS+= -I../includes -I../librc -I../libeinfo
|
CFLAGS+= -I../includes -I../librc -I../libeinfo
|
||||||
CFLAGS+= -DLIB=\"${LIBNAME}\"
|
CFLAGS+= -DLIB=\"${LIBNAME}\"
|
||||||
|
43
src/rc/rc.c
43
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();
|
pid_t crashed_pid = getpid();
|
||||||
|
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
case -1: _exit(sig);
|
case -1:
|
||||||
case 0: {
|
_exit(sig);
|
||||||
char pid[10];
|
/* NOTREACHED */
|
||||||
|
case 0:
|
||||||
sprintf(pid, "%i", crashed_pid);
|
sprintf(pid, "%i", crashed_pid);
|
||||||
printf("\nAuto launching gdb!\n\n");
|
printf("\nAuto launching gdb!\n\n");
|
||||||
_exit(execlp("gdb", "gdb", "--quiet", "--pid", pid, "-ex", "bt full", NULL));
|
_exit(execlp("gdb", "gdb", "--quiet", "--pid", pid, "-ex", "bt full", NULL));
|
||||||
}
|
/* NOTREACHED */
|
||||||
default: {
|
default:
|
||||||
int status;
|
|
||||||
wait(&status);
|
wait(&status);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit(1);
|
_exit(1);
|
||||||
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
static void init_bad_signals(void)
|
#endif
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
#define getoptstring "o:" getoptstring_COMMON
|
#define getoptstring "o:" getoptstring_COMMON
|
||||||
@ -970,7 +957,11 @@ int main(int argc, char **argv)
|
|||||||
char *token;
|
char *token;
|
||||||
#endif
|
#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]);
|
applet = basename_c(argv[0]);
|
||||||
LIST_INIT(&service_pids);
|
LIST_INIT(&service_pids);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user