Module Name: src
Committed By: christos
Date: Sat Dec 3 16:25:50 UTC 2011
Modified Files:
src/sys/ddb: db_xxx.c
Log Message:
If we are DIAGNOSTIC don't try to go further if we failed to take the
lock, because we are going to trigger a KASSERT. Also hold the lock
longer and take the proc lock for kpsignal(). Maybe we should add
mutex_steal() and mutex_return() for the debugger? Lock correction
suggestion from jmcneill.
To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/ddb/db_xxx.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/ddb/db_xxx.c
diff -u src/sys/ddb/db_xxx.c:1.65 src/sys/ddb/db_xxx.c:1.66
--- src/sys/ddb/db_xxx.c:1.65 Fri Dec 2 18:57:58 2011
+++ src/sys/ddb/db_xxx.c Sat Dec 3 11:25:49 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: db_xxx.c,v 1.65 2011/12/02 23:57:58 christos Exp $ */
+/* $NetBSD: db_xxx.c,v 1.66 2011/12/03 16:25:49 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.65 2011/12/02 23:57:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.66 2011/12/03 16:25:49 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_kgdb.h"
@@ -108,19 +108,29 @@ db_kill_proc(db_expr_t addr, bool haddr,
}
/* We might stop when the mutex is held or when not */
t = mutex_tryenter(proc_lock);
+#ifdef DIAGNOSTIC
+ if (!t) {
+ db_error("could not acquire proc_lock mutex\n");
+ /*NOTREACHED*/
+ }
+#endif
p = proc_find((pid_t)pid);
- if (t)
- mutex_exit(proc_lock);
if (p == NULL) {
- db_error("no such proc\n");
- /*NOTREACHED*/
+ if (t)
+ mutex_exit(proc_lock);
+ db_error("no such proc\n");
+ /*NOTREACHED*/
}
KSI_INIT(&ksi);
ksi.ksi_signo = sig;
ksi.ksi_code = SI_USER;
ksi.ksi_pid = 0;
ksi.ksi_uid = 0;
+ mutex_enter(p->p_lock);
kpsignal2(p, &ksi);
+ mutex_exit(p->p_lock);
+ if (t)
+ mutex_exit(proc_lock);
#else
db_printf("This command is not currently supported.\n");
#endif