| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: db_command.c,v 1.167 2020/01/01 22:57:17 thorpej Exp $ */ | | 1 | /* $NetBSD: db_command.c,v 1.168 2020/03/09 01:46:24 christos Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009, 2019 | | 4 | * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009, 2019 |
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 Adam Hamsik, and by Andrew Doran. | | 9 | * by Adam Hamsik, and by 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 |
| @@ -51,27 +51,27 @@ | | | @@ -51,27 +51,27 @@ |
51 | * School of Computer Science | | 51 | * School of Computer Science |
52 | * Carnegie Mellon University | | 52 | * Carnegie Mellon University |
53 | * Pittsburgh PA 15213-3890 | | 53 | * Pittsburgh PA 15213-3890 |
54 | * | | 54 | * |
55 | * any improvements or extensions that they make and grant Carnegie the | | 55 | * any improvements or extensions that they make and grant Carnegie the |
56 | * rights to redistribute these changes. | | 56 | * rights to redistribute these changes. |
57 | */ | | 57 | */ |
58 | | | 58 | |
59 | /* | | 59 | /* |
60 | * Command dispatcher. | | 60 | * Command dispatcher. |
61 | */ | | 61 | */ |
62 | | | 62 | |
63 | #include <sys/cdefs.h> | | 63 | #include <sys/cdefs.h> |
64 | __KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.167 2020/01/01 22:57:17 thorpej Exp $"); | | 64 | __KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.168 2020/03/09 01:46:24 christos Exp $"); |
65 | | | 65 | |
66 | #ifdef _KERNEL_OPT | | 66 | #ifdef _KERNEL_OPT |
67 | #include "opt_aio.h" | | 67 | #include "opt_aio.h" |
68 | #include "opt_ddb.h" | | 68 | #include "opt_ddb.h" |
69 | #include "opt_kgdb.h" | | 69 | #include "opt_kgdb.h" |
70 | #include "opt_mqueue.h" | | 70 | #include "opt_mqueue.h" |
71 | #include "opt_inet.h" | | 71 | #include "opt_inet.h" |
72 | #include "opt_kernhist.h" | | 72 | #include "opt_kernhist.h" |
73 | #include "opt_ddbparam.h" | | 73 | #include "opt_ddbparam.h" |
74 | #include "opt_multiprocessor.h" | | 74 | #include "opt_multiprocessor.h" |
75 | #endif | | 75 | #endif |
76 | | | 76 | |
77 | #include <sys/param.h> | | 77 | #include <sys/param.h> |
| @@ -111,26 +111,31 @@ __KERNEL_RCSID(0, "$NetBSD: db_command.c | | | @@ -111,26 +111,31 @@ __KERNEL_RCSID(0, "$NetBSD: db_command.c |
111 | #define CMD_AMBIGUOUS 3 | | 111 | #define CMD_AMBIGUOUS 3 |
112 | | | 112 | |
113 | /* | | 113 | /* |
114 | * Exported global variables | | 114 | * Exported global variables |
115 | */ | | 115 | */ |
116 | bool db_cmd_loop_done; | | 116 | bool db_cmd_loop_done; |
117 | label_t *db_recover; | | 117 | label_t *db_recover; |
118 | db_addr_t db_dot; | | 118 | db_addr_t db_dot; |
119 | db_addr_t db_last_addr; | | 119 | db_addr_t db_last_addr; |
120 | db_addr_t db_prev; | | 120 | db_addr_t db_prev; |
121 | db_addr_t db_next; | | 121 | db_addr_t db_next; |
122 | | | 122 | |
123 | | | 123 | |
| | | 124 | #ifndef _KERNEL |
| | | 125 | #define db_kernelonly() \ |
| | | 126 | db_printf("%s: can only be used in-kernel.\n", __func__) |
| | | 127 | #endif |
| | | 128 | |
124 | /* | | 129 | /* |
125 | * New DDB api for adding and removing commands uses three lists, because | | 130 | * New DDB api for adding and removing commands uses three lists, because |
126 | * we use two types of commands | | 131 | * we use two types of commands |
127 | * a) standard commands without subcommands -> reboot | | 132 | * a) standard commands without subcommands -> reboot |
128 | * b) show commands which are subcommands of show command -> show aio_jobs | | 133 | * b) show commands which are subcommands of show command -> show aio_jobs |
129 | * c) if defined machine specific commands | | 134 | * c) if defined machine specific commands |
130 | * | | 135 | * |
131 | * ddb_add_cmd, ddb_rem_cmd use type (DDB_SHOW_CMD||DDB_BASE_CMD)argument to | | 136 | * ddb_add_cmd, ddb_rem_cmd use type (DDB_SHOW_CMD||DDB_BASE_CMD)argument to |
132 | * add them to representativ lists. | | 137 | * add them to representativ lists. |
133 | */ | | 138 | */ |
134 | | | 139 | |
135 | static const struct db_command db_command_table[]; | | 140 | static const struct db_command db_command_table[]; |
136 | static const struct db_command db_show_cmds[]; | | 141 | static const struct db_command db_show_cmds[]; |
| @@ -1002,83 +1007,93 @@ static void | | | @@ -1002,83 +1007,93 @@ static void |
1002 | db_map_print_cmd(db_expr_t addr, bool have_addr, db_expr_t count, | | 1007 | db_map_print_cmd(db_expr_t addr, bool have_addr, db_expr_t count, |
1003 | const char *modif) | | 1008 | const char *modif) |
1004 | { | | 1009 | { |
1005 | #ifdef _KERNEL | | 1010 | #ifdef _KERNEL |
1006 | bool full = false; | | 1011 | bool full = false; |
1007 | | | 1012 | |
1008 | if (modif[0] == 'f') | | 1013 | if (modif[0] == 'f') |
1009 | full = true; | | 1014 | full = true; |
1010 | | | 1015 | |
1011 | if (have_addr == false) | | 1016 | if (have_addr == false) |
1012 | addr = (db_expr_t)(uintptr_t)db_read_ptr("kernel_map"); | | 1017 | addr = (db_expr_t)(uintptr_t)db_read_ptr("kernel_map"); |
1013 | | | 1018 | |
1014 | uvm_map_printit((struct vm_map *)(uintptr_t) addr, full, db_printf); | | 1019 | uvm_map_printit((struct vm_map *)(uintptr_t) addr, full, db_printf); |
| | | 1020 | #else |
| | | 1021 | db_kernelonly(); |
1015 | #endif /* XXX CRASH(8) */ | | 1022 | #endif /* XXX CRASH(8) */ |
1016 | } | | 1023 | } |
1017 | | | 1024 | |
1018 | /*ARGSUSED*/ | | 1025 | /*ARGSUSED*/ |
1019 | static void | | 1026 | static void |
1020 | db_object_print_cmd(db_expr_t addr, bool have_addr, | | 1027 | db_object_print_cmd(db_expr_t addr, bool have_addr, |
1021 | db_expr_t count, const char *modif) | | 1028 | db_expr_t count, const char *modif) |
1022 | { | | 1029 | { |
1023 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1030 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1024 | bool full = false; | | 1031 | bool full = false; |
1025 | | | 1032 | |
1026 | if (modif[0] == 'f') | | 1033 | if (modif[0] == 'f') |
1027 | full = true; | | 1034 | full = true; |
1028 | | | 1035 | |
1029 | uvm_object_printit((struct uvm_object *)(uintptr_t) addr, full, | | 1036 | uvm_object_printit((struct uvm_object *)(uintptr_t) addr, full, |
1030 | db_printf); | | 1037 | db_printf); |
| | | 1038 | #else |
| | | 1039 | db_kernelonly(); |
1031 | #endif | | 1040 | #endif |
1032 | } | | 1041 | } |
1033 | | | 1042 | |
1034 | /*ARGSUSED*/ | | 1043 | /*ARGSUSED*/ |
1035 | static void | | 1044 | static void |
1036 | db_page_print_cmd(db_expr_t addr, bool have_addr, | | 1045 | db_page_print_cmd(db_expr_t addr, bool have_addr, |
1037 | db_expr_t count, const char *modif) | | 1046 | db_expr_t count, const char *modif) |
1038 | { | | 1047 | { |
1039 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1048 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1040 | bool full = false; | | 1049 | bool full = false; |
1041 | | | 1050 | |
1042 | if (modif[0] == 'f') | | 1051 | if (modif[0] == 'f') |
1043 | full = true; | | 1052 | full = true; |
1044 | | | 1053 | |
1045 | uvm_page_printit((struct vm_page *)(uintptr_t) addr, full, db_printf); | | 1054 | uvm_page_printit((struct vm_page *)(uintptr_t) addr, full, db_printf); |
| | | 1055 | #else |
| | | 1056 | db_kernelonly(); |
1046 | #endif | | 1057 | #endif |
1047 | } | | 1058 | } |
1048 | | | 1059 | |
1049 | /*ARGSUSED*/ | | 1060 | /*ARGSUSED*/ |
1050 | static void | | 1061 | static void |
1051 | db_show_all_pages(db_expr_t addr, bool have_addr, | | 1062 | db_show_all_pages(db_expr_t addr, bool have_addr, |
1052 | db_expr_t count, const char *modif) | | 1063 | db_expr_t count, const char *modif) |
1053 | { | | 1064 | { |
1054 | | | 1065 | |
1055 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1066 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1056 | uvm_page_printall(db_printf); | | 1067 | uvm_page_printall(db_printf); |
| | | 1068 | #else |
| | | 1069 | db_kernelonly(); |
1057 | #endif | | 1070 | #endif |
1058 | } | | 1071 | } |
1059 | | | 1072 | |
1060 | /*ARGSUSED*/ | | 1073 | /*ARGSUSED*/ |
1061 | static void | | 1074 | static void |
1062 | db_buf_print_cmd(db_expr_t addr, bool have_addr, | | 1075 | db_buf_print_cmd(db_expr_t addr, bool have_addr, |
1063 | db_expr_t count, const char *modif) | | 1076 | db_expr_t count, const char *modif) |
1064 | { | | 1077 | { |
1065 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1078 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1066 | bool full = false; | | 1079 | bool full = false; |
1067 | | | 1080 | |
1068 | if (modif[0] == 'f') | | 1081 | if (modif[0] == 'f') |
1069 | full = true; | | 1082 | full = true; |
1070 | | | 1083 | |
1071 | vfs_buf_print((struct buf *)(uintptr_t) addr, full, db_printf); | | 1084 | vfs_buf_print((struct buf *)(uintptr_t) addr, full, db_printf); |
| | | 1085 | #else |
| | | 1086 | db_kernelonly(); |
1072 | #endif | | 1087 | #endif |
1073 | } | | 1088 | } |
1074 | | | 1089 | |
1075 | /*ARGSUSED*/ | | 1090 | /*ARGSUSED*/ |
1076 | static void | | 1091 | static void |
1077 | db_event_print_cmd(db_expr_t addr, bool have_addr, | | 1092 | db_event_print_cmd(db_expr_t addr, bool have_addr, |
1078 | db_expr_t count, const char *modif) | | 1093 | db_expr_t count, const char *modif) |
1079 | { | | 1094 | { |
1080 | bool showzero = false; | | 1095 | bool showzero = false; |
1081 | bool showall = true; | | 1096 | bool showall = true; |
1082 | bool showintr = false; | | 1097 | bool showintr = false; |
1083 | bool showtrap = false; | | 1098 | bool showtrap = false; |
1084 | bool showmisc = false; | | 1099 | bool showmisc = false; |
| @@ -1132,52 +1147,58 @@ db_event_print_cmd(db_expr_t addr, bool | | | @@ -1132,52 +1147,58 @@ db_event_print_cmd(db_expr_t addr, bool |
1132 | | | 1147 | |
1133 | /*ARGSUSED*/ | | 1148 | /*ARGSUSED*/ |
1134 | static void | | 1149 | static void |
1135 | db_vnode_print_cmd(db_expr_t addr, bool have_addr, | | 1150 | db_vnode_print_cmd(db_expr_t addr, bool have_addr, |
1136 | db_expr_t count, const char *modif) | | 1151 | db_expr_t count, const char *modif) |
1137 | { | | 1152 | { |
1138 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1153 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1139 | bool full = false; | | 1154 | bool full = false; |
1140 | | | 1155 | |
1141 | if (modif[0] == 'f') | | 1156 | if (modif[0] == 'f') |
1142 | full = true; | | 1157 | full = true; |
1143 | | | 1158 | |
1144 | vfs_vnode_print((struct vnode *)(uintptr_t) addr, full, db_printf); | | 1159 | vfs_vnode_print((struct vnode *)(uintptr_t) addr, full, db_printf); |
| | | 1160 | #else |
| | | 1161 | db_kernelonly(); |
1145 | #endif | | 1162 | #endif |
1146 | } | | 1163 | } |
1147 | | | 1164 | |
1148 | /*ARGSUSED*/ | | 1165 | /*ARGSUSED*/ |
1149 | static void | | 1166 | static void |
1150 | db_vnode_lock_print_cmd(db_expr_t addr, bool have_addr, | | 1167 | db_vnode_lock_print_cmd(db_expr_t addr, bool have_addr, |
1151 | db_expr_t count, const char *modif) | | 1168 | db_expr_t count, const char *modif) |
1152 | { | | 1169 | { |
1153 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1170 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1154 | bool full = false; | | 1171 | bool full = false; |
1155 | | | 1172 | |
1156 | if (modif[0] == 'f') | | 1173 | if (modif[0] == 'f') |
1157 | full = true; | | 1174 | full = true; |
1158 | | | 1175 | |
1159 | vfs_vnode_lock_print((struct vnode *)(uintptr_t) addr, full, db_printf); | | 1176 | vfs_vnode_lock_print((struct vnode *)(uintptr_t) addr, full, db_printf); |
| | | 1177 | #else |
| | | 1178 | db_kernelonly(); |
1160 | #endif | | 1179 | #endif |
1161 | } | | 1180 | } |
1162 | | | 1181 | |
1163 | /*ARGSUSED*/ | | 1182 | /*ARGSUSED*/ |
1164 | static void | | 1183 | static void |
1165 | db_vmem_print_cmd(db_expr_t addr, bool have_addr, | | 1184 | db_vmem_print_cmd(db_expr_t addr, bool have_addr, |
1166 | db_expr_t count, const char *modif) | | 1185 | db_expr_t count, const char *modif) |
1167 | { | | 1186 | { |
1168 | | | 1187 | |
1169 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1188 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1170 | vmem_print((uintptr_t) addr, modif, db_printf); | | 1189 | vmem_print((uintptr_t) addr, modif, db_printf); |
| | | 1190 | #else |
| | | 1191 | db_kernelonly(); |
1171 | #endif | | 1192 | #endif |
1172 | } | | 1193 | } |
1173 | | | 1194 | |
1174 | static void | | 1195 | static void |
1175 | db_mount_print_cmd(db_expr_t addr, bool have_addr, | | 1196 | db_mount_print_cmd(db_expr_t addr, bool have_addr, |
1176 | db_expr_t count, const char *modif) | | 1197 | db_expr_t count, const char *modif) |
1177 | { | | 1198 | { |
1178 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1199 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1179 | bool full = false; | | 1200 | bool full = false; |
1180 | | | 1201 | |
1181 | if (modif[0] == 'f') | | 1202 | if (modif[0] == 'f') |
1182 | full = true; | | 1203 | full = true; |
1183 | | | 1204 | |
| @@ -1185,136 +1206,152 @@ db_mount_print_cmd(db_expr_t addr, bool | | | @@ -1185,136 +1206,152 @@ db_mount_print_cmd(db_expr_t addr, bool |
1185 | #endif | | 1206 | #endif |
1186 | } | | 1207 | } |
1187 | | | 1208 | |
1188 | static void | | 1209 | static void |
1189 | db_show_all_mount(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) | | 1210 | db_show_all_mount(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) |
1190 | { | | 1211 | { |
1191 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1212 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1192 | bool full = false; | | 1213 | bool full = false; |
1193 | | | 1214 | |
1194 | if (modif[0] == 'f') | | 1215 | if (modif[0] == 'f') |
1195 | full = true; | | 1216 | full = true; |
1196 | | | 1217 | |
1197 | vfs_mount_print_all(full, db_printf); | | 1218 | vfs_mount_print_all(full, db_printf); |
| | | 1219 | #else |
| | | 1220 | db_kernelonly(); |
1198 | #endif | | 1221 | #endif |
1199 | } | | 1222 | } |
1200 | | | 1223 | |
1201 | /*ARGSUSED*/ | | 1224 | /*ARGSUSED*/ |
1202 | static void | | 1225 | static void |
1203 | db_mbuf_print_cmd(db_expr_t addr, bool have_addr, | | 1226 | db_mbuf_print_cmd(db_expr_t addr, bool have_addr, |
1204 | db_expr_t count, const char *modif) | | 1227 | db_expr_t count, const char *modif) |
1205 | { | | 1228 | { |
1206 | | | 1229 | |
1207 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1230 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1208 | m_print((const struct mbuf *)(uintptr_t) addr, modif, db_printf); | | 1231 | m_print((const struct mbuf *)(uintptr_t) addr, modif, db_printf); |
| | | 1232 | #else |
| | | 1233 | db_kernelonly(); |
1209 | #endif | | 1234 | #endif |
1210 | } | | 1235 | } |
1211 | | | 1236 | |
1212 | /*ARGSUSED*/ | | 1237 | /*ARGSUSED*/ |
1213 | static void | | 1238 | static void |
1214 | db_pool_print_cmd(db_expr_t addr, bool have_addr, | | 1239 | db_pool_print_cmd(db_expr_t addr, bool have_addr, |
1215 | db_expr_t count, const char *modif) | | 1240 | db_expr_t count, const char *modif) |
1216 | { | | 1241 | { |
1217 | | | 1242 | |
1218 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1243 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1219 | pool_printit((struct pool *)(uintptr_t) addr, modif, db_printf); | | 1244 | pool_printit((struct pool *)(uintptr_t) addr, modif, db_printf); |
| | | 1245 | #else |
| | | 1246 | db_kernelonly(); |
1220 | #endif | | 1247 | #endif |
1221 | } | | 1248 | } |
1222 | | | 1249 | |
1223 | /*ARGSUSED*/ | | 1250 | /*ARGSUSED*/ |
1224 | static void | | 1251 | static void |
1225 | db_namecache_print_cmd(db_expr_t addr, bool have_addr, | | 1252 | db_namecache_print_cmd(db_expr_t addr, bool have_addr, |
1226 | db_expr_t count, const char *modif) | | 1253 | db_expr_t count, const char *modif) |
1227 | { | | 1254 | { |
1228 | | | 1255 | |
1229 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1256 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1230 | namecache_print((struct vnode *)(uintptr_t) addr, db_printf); | | 1257 | namecache_print((struct vnode *)(uintptr_t) addr, db_printf); |
| | | 1258 | #else |
| | | 1259 | db_kernelonly(); |
1231 | #endif | | 1260 | #endif |
1232 | } | | 1261 | } |
1233 | | | 1262 | |
1234 | /*ARGSUSED*/ | | 1263 | /*ARGSUSED*/ |
1235 | static void | | 1264 | static void |
1236 | db_uvmexp_print_cmd(db_expr_t addr, bool have_addr, | | 1265 | db_uvmexp_print_cmd(db_expr_t addr, bool have_addr, |
1237 | db_expr_t count, const char *modif) | | 1266 | db_expr_t count, const char *modif) |
1238 | { | | 1267 | { |
1239 | | | 1268 | |
1240 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1269 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1241 | uvmexp_print(db_printf); | | 1270 | uvmexp_print(db_printf); |
| | | 1271 | #else |
| | | 1272 | db_kernelonly(); |
1242 | #endif | | 1273 | #endif |
1243 | } | | 1274 | } |
1244 | | | 1275 | |
1245 | /*ARGSUSED */ | | 1276 | /*ARGSUSED */ |
1246 | static void | | 1277 | static void |
1247 | db_socket_print_cmd(db_expr_t addr, bool have_addr, db_expr_t count, | | 1278 | db_socket_print_cmd(db_expr_t addr, bool have_addr, db_expr_t count, |
1248 | const char *modif) | | 1279 | const char *modif) |
1249 | { | | 1280 | { |
1250 | | | 1281 | |
1251 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1282 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1252 | socket_print(modif, db_printf); | | 1283 | socket_print(modif, db_printf); |
| | | 1284 | #else |
| | | 1285 | db_kernelonly(); |
1253 | #endif | | 1286 | #endif |
1254 | } | | 1287 | } |
1255 | | | 1288 | |
1256 | #ifdef KERNHIST | | 1289 | #ifdef KERNHIST |
1257 | /*ARGSUSED*/ | | 1290 | /*ARGSUSED*/ |
1258 | static void | | 1291 | static void |
1259 | db_kernhist_print_cmd(db_expr_t addr, bool have_addr, | | 1292 | db_kernhist_print_cmd(db_expr_t addr, bool have_addr, |
1260 | db_expr_t count, const char *modif) | | 1293 | db_expr_t count, const char *modif) |
1261 | { | | 1294 | { |
1262 | | | 1295 | |
1263 | if (!have_addr) | | 1296 | if (!have_addr) |
1264 | addr = 0; | | 1297 | addr = 0; |
1265 | kernhist_print((void *)(uintptr_t)addr, count, modif, db_printf); | | 1298 | kernhist_print((void *)(uintptr_t)addr, count, modif, db_printf); |
1266 | } | | 1299 | } |
1267 | #endif | | 1300 | #endif |
1268 | | | 1301 | |
1269 | /*ARGSUSED*/ | | 1302 | /*ARGSUSED*/ |
1270 | static void | | 1303 | static void |
1271 | db_lock_print_cmd(db_expr_t addr, bool have_addr, | | 1304 | db_lock_print_cmd(db_expr_t addr, bool have_addr, |
1272 | db_expr_t count, const char *modif) | | 1305 | db_expr_t count, const char *modif) |
1273 | { | | 1306 | { |
1274 | | | 1307 | |
1275 | #ifdef _KERNEL /* XXX CRASH(8) */ | | | |
1276 | lockdebug_lock_print(have_addr ? (void *)(uintptr_t)addr : NULL, | | 1308 | lockdebug_lock_print(have_addr ? (void *)(uintptr_t)addr : NULL, |
1277 | db_printf); | | 1309 | db_printf); |
1278 | #endif | | | |
1279 | } | | 1310 | } |
1280 | | | 1311 | |
1281 | static void | | 1312 | static void |
1282 | db_show_all_locks(db_expr_t addr, bool have_addr, | | 1313 | db_show_all_locks(db_expr_t addr, bool have_addr, |
1283 | db_expr_t count, const char *modif) | | 1314 | db_expr_t count, const char *modif) |
1284 | { | | 1315 | { |
1285 | | | 1316 | |
1286 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1317 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1287 | lockdebug_show_all_locks(db_printf, modif); | | 1318 | lockdebug_show_all_locks(db_printf, modif); |
| | | 1319 | #else |
| | | 1320 | db_kernelonly(); |
1288 | #endif | | 1321 | #endif |
1289 | } | | 1322 | } |
1290 | | | 1323 | |
1291 | static void | | 1324 | static void |
1292 | db_show_all_freelists(db_expr_t addr, bool have_addr, | | 1325 | db_show_all_freelists(db_expr_t addr, bool have_addr, |
1293 | db_expr_t count, const char *modif) | | 1326 | db_expr_t count, const char *modif) |
1294 | { | | 1327 | { |
1295 | | | 1328 | |
1296 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1329 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1297 | uvm_page_print_freelists(db_printf); | | 1330 | uvm_page_print_freelists(db_printf); |
| | | 1331 | #else |
| | | 1332 | db_kernelonly(); |
1298 | #endif | | 1333 | #endif |
1299 | } | | 1334 | } |
1300 | | | 1335 | |
1301 | static void | | 1336 | static void |
1302 | db_show_lockstats(db_expr_t addr, bool have_addr, | | 1337 | db_show_lockstats(db_expr_t addr, bool have_addr, |
1303 | db_expr_t count, const char *modif) | | 1338 | db_expr_t count, const char *modif) |
1304 | { | | 1339 | { |
1305 | | | 1340 | |
1306 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1341 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1307 | lockdebug_show_lockstats(db_printf); | | 1342 | lockdebug_show_lockstats(db_printf); |
| | | 1343 | #else |
| | | 1344 | db_kernelonly(); |
1308 | #endif | | 1345 | #endif |
1309 | } | | 1346 | } |
1310 | | | 1347 | |
1311 | /* | | 1348 | /* |
1312 | * Call random function: | | 1349 | * Call random function: |
1313 | * !expr(arg,arg,arg) | | 1350 | * !expr(arg,arg,arg) |
1314 | */ | | 1351 | */ |
1315 | /*ARGSUSED*/ | | 1352 | /*ARGSUSED*/ |
1316 | static void | | 1353 | static void |
1317 | db_fncall(db_expr_t addr, bool have_addr, | | 1354 | db_fncall(db_expr_t addr, bool have_addr, |
1318 | db_expr_t count, const char *modif) | | 1355 | db_expr_t count, const char *modif) |
1319 | { | | 1356 | { |
1320 | #ifdef _KERNEL | | 1357 | #ifdef _KERNEL |
| @@ -1358,27 +1395,27 @@ db_fncall(db_expr_t addr, bool have_addr | | | @@ -1358,27 +1395,27 @@ db_fncall(db_expr_t addr, bool have_addr |
1358 | return; | | 1395 | return; |
1359 | } | | 1396 | } |
1360 | } | | 1397 | } |
1361 | db_skip_to_eol(); | | 1398 | db_skip_to_eol(); |
1362 | | | 1399 | |
1363 | while (nargs < MAXARGS) { | | 1400 | while (nargs < MAXARGS) { |
1364 | args[nargs++] = 0; | | 1401 | args[nargs++] = 0; |
1365 | } | | 1402 | } |
1366 | | | 1403 | |
1367 | retval = (*func)(args[0], args[1], args[2], args[3], args[4], | | 1404 | retval = (*func)(args[0], args[1], args[2], args[3], args[4], |
1368 | args[5], args[6], args[7], args[8], args[9]); | | 1405 | args[5], args[6], args[7], args[8], args[9]); |
1369 | db_printf("%s\n", db_num_to_str(retval)); | | 1406 | db_printf("%s\n", db_num_to_str(retval)); |
1370 | #else /* _KERNEL */ | | 1407 | #else /* _KERNEL */ |
1371 | db_printf("This command can only be used in-kernel.\n"); | | 1408 | db_kernelonly(); |
1372 | #endif /* _KERNEL */ | | 1409 | #endif /* _KERNEL */ |
1373 | } | | 1410 | } |
1374 | | | 1411 | |
1375 | static void | | 1412 | static void |
1376 | db_reboot_cmd(db_expr_t addr, bool have_addr, | | 1413 | db_reboot_cmd(db_expr_t addr, bool have_addr, |
1377 | db_expr_t count, const char *modif) | | 1414 | db_expr_t count, const char *modif) |
1378 | { | | 1415 | { |
1379 | #ifdef _KERNEL | | 1416 | #ifdef _KERNEL |
1380 | db_expr_t bootflags; | | 1417 | db_expr_t bootflags; |
1381 | | | 1418 | |
1382 | /* Flags, default to RB_AUTOBOOT */ | | 1419 | /* Flags, default to RB_AUTOBOOT */ |
1383 | if (!db_expression(&bootflags)) | | 1420 | if (!db_expression(&bootflags)) |
1384 | bootflags = (db_expr_t)RB_AUTOBOOT; | | 1421 | bootflags = (db_expr_t)RB_AUTOBOOT; |
| @@ -1389,27 +1426,27 @@ db_reboot_cmd(db_expr_t addr, bool have_ | | | @@ -1389,27 +1426,27 @@ db_reboot_cmd(db_expr_t addr, bool have_ |
1389 | /* | | 1426 | /* |
1390 | * We are leaving DDB, never to return upward. | | 1427 | * We are leaving DDB, never to return upward. |
1391 | * Clear db_recover so that we can debug faults in functions | | 1428 | * Clear db_recover so that we can debug faults in functions |
1392 | * called from cpu_reboot. | | 1429 | * called from cpu_reboot. |
1393 | */ | | 1430 | */ |
1394 | db_recover = 0; | | 1431 | db_recover = 0; |
1395 | /* Avoid all mutex errors */ | | 1432 | /* Avoid all mutex errors */ |
1396 | lockdebug_dismiss(); | | 1433 | lockdebug_dismiss(); |
1397 | panicstr = "reboot forced via kernel debugger"; | | 1434 | panicstr = "reboot forced via kernel debugger"; |
1398 | /* Make it possible to break into the debugger again */ | | 1435 | /* Make it possible to break into the debugger again */ |
1399 | spl0(); | | 1436 | spl0(); |
1400 | kern_reboot((int)bootflags, NULL); | | 1437 | kern_reboot((int)bootflags, NULL); |
1401 | #else /* _KERNEL */ | | 1438 | #else /* _KERNEL */ |
1402 | db_printf("This command can only be used in-kernel.\n"); | | 1439 | db_kernelonly(); |
1403 | #endif /* _KERNEL */ | | 1440 | #endif /* _KERNEL */ |
1404 | } | | 1441 | } |
1405 | | | 1442 | |
1406 | static void | | 1443 | static void |
1407 | db_sifting_cmd(db_expr_t addr, bool have_addr, | | 1444 | db_sifting_cmd(db_expr_t addr, bool have_addr, |
1408 | db_expr_t count, const char *modif) | | 1445 | db_expr_t count, const char *modif) |
1409 | { | | 1446 | { |
1410 | int mode, t; | | 1447 | int mode, t; |
1411 | | | 1448 | |
1412 | t = db_read_token(); | | 1449 | t = db_read_token(); |
1413 | if (t == tSLASH) { | | 1450 | if (t == tSLASH) { |
1414 | t = db_read_token(); | | 1451 | t = db_read_token(); |
1415 | if (t != tIDENT) { | | 1452 | if (t != tIDENT) { |
| @@ -1456,34 +1493,36 @@ static void | | | @@ -1456,34 +1493,36 @@ static void |
1456 | db_sync_cmd(db_expr_t addr, bool have_addr, | | 1493 | db_sync_cmd(db_expr_t addr, bool have_addr, |
1457 | db_expr_t count, const char *modif) | | 1494 | db_expr_t count, const char *modif) |
1458 | { | | 1495 | { |
1459 | #ifdef _KERNEL | | 1496 | #ifdef _KERNEL |
1460 | /* | | 1497 | /* |
1461 | * We are leaving DDB, never to return upward. | | 1498 | * We are leaving DDB, never to return upward. |
1462 | * Clear db_recover so that we can debug faults in functions | | 1499 | * Clear db_recover so that we can debug faults in functions |
1463 | * called from cpu_reboot. | | 1500 | * called from cpu_reboot. |
1464 | */ | | 1501 | */ |
1465 | db_recover = 0; | | 1502 | db_recover = 0; |
1466 | panicstr = "dump forced via kernel debugger"; | | 1503 | panicstr = "dump forced via kernel debugger"; |
1467 | kern_reboot(RB_DUMP, NULL); | | 1504 | kern_reboot(RB_DUMP, NULL); |
1468 | #else /* _KERNEL */ | | 1505 | #else /* _KERNEL */ |
1469 | db_printf("This command can only be used in-kernel.\n"); | | 1506 | db_kernelonly(); |
1470 | #endif /* _KERNEL */ | | 1507 | #endif /* _KERNEL */ |
1471 | } | | 1508 | } |
1472 | | | 1509 | |
1473 | /* | | 1510 | /* |
1474 | * Describe what an address is | | 1511 | * Describe what an address is |
1475 | */ | | 1512 | */ |
1476 | void | | 1513 | void |
1477 | db_whatis_cmd(db_expr_t address, bool have_addr, | | 1514 | db_whatis_cmd(db_expr_t address, bool have_addr, |
1478 | db_expr_t count, const char *modif) | | 1515 | db_expr_t count, const char *modif) |
1479 | { | | 1516 | { |
1480 | const uintptr_t addr = (uintptr_t)address; | | 1517 | const uintptr_t addr = (uintptr_t)address; |
1481 | | | 1518 | |
1482 | db_lwp_whatis(addr, db_printf); | | 1519 | db_lwp_whatis(addr, db_printf); |
1483 | #ifdef _KERNEL /* XXX CRASH(8) */ | | 1520 | #ifdef _KERNEL /* XXX CRASH(8) */ |
1484 | pool_whatis(addr, db_printf); | | 1521 | pool_whatis(addr, db_printf); |
1485 | vmem_whatis(addr, db_printf); | | 1522 | vmem_whatis(addr, db_printf); |
1486 | uvm_whatis(addr, db_printf); | | 1523 | uvm_whatis(addr, db_printf); |
1487 | module_whatis(addr, db_printf); | | 1524 | module_whatis(addr, db_printf); |
| | | 1525 | #else |
| | | 1526 | db_kernelonly(); |
1488 | #endif | | 1527 | #endif |
1489 | } | | 1528 | } |