| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: db_xxx.c,v 1.65 2011/12/02 23:57:58 christos Exp $ */ | | 1 | /* $NetBSD: db_xxx.c,v 1.66 2011/12/03 16:25:49 christos Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1982, 1986, 1989, 1991, 1993 | | 4 | * Copyright (c) 1982, 1986, 1989, 1991, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -27,27 +27,27 @@ | | | @@ -27,27 +27,27 @@ |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | * | | 30 | * |
31 | * from: kern_proc.c 8.4 (Berkeley) 1/4/94 | | 31 | * from: kern_proc.c 8.4 (Berkeley) 1/4/94 |
32 | */ | | 32 | */ |
33 | | | 33 | |
34 | /* | | 34 | /* |
35 | * Miscellaneous DDB functions that are intimate (xxx) with various | | 35 | * Miscellaneous DDB functions that are intimate (xxx) with various |
36 | * data structures and functions used by the kernel (proc, callout). | | 36 | * data structures and functions used by the kernel (proc, callout). |
37 | */ | | 37 | */ |
38 | | | 38 | |
39 | #include <sys/cdefs.h> | | 39 | #include <sys/cdefs.h> |
40 | __KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.65 2011/12/02 23:57:58 christos Exp $"); | | 40 | __KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.66 2011/12/03 16:25:49 christos Exp $"); |
41 | | | 41 | |
42 | #ifdef _KERNEL_OPT | | 42 | #ifdef _KERNEL_OPT |
43 | #include "opt_kgdb.h" | | 43 | #include "opt_kgdb.h" |
44 | #include "opt_aio.h" | | 44 | #include "opt_aio.h" |
45 | #include "opt_mqueue.h" | | 45 | #include "opt_mqueue.h" |
46 | #endif | | 46 | #endif |
47 | | | 47 | |
48 | #ifndef _KERNEL | | 48 | #ifndef _KERNEL |
49 | #include <stdbool.h> | | 49 | #include <stdbool.h> |
50 | #endif | | 50 | #endif |
51 | | | 51 | |
52 | #include <sys/param.h> | | 52 | #include <sys/param.h> |
53 | #include <sys/systm.h> | | 53 | #include <sys/systm.h> |
| @@ -98,39 +98,49 @@ db_kill_proc(db_expr_t addr, bool haddr, | | | @@ -98,39 +98,49 @@ db_kill_proc(db_expr_t addr, bool haddr, |
98 | db_error("sig?\n"); | | 98 | db_error("sig?\n"); |
99 | /*NOTREACHED*/ | | 99 | /*NOTREACHED*/ |
100 | } | | 100 | } |
101 | } else { | | 101 | } else { |
102 | db_unread_token(t); | | 102 | db_unread_token(t); |
103 | sig = 15; | | 103 | sig = 15; |
104 | } | | 104 | } |
105 | if (db_read_token() != tEOL) { | | 105 | if (db_read_token() != tEOL) { |
106 | db_error("?\n"); | | 106 | db_error("?\n"); |
107 | /*NOTREACHED*/ | | 107 | /*NOTREACHED*/ |
108 | } | | 108 | } |
109 | /* We might stop when the mutex is held or when not */ | | 109 | /* We might stop when the mutex is held or when not */ |
110 | t = mutex_tryenter(proc_lock); | | 110 | t = mutex_tryenter(proc_lock); |
| | | 111 | #ifdef DIAGNOSTIC |
| | | 112 | if (!t) { |
| | | 113 | db_error("could not acquire proc_lock mutex\n"); |
| | | 114 | /*NOTREACHED*/ |
| | | 115 | } |
| | | 116 | #endif |
111 | p = proc_find((pid_t)pid); | | 117 | p = proc_find((pid_t)pid); |
112 | if (t) | | | |
113 | mutex_exit(proc_lock); | | | |
114 | if (p == NULL) { | | 118 | if (p == NULL) { |
115 | db_error("no such proc\n"); | | 119 | if (t) |
116 | /*NOTREACHED*/ | | 120 | mutex_exit(proc_lock); |
| | | 121 | db_error("no such proc\n"); |
| | | 122 | /*NOTREACHED*/ |
117 | } | | 123 | } |
118 | KSI_INIT(&ksi); | | 124 | KSI_INIT(&ksi); |
119 | ksi.ksi_signo = sig; | | 125 | ksi.ksi_signo = sig; |
120 | ksi.ksi_code = SI_USER; | | 126 | ksi.ksi_code = SI_USER; |
121 | ksi.ksi_pid = 0; | | 127 | ksi.ksi_pid = 0; |
122 | ksi.ksi_uid = 0; | | 128 | ksi.ksi_uid = 0; |
| | | 129 | mutex_enter(p->p_lock); |
123 | kpsignal2(p, &ksi); | | 130 | kpsignal2(p, &ksi); |
| | | 131 | mutex_exit(p->p_lock); |
| | | 132 | if (t) |
| | | 133 | mutex_exit(proc_lock); |
124 | #else | | 134 | #else |
125 | db_printf("This command is not currently supported.\n"); | | 135 | db_printf("This command is not currently supported.\n"); |
126 | #endif | | 136 | #endif |
127 | } | | 137 | } |
128 | | | 138 | |
129 | #ifdef KGDB | | 139 | #ifdef KGDB |
130 | void | | 140 | void |
131 | db_kgdb_cmd(db_expr_t addr, bool haddr, | | 141 | db_kgdb_cmd(db_expr_t addr, bool haddr, |
132 | db_expr_t count, const char *modif) | | 142 | db_expr_t count, const char *modif) |
133 | { | | 143 | { |
134 | kgdb_active++; | | 144 | kgdb_active++; |
135 | kgdb_trap(db_trap_type, DDB_REGS); | | 145 | kgdb_trap(db_trap_type, DDB_REGS); |
136 | kgdb_active--; | | 146 | kgdb_active--; |