From b8fa61d129429757d1ba66349f7a57b0f76f2c7e Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Fri, 28 Mar 1997 12:56:07 +0000 Subject: [PATCH] Added a setjmp() and a longjmp() so that an unexpected trap inside ddb isn't necessarily fatal. You can now do silly things like `call vprint' and `show map' without losing control. --- sys/amd64/amd64/db_interface.c | 17 ++++++++++++++++- sys/i386/i386/db_interface.c | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/sys/amd64/amd64/db_interface.c b/sys/amd64/amd64/db_interface.c index 6e56a9f523b6..c286027d53bd 100644 --- a/sys/amd64/amd64/db_interface.c +++ b/sys/amd64/amd64/db_interface.c @@ -23,7 +23,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id$ + * $Id: db_interface.c,v 1.26 1997/02/22 09:32:14 peter Exp $ */ /* @@ -44,6 +44,7 @@ #include #include + #include static jmp_buf *db_nofault = 0; @@ -53,6 +54,9 @@ extern void gdb_handle_exception __P((db_regs_t *, int, int)); db_regs_t ddb_regs; +static jmp_buf db_global_jmpbuf; +static int db_global_jmpbuf_valid; + #ifdef __GNUC__ #define rss() ({u_short ss; __asm __volatile("movl %%ss,%0" : "=r" (ss)); ss;}) #endif @@ -107,6 +111,14 @@ kdb_trap(type, code, regs) } } + /* + * This handles unexpected traps in ddb commands, including calls to + * non-ddb functions. db_nofault only applies to memory accesses by + * internal ddb commands. + */ + if (db_global_jmpbuf_valid) + longjmp(db_global_jmpbuf, 1); + /* * XXX We really should switch to a local stack here. */ @@ -122,10 +134,13 @@ kdb_trap(type, code, regs) cnpollc(TRUE); + (void) setjmp(db_global_jmpbuf); + db_global_jmpbuf_valid = TRUE; if (ddb_mode) db_trap(type, code); else gdb_handle_exception(&ddb_regs, type, code); + db_global_jmpbuf_valid = FALSE; cnpollc(FALSE); diff --git a/sys/i386/i386/db_interface.c b/sys/i386/i386/db_interface.c index 6e56a9f523b6..c286027d53bd 100644 --- a/sys/i386/i386/db_interface.c +++ b/sys/i386/i386/db_interface.c @@ -23,7 +23,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id$ + * $Id: db_interface.c,v 1.26 1997/02/22 09:32:14 peter Exp $ */ /* @@ -44,6 +44,7 @@ #include #include + #include static jmp_buf *db_nofault = 0; @@ -53,6 +54,9 @@ extern void gdb_handle_exception __P((db_regs_t *, int, int)); db_regs_t ddb_regs; +static jmp_buf db_global_jmpbuf; +static int db_global_jmpbuf_valid; + #ifdef __GNUC__ #define rss() ({u_short ss; __asm __volatile("movl %%ss,%0" : "=r" (ss)); ss;}) #endif @@ -107,6 +111,14 @@ kdb_trap(type, code, regs) } } + /* + * This handles unexpected traps in ddb commands, including calls to + * non-ddb functions. db_nofault only applies to memory accesses by + * internal ddb commands. + */ + if (db_global_jmpbuf_valid) + longjmp(db_global_jmpbuf, 1); + /* * XXX We really should switch to a local stack here. */ @@ -122,10 +134,13 @@ kdb_trap(type, code, regs) cnpollc(TRUE); + (void) setjmp(db_global_jmpbuf); + db_global_jmpbuf_valid = TRUE; if (ddb_mode) db_trap(type, code); else gdb_handle_exception(&ddb_regs, type, code); + db_global_jmpbuf_valid = FALSE; cnpollc(FALSE);