summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2002-08-31 04:25:44 +0000
committerbde <bde@FreeBSD.org>2002-08-31 04:25:44 +0000
commitcc37b25dbb5feb0c2228e663ff607c9cfe80b941 (patch)
tree6496da2e417fd05735f3de0655a5fb6b373de639 /sys
parent385431ebc407d822797fd1d54db2210bda008c77 (diff)
downloadFreeBSD-src-cc37b25dbb5feb0c2228e663ff607c9cfe80b941.zip
FreeBSD-src-cc37b25dbb5feb0c2228e663ff607c9cfe80b941.tar.gz
db_ps.c:
Don't attempt to follow null pointers for zombie processes in db_ps(). Style fix: use explicit an comparison with NULL for all null pointer checks in db_ps() instead of for half of them. db_interface.c: Fixed ddb's handling of traps from with ddb on i386's only. This was mostly fixed in rev.1.27 (by longjmp()'ing back to the top level) but was completly broken in rev.1.48 (by not unwinding the new state (mainly db_active) either before or after the longjmp(). This mostly never worked for other arches, since rev.1.27 has not been ported and lower level longjmp()'s only handle traps for memory accesses. All cases should be handled at a lower level to provided better control and simplify unwinding of state. Implementation details: don't pretend to maintain db_active in a nested way -- ddb cannot be reentered in a nested way. Use db_active instead of the db_global_jmpbuf_valid flag and longjmp()'s return value for things related to reentering ddb. [re]entering is still not atomic enough.
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/db_interface.c16
-rw-r--r--sys/ddb/db_ps.c11
-rw-r--r--sys/i386/i386/db_interface.c16
3 files changed, 22 insertions, 21 deletions
diff --git a/sys/amd64/amd64/db_interface.c b/sys/amd64/amd64/db_interface.c
index 2ba81da..26635d3 100644
--- a/sys/amd64/amd64/db_interface.c
+++ b/sys/amd64/amd64/db_interface.c
@@ -58,7 +58,6 @@ int db_active;
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("mov %%ss,%0" : "=r" (ss)); ss;})
@@ -119,7 +118,7 @@ kdb_trap(type, code, regs)
* non-ddb functions. db_nofault only applies to memory accesses by
* internal ddb commands.
*/
- if (db_global_jmpbuf_valid)
+ if (db_active)
longjmp(db_global_jmpbuf, 1);
/*
@@ -154,16 +153,17 @@ kdb_trap(type, code, regs)
#endif /* SMP */
(void) setjmp(db_global_jmpbuf);
- db_global_jmpbuf_valid = TRUE;
- db_active++;
if (ddb_mode) {
- cndbctl(TRUE);
+ if (!db_active)
+ cndbctl(TRUE);
+ db_active = 1;
db_trap(type, code);
cndbctl(FALSE);
- } else
+ } else {
+ db_active = 1;
gdb_handle_exception(&ddb_regs, type, code);
- db_active--;
- db_global_jmpbuf_valid = FALSE;
+ }
+ db_active = 0;
#ifdef SMP
#ifdef CPUSTOP_ON_DDBBREAK
diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c
index 05c0778..7025ee3 100644
--- a/sys/ddb/db_ps.c
+++ b/sys/ddb/db_ps.c
@@ -120,14 +120,15 @@ db_ps(dummy1, dummy2, dummy3, dummy4)
}
db_printf("%5d %8p %8p %4d %5d %5d %07x %-4s",
p->p_pid, (volatile void *)p, (void *)p->p_uarea,
- p->p_ucred ? p->p_ucred->cr_ruid : 0, pp->p_pid,
- p->p_pgrp ? p->p_pgrp->pg_id : 0, p->p_flag, state);
+ p->p_ucred != NULL ? p->p_ucred->cr_ruid : 0, pp->p_pid,
+ p->p_pgrp != NULL ? p->p_pgrp->pg_id : 0, p->p_flag,
+ state);
if (p->p_flag & P_KSES) {
db_printf("(threaded) %s\n", p->p_comm);
FOREACH_THREAD_IN_PROC(p, td) {
db_printf( ". . . . . . . "
". thread %p . . . ", td);
- if (td->td_wchan) {
+ if (td->td_wchan != NULL) {
db_printf("SLP %6s %8p\n", td->td_wmesg,
(void *)td->td_wchan);
} else if (td->td_state == TDS_MTX) {
@@ -139,10 +140,10 @@ db_ps(dummy1, dummy2, dummy3, dummy4)
}
} else {
td = FIRST_THREAD_IN_PROC(p);
- if (td->td_wchan) {
+ if (td != NULL && td->td_wchan != NULL) {
db_printf(" %-6s %8p", td->td_wmesg,
(void *)td->td_wchan);
- } else if (td->td_state == TDS_MTX) {
+ } else if (td != NULL && td->td_state == TDS_MTX) {
db_printf(" %6s %8p", td->td_mtxname,
(void *)td->td_blocked);
} else {
diff --git a/sys/i386/i386/db_interface.c b/sys/i386/i386/db_interface.c
index 2ba81da..26635d3 100644
--- a/sys/i386/i386/db_interface.c
+++ b/sys/i386/i386/db_interface.c
@@ -58,7 +58,6 @@ int db_active;
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("mov %%ss,%0" : "=r" (ss)); ss;})
@@ -119,7 +118,7 @@ kdb_trap(type, code, regs)
* non-ddb functions. db_nofault only applies to memory accesses by
* internal ddb commands.
*/
- if (db_global_jmpbuf_valid)
+ if (db_active)
longjmp(db_global_jmpbuf, 1);
/*
@@ -154,16 +153,17 @@ kdb_trap(type, code, regs)
#endif /* SMP */
(void) setjmp(db_global_jmpbuf);
- db_global_jmpbuf_valid = TRUE;
- db_active++;
if (ddb_mode) {
- cndbctl(TRUE);
+ if (!db_active)
+ cndbctl(TRUE);
+ db_active = 1;
db_trap(type, code);
cndbctl(FALSE);
- } else
+ } else {
+ db_active = 1;
gdb_handle_exception(&ddb_regs, type, code);
- db_active--;
- db_global_jmpbuf_valid = FALSE;
+ }
+ db_active = 0;
#ifdef SMP
#ifdef CPUSTOP_ON_DDBBREAK
OpenPOWER on IntegriCloud