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.
This commit is contained in:
Bruce Evans 2002-08-31 04:25:44 +00:00
parent 31cdffc6d8
commit efdfb8fea3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=102667
3 changed files with 22 additions and 21 deletions

View file

@ -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

View file

@ -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 {

View file

@ -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