Thu Mar 11 10:34:34 2021 UTC ()
Numeric modifiers conflict with the syntax interpretation of ddb, so use 'b', 'w', 'l', 'q' instead.
Also, change load/store('l','s') to 'r','w' like the other arch.

 >db{0}> machine watch/1 hostname
 >Bad modifier

 >db{0}> machine watch/s1 hostname
 >add watchpoint 0 as ffffc00001087848


(ryo)
diff -r1.198 -r1.199 src/share/man/man4/ddb.4
diff -r1.38 -r1.39 src/sys/arch/aarch64/aarch64/db_machdep.c

cvs diff -r1.198 -r1.199 src/share/man/man4/ddb.4 (expand / switch to unified diff)

--- src/share/man/man4/ddb.4 2021/02/19 08:57:56 1.198
+++ src/share/man/man4/ddb.4 2021/03/11 10:34:34 1.199
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: ddb.4,v 1.198 2021/02/19 08:57:56 msaitoh Exp $ 1.\" $NetBSD: ddb.4,v 1.199 2021/03/11 10:34:34 ryo Exp $
2.\" 2.\"
3.\" Copyright (c) 1997 - 2019 The NetBSD Foundation, Inc. 3.\" Copyright (c) 1997 - 2019 The NetBSD Foundation, Inc.
4.\" All rights reserved. 4.\" All rights reserved.
5.\" 5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation 6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Luke Mewburn 7.\" by Luke Mewburn
8.\" 8.\"
9.\" Redistribution and use in source and binary forms, with or without 9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions 10.\" modification, are permitted provided that the following conditions
11.\" are met: 11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright 12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer. 13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" 2. Redistributions in binary form must reproduce the above copyright
@@ -46,27 +46,27 @@ @@ -46,27 +46,27 @@
46.\" CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 46.\" CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
47.\" ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 47.\" ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
48.\" 48.\"
49.\" Carnegie Mellon requests users of this software to return to 49.\" Carnegie Mellon requests users of this software to return to
50.\" 50.\"
51.\" Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 51.\" Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
52.\" School of Computer Science 52.\" School of Computer Science
53.\" Carnegie Mellon University 53.\" Carnegie Mellon University
54.\" Pittsburgh PA 15213-3890 54.\" Pittsburgh PA 15213-3890
55.\" 55.\"
56.\" any improvements or extensions that they make and grant Carnegie Mellon 56.\" any improvements or extensions that they make and grant Carnegie Mellon
57.\" the rights to redistribute these changes. 57.\" the rights to redistribute these changes.
58.\" 58.\"
59.Dd February 19, 2021 59.Dd March 11, 2021
60.Dt DDB 4 60.Dt DDB 4
61.Os 61.Os
62.Sh NAME 62.Sh NAME
63.Nm ddb 63.Nm ddb
64.Nd in-kernel debugger 64.Nd in-kernel debugger
65.Sh SYNOPSIS 65.Sh SYNOPSIS
66.Cd options DDB 66.Cd options DDB
67.Pp 67.Pp
68To enable history editing: 68To enable history editing:
69.Cd options DDB_HISTORY_SIZE=integer 69.Cd options DDB_HISTORY_SIZE=integer
70.Pp 70.Pp
71To disable entering 71To disable entering
72.\" XXX: hack; .Nm automatically introduces newline in SYNOPSIS 72.\" XXX: hack; .Nm automatically introduces newline in SYNOPSIS
@@ -1007,64 +1007,58 @@ into the @@ -1007,64 +1007,58 @@ into the
1007.Nx 1007.Nx
1008kernel for any given port can also add machine specific commands 1008kernel for any given port can also add machine specific commands
1009to the 1009to the
1010.Nm 1010.Nm
1011command parser. 1011command parser.
1012All of these commands are preceded by the command word 1012All of these commands are preceded by the command word
1013.Em machine 1013.Em machine
1014to indicate that they are part of the machine-specific command 1014to indicate that they are part of the machine-specific command
1015set (e.g. 1015set (e.g.
1016.Ic machine reboot ) . 1016.Ic machine reboot ) .
1017Some of these commands are: 1017Some of these commands are:
1018.Ss AARCH64 1018.Ss AARCH64
1019.Bl -tag -width "traptrace" -compact 1019.Bl -tag -width "traptrace" -compact
 1020.It Ic break
 1021Set or clear a hardware breakpoint.
1020.It Ic cpu 1022.It Ic cpu
1021Switch to another CPU. 1023Switch to another CPU.
1022.It Ic cpuinfo 1024.It Ic cpuinfo
1023Print CPU information about the ``struct cpuinfo''. 1025Print CPU information about the ``struct cpuinfo''.
1024.It Ic frame 1026.It Ic frame
1025Given a trap frame address, print out the trap frame. 1027Given a trap frame address, print out the trap frame.
1026.It Ic lwp 1028.It Ic lwp
1027Print lwp information about the ``struct lwp''. 1029Print lwp information about the ``struct lwp''.
1028.It Ic pte 1030.It Ic pte
1029Print PTE information. 1031Print PTE information.
1030.It Ic reset 1032.It Ic reset
1031Reset the system. 1033Reset the system.
1032.It Ic sysreg 1034.It Ic sysreg
1033Print system registers. 1035Print system registers.
1034.It Ic watch 1036.It Ic watch
1035Set or clear a hardware watchpoint. 1037Set or clear a hardware watchpoint.
1036Pass the address to be watched, or watchpoint number to clear the watchpoint. 1038Pass the address to be watched, or watchpoint number to clear the watchpoint.
1037Optional modifiers are 1039Optional modifiers are
1038.Dq l 1040.Dq r
1039for load access, 1041for read access,
1040.Dq s 1042.Dq w
1041for store access, 1043for write access (default: trap on read or write access),
1042.Dq 1 1044.Dq b
1043for 8 bit width, 1045for 8 bit width,
1044.Dq 2 1046.Dq h
1045for 16 bit, 1047for 16 bit,
1046.Dq 3 1048.Dq l
1047for 24 bit, 1049for 32 bit or,
1048.Dq 4 1050.Dq q
1049for 32 bit, 1051for 64 bit (default: 32 bit).
1050.Dq 5 
1051for 40 bit, 
1052.Dq 6 
1053for 48 bit, 
1054.Dq 7 
1055for 56 bit, 
1056.Dq 8 
1057for 64 bit. 
1058.El 1052.El
1059.Ss ALPHA 1053.Ss ALPHA
1060.Bl -tag -width "traptrace" -compact 1054.Bl -tag -width "traptrace" -compact
1061.It Ic cpu 1055.It Ic cpu
1062Switch to another CPU. 1056Switch to another CPU.
1063.\" .It Ic halt 1057.\" .It Ic halt
1064.\" Call the PROM monitor to halt the CPU. 1058.\" Call the PROM monitor to halt the CPU.
1065.\" .It Ic reboot 1059.\" .It Ic reboot
1066.\" Call the PROM monitor to reboot the CPU. 1060.\" Call the PROM monitor to reboot the CPU.
1067.El 1061.El
1068.Ss AMD64 1062.Ss AMD64
1069.Bl -tag -width "traptrace" -compact 1063.Bl -tag -width "traptrace" -compact
1070.It Ic cpu 1064.It Ic cpu

cvs diff -r1.38 -r1.39 src/sys/arch/aarch64/aarch64/db_machdep.c (expand / switch to unified diff)

--- src/sys/arch/aarch64/aarch64/db_machdep.c 2021/03/11 09:48:40 1.38
+++ src/sys/arch/aarch64/aarch64/db_machdep.c 2021/03/11 10:34:34 1.39
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: db_machdep.c,v 1.38 2021/03/11 09:48:40 ryo Exp $ */ 1/* $NetBSD: db_machdep.c,v 1.39 2021/03/11 10:34:34 ryo Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc. 4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry. 8 * by Matt Thomas of 3am Software Foundry.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.38 2021/03/11 09:48:40 ryo Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.39 2021/03/11 10:34:34 ryo Exp $");
34 34
35#ifdef _KERNEL_OPT 35#ifdef _KERNEL_OPT
36#include "opt_compat_netbsd32.h" 36#include "opt_compat_netbsd32.h"
37#endif 37#endif
38 38
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/systm.h> 40#include <sys/systm.h>
41#include <sys/atomic.h> 41#include <sys/atomic.h>
42#include <sys/cpu.h> 42#include <sys/cpu.h>
43#include <sys/lwp.h> 43#include <sys/lwp.h>
44#include <sys/intr.h> 44#include <sys/intr.h>
45 45
46#include <uvm/uvm.h> 46#include <uvm/uvm.h>
@@ -169,30 +169,31 @@ const struct db_command db_machine_comma @@ -169,30 +169,31 @@ const struct db_command db_machine_comma
169 }, 169 },
170 { 170 {
171 DDB_ADD_CMD( 171 DDB_ADD_CMD(
172 "ttbr", db_md_ttbr_cmd, 0, 172 "ttbr", db_md_ttbr_cmd, 0,
173 "Dump or count TTBR table", 173 "Dump or count TTBR table",
174 "[/apc] address | pid", 174 "[/apc] address | pid",
175 "\taddress:\taddress of pmap to display\n" 175 "\taddress:\taddress of pmap to display\n"
176 "\tpid:\t\tpid of pmap to display") 176 "\tpid:\t\tpid of pmap to display")
177 }, 177 },
178 { 178 {
179 DDB_ADD_CMD( 179 DDB_ADD_CMD(
180 "watch", db_md_watch_cmd, 0, 180 "watch", db_md_watch_cmd, 0,
181 "set or clear watchpoint", 181 "set or clear watchpoint",
182 "[/12345678] [address|#]", 182 "[/rwbhlq] [address|#]",
183 "\taddress: watchpoint address to set\n" 183 "\taddress: watchpoint address to set\n"
184 "\t#: watchpoint number to remove" 184 "\t#: watchpoint number to remove\n"
185 "\t/1..8: size of data\n") 185 "\t/rw: read or write access\n"
 186 "\t/bhlq: size of access\n")
186 }, 187 },
187 { 188 {
188 DDB_ADD_CMD( 189 DDB_ADD_CMD(
189 "meminfo", db_md_meminfo_cmd, 0, 190 "meminfo", db_md_meminfo_cmd, 0,
190 "Dump info about memory ranges", 191 "Dump info about memory ranges",
191 NULL, NULL) 192 NULL, NULL)
192 }, 193 },
193#endif 194#endif
194 { 195 {
195 DDB_END_CMD 196 DDB_END_CMD
196 }, 197 },
197}; 198};
198 199
@@ -968,40 +969,42 @@ db_md_watch_cmd(db_expr_t addr, bool hav @@ -968,40 +969,42 @@ db_md_watch_cmd(db_expr_t addr, bool hav
968 969
969 if (!have_addr) { 970 if (!have_addr) {
970 show_watchpoints(); 971 show_watchpoints();
971 return; 972 return;
972 } 973 }
973 974
974 accesstype = watchsize = 0; 975 accesstype = watchsize = 0;
975 if ((modif != NULL) && (*modif != '\0')) { 976 if ((modif != NULL) && (*modif != '\0')) {
976 int ch; 977 int ch;
977 for (; *modif != '\0'; modif++) { 978 for (; *modif != '\0'; modif++) {
978 ch = *modif; 979 ch = *modif;
979 980
980 switch (ch) { 981 switch (ch) {
981 case '1': 982 case 'b':
982 case '2': 983 watchsize = 1;
983 case '3': 984 break;
984 case '4': 985 case 'h':
985 case '5': 986 watchsize = 2;
986 case '6': 
987 case '7': 
988 case '8': 
989 watchsize = ch - '0'; 
990 break; 987 break;
991 case 'l': 988 case 'l':
 989 watchsize = 4;
 990 break;
 991 case 'q':
 992 watchsize = 8;
 993 break;
 994 case 'r':
992 accesstype |= WATCHPOINT_ACCESS_LOAD; 995 accesstype |= WATCHPOINT_ACCESS_LOAD;
993 break; 996 break;
994 case 's': 997 case 'w':
995 accesstype |= WATCHPOINT_ACCESS_STORE; 998 accesstype |= WATCHPOINT_ACCESS_STORE;
996 break; 999 break;
997 } 1000 }
998 } 1001 }
999 } 1002 }
1000 if (watchsize == 0) 1003 if (watchsize == 0)
1001 watchsize = 4; /* default: 4byte */ 1004 watchsize = 4; /* default: 4byte */
1002 if (accesstype == 0) 1005 if (accesstype == 0)
1003 accesstype = WATCHPOINT_ACCESS_LOADSTORE; /* default */ 1006 accesstype = WATCHPOINT_ACCESS_LOADSTORE; /* default */
1004 1007
1005 added = -1; 1008 added = -1;
1006 cleared = -1; 1009 cleared = -1;
1007 if (0 <= addr && addr <= max_watchpoint) { 1010 if (0 <= addr && addr <= max_watchpoint) {