diff options
author | mdf <mdf@FreeBSD.org> | 2011-02-18 22:25:11 +0000 |
---|---|---|
committer | mdf <mdf@FreeBSD.org> | 2011-02-18 22:25:11 +0000 |
commit | baf9dec697b13c0c3c2739e4d76b03367f062228 (patch) | |
tree | 46e277fb34fa25a6bc0562a2934616b700f3f6f8 /sys/gdb | |
parent | 699ef3129bdda98a0a0164e4d221a0273dfc24d8 (diff) | |
download | FreeBSD-src-baf9dec697b13c0c3c2739e4d76b03367f062228.zip FreeBSD-src-baf9dec697b13c0c3c2739e4d76b03367f062228.tar.gz |
Modify kdb_trap() so that it re-calls the dbbe_trap function as long as
the debugger back-end has changed. This means that switching from ddb
to gdb no longer requires a "step" which can be dangerous on an
already-crashed kernel.
Also add a capability to get from the gdb back-end back to ddb, by
typing ^C in the console window.
While here, simplify kdb_sysctl_available() by using
sbuf_new_for_sysctl(), and use strlcpy() instead of strncpy() since the
strlcpy semantic is desired.
MFC after: 1 month
Diffstat (limited to 'sys/gdb')
-rw-r--r-- | sys/gdb/gdb_main.c | 11 | ||||
-rw-r--r-- | sys/gdb/gdb_packet.c | 12 |
2 files changed, 23 insertions, 0 deletions
diff --git a/sys/gdb/gdb_main.c b/sys/gdb/gdb_main.c index 233330e..8f3c271 100644 --- a/sys/gdb/gdb_main.c +++ b/sys/gdb/gdb_main.c @@ -95,7 +95,17 @@ gdb_init(void) static int gdb_trap(int type, int code) { + jmp_buf jb; struct thread *thr_iter; + void *prev_jb; + + prev_jb = kdb_jmpbuf(jb); + if (setjmp(jb) != 0) { + printf("%s bailing, hopefully back to ddb!\n", __func__); + gdb_listening = 0; + (void)kdb_jmpbuf(prev_jb); + return (1); + } gdb_listening = 0; /* @@ -291,5 +301,6 @@ gdb_trap(int type, int code) break; } } + (void)kdb_jmpbuf(prev_jb); return (0); } diff --git a/sys/gdb/gdb_packet.c b/sys/gdb/gdb_packet.c index d3e5a0a..a62cc8d 100644 --- a/sys/gdb/gdb_packet.c +++ b/sys/gdb/gdb_packet.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/ctype.h> #include <sys/kdb.h> +#include <sys/ttydefaults.h> #include <machine/gdb_machdep.h> #include <machine/kdb.h> @@ -60,6 +61,17 @@ gdb_getc(void) do c = gdb_cur->gdb_getc(); while (c == -1); + + if (c == CTRL('C')) { + printf("Received ^C; trying to switch back to ddb.\n"); + + if (kdb_dbbe_select("ddb") != 0) + printf("The ddb backend could not be selected.\n"); + else { + printf("using longjmp, hope it works!\n"); + kdb_reenter(); + } + } return (c); } |