Wed Jan 13 07:36:56 2021 UTC ()
Improve English in comments


(skrll)
diff -r1.242 -r1.243 src/sys/kern/kern_lwp.c
diff -r1.29 -r1.30 src/sys/kern/kgdb_stub.c

cvs diff -r1.242 -r1.243 src/sys/kern/kern_lwp.c (expand / switch to unified diff)

--- src/sys/kern/kern_lwp.c 2020/06/22 16:21:29 1.242
+++ src/sys/kern/kern_lwp.c 2021/01/13 07:36:56 1.243
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kern_lwp.c,v 1.242 2020/06/22 16:21:29 maxv Exp $ */ 1/* $NetBSD: kern_lwp.c,v 1.243 2021/01/13 07:36:56 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019, 2020 4 * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019, 2020
5 * The NetBSD Foundation, Inc. 5 * The NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Nathan J. Williams, and Andrew Doran. 9 * by Nathan J. Williams, and Andrew Doran.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -186,48 +186,48 @@ @@ -186,48 +186,48 @@
186 * be spc_lwplock for SOBJ_SLEEPQ_NULL (an "untracked" sleep). 186 * be spc_lwplock for SOBJ_SLEEPQ_NULL (an "untracked" sleep).
187 * 187 *
188 * LSSTOP: 188 * LSSTOP:
189 * 189 *
190 * If the LWP was previously sleeping (l_wchan != NULL), then 190 * If the LWP was previously sleeping (l_wchan != NULL), then
191 * l_mutex references the sleep queue lock. If the LWP was 191 * l_mutex references the sleep queue lock. If the LWP was
192 * runnable or on the CPU when halted, or has been removed from 192 * runnable or on the CPU when halted, or has been removed from
193 * the sleep queue since halted, then the lock is spc_lwplock. 193 * the sleep queue since halted, then the lock is spc_lwplock.
194 * 194 *
195 * The lock order is as follows: 195 * The lock order is as follows:
196 * 196 *
197 * sleepq -> turnstile -> spc_lwplock -> spc_mutex 197 * sleepq -> turnstile -> spc_lwplock -> spc_mutex
198 * 198 *
199 * Each process has an scheduler state lock (proc::p_lock), and a 199 * Each process has a scheduler state lock (proc::p_lock), and a
200 * number of counters on LWPs and their states: p_nzlwps, p_nrlwps, and 200 * number of counters on LWPs and their states: p_nzlwps, p_nrlwps, and
201 * so on. When an LWP is to be entered into or removed from one of the 201 * so on. When an LWP is to be entered into or removed from one of the
202 * following states, p_lock must be held and the process wide counters 202 * following states, p_lock must be held and the process wide counters
203 * adjusted: 203 * adjusted:
204 * 204 *
205 * LSIDL, LSZOMB, LSSTOP, LSSUSPENDED 205 * LSIDL, LSZOMB, LSSTOP, LSSUSPENDED
206 * 206 *
207 * (But not always for kernel threads. There are some special cases 207 * (But not always for kernel threads. There are some special cases
208 * as mentioned above: soft interrupts, and the idle loops.) 208 * as mentioned above: soft interrupts, and the idle loops.)
209 * 209 *
210 * Note that an LWP is considered running or likely to run soon if in 210 * Note that an LWP is considered running or likely to run soon if in
211 * one of the following states. This affects the value of p_nrlwps: 211 * one of the following states. This affects the value of p_nrlwps:
212 * 212 *
213 * LSRUN, LSONPROC, LSSLEEP 213 * LSRUN, LSONPROC, LSSLEEP
214 * 214 *
215 * p_lock does not need to be held when transitioning among these 215 * p_lock does not need to be held when transitioning among these
216 * three states, hence p_lock is rarely taken for state transitions. 216 * three states, hence p_lock is rarely taken for state transitions.
217 */ 217 */
218 218
219#include <sys/cdefs.h> 219#include <sys/cdefs.h>
220__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.242 2020/06/22 16:21:29 maxv Exp $"); 220__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.243 2021/01/13 07:36:56 skrll Exp $");
221 221
222#include "opt_ddb.h" 222#include "opt_ddb.h"
223#include "opt_lockdebug.h" 223#include "opt_lockdebug.h"
224#include "opt_dtrace.h" 224#include "opt_dtrace.h"
225 225
226#define _LWP_API_PRIVATE 226#define _LWP_API_PRIVATE
227 227
228#include <sys/param.h> 228#include <sys/param.h>
229#include <sys/systm.h> 229#include <sys/systm.h>
230#include <sys/cpu.h> 230#include <sys/cpu.h>
231#include <sys/pool.h> 231#include <sys/pool.h>
232#include <sys/proc.h> 232#include <sys/proc.h>
233#include <sys/syscallargs.h> 233#include <sys/syscallargs.h>

cvs diff -r1.29 -r1.30 src/sys/kern/kgdb_stub.c (expand / switch to unified diff)

--- src/sys/kern/kgdb_stub.c 2015/06/26 14:26:38 1.29
+++ src/sys/kern/kgdb_stub.c 2021/01/13 07:36:56 1.30
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kgdb_stub.c,v 1.29 2015/06/26 14:26:38 christos Exp $ */ 1/* $NetBSD: kgdb_stub.c,v 1.30 2021/01/13 07:36:56 skrll Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1990, 1993 4 * Copyright (c) 1990, 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 * This software was developed by the Computer Systems Engineering group 7 * This software was developed by the Computer Systems Engineering group
8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 * contributed to Berkeley. 9 * contributed to Berkeley.
10 * 10 *
11 * All advertising materials mentioning features or use of this software 11 * All advertising materials mentioning features or use of this software
12 * must display the following acknowledgement: 12 * must display the following acknowledgement:
13 * This product includes software developed by the University of 13 * This product includes software developed by the University of
14 * California, Lawrence Berkeley Laboratories. 14 * California, Lawrence Berkeley Laboratories.
@@ -35,27 +35,27 @@ @@ -35,27 +35,27 @@
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE. 38 * SUCH DAMAGE.
39 * 39 *
40 * @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94 40 * @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94
41 */ 41 */
42 42
43/* 43/*
44 * "Stub" to allow remote CPU to debug over a serial line using gdb. 44 * "Stub" to allow remote CPU to debug over a serial line using gdb.
45 */ 45 */
46 46
47#include <sys/cdefs.h> 47#include <sys/cdefs.h>
48__KERNEL_RCSID(0, "$NetBSD: kgdb_stub.c,v 1.29 2015/06/26 14:26:38 christos Exp $"); 48__KERNEL_RCSID(0, "$NetBSD: kgdb_stub.c,v 1.30 2021/01/13 07:36:56 skrll Exp $");
49 49
50#include "opt_ddb.h" 50#include "opt_ddb.h"
51#include "opt_kgdb.h" 51#include "opt_kgdb.h"
52 52
53#include <sys/param.h> 53#include <sys/param.h>
54#include <sys/systm.h> 54#include <sys/systm.h>
55#include <sys/kgdb.h> 55#include <sys/kgdb.h>
56 56
57#undef DEBUG_KGDB 57#undef DEBUG_KGDB
58 58
59#ifdef DEBUG_KGDB 59#ifdef DEBUG_KGDB
60#define DPRINTF(x) printf x 60#define DPRINTF(x) printf x
61#else 61#else
@@ -154,76 +154,76 @@ digit2i(u_char c) @@ -154,76 +154,76 @@ digit2i(u_char c)
154 if (c >= '0' && c <= '9') 154 if (c >= '0' && c <= '9')
155 return (c - '0'); 155 return (c - '0');
156 else if (c >= 'a' && c <= 'f') 156 else if (c >= 'a' && c <= 'f')
157 return (c - 'a' + 10); 157 return (c - 'a' + 10);
158 else if (c >= 'A' && c <= 'F') 158 else if (c >= 'A' && c <= 'F')
159 159
160 return (c - 'A' + 10); 160 return (c - 'A' + 10);
161 else 161 else
162 return (-1); 162 return (-1);
163} 163}
164 164
165/* 165/*
166 * Convert the low 4 bits of an integer into 166 * Convert the low 4 bits of an integer into
167 * an hex digit. 167 * a hex digit.
168 */ 168 */
169static u_char 169static u_char
170i2digit(int n) 170i2digit(int n)
171{ 171{
172 return (hexdigits[n & 0x0f]); 172 return (hexdigits[n & 0x0f]);
173} 173}
174 174
175/* 175/*
176 * Convert a byte array into an hex string. 176 * Convert a byte array into a hex string.
177 */ 177 */
178static void 178static void
179mem2hex(void *vdst, void *vsrc, int len) 179mem2hex(void *vdst, void *vsrc, int len)
180{ 180{
181 u_char *dst = vdst; 181 u_char *dst = vdst;
182 u_char *src = vsrc; 182 u_char *src = vsrc;
183 183
184 while (len--) { 184 while (len--) {
185 *dst++ = i2digit(*src >> 4); 185 *dst++ = i2digit(*src >> 4);
186 *dst++ = i2digit(*src++); 186 *dst++ = i2digit(*src++);
187 } 187 }
188 *dst = '\0'; 188 *dst = '\0';
189} 189}
190 190
191/* 191/*
192 * Convert an hex string into a byte array. 192 * Convert a hex string into a byte array.
193 * This returns a pointer to the character following 193 * This returns a pointer to the character following
194 * the last valid hex digit. If the string ends in 194 * the last valid hex digit. If the string ends in
195 * the middle of a byte, NULL is returned. 195 * the middle of a byte, NULL is returned.
196 */ 196 */
197static u_char * 197static u_char *
198hex2mem(void *vdst, u_char *src, int maxlen) 198hex2mem(void *vdst, u_char *src, int maxlen)
199{ 199{
200 u_char *dst = vdst; 200 u_char *dst = vdst;
201 int msb, lsb; 201 int msb, lsb;
202 202
203 while (*src && maxlen--) { 203 while (*src && maxlen--) {
204 msb = digit2i(*src++); 204 msb = digit2i(*src++);
205 if (msb < 0) 205 if (msb < 0)
206 return (src - 1); 206 return (src - 1);
207 lsb = digit2i(*src++); 207 lsb = digit2i(*src++);
208 if (lsb < 0) 208 if (lsb < 0)
209 return (NULL); 209 return (NULL);
210 *dst++ = (msb << 4) | lsb; 210 *dst++ = (msb << 4) | lsb;
211 } 211 }
212 return (src); 212 return (src);
213} 213}
214 214
215/* 215/*
216 * Convert an hex string into an integer. 216 * Convert a hex string into an integer.
217 * This returns a pointer to the character following 217 * This returns a pointer to the character following
218 * the last valid hex digit. 218 * the last valid hex digit.
219 */ 219 */
220static vaddr_t 220static vaddr_t
221hex2i(u_char **srcp) 221hex2i(u_char **srcp)
222{ 222{
223 char *src = *srcp; 223 char *src = *srcp;
224 vaddr_t r = 0; 224 vaddr_t r = 0;
225 int nibble; 225 int nibble;
226 226
227 while ((nibble = digit2i(*src)) >= 0) { 227 while ((nibble = digit2i(*src)) >= 0) {
228 r *= 16; 228 r *= 16;
229 r += nibble; 229 r += nibble;