db_command.c revision 1.82 1 /* $NetBSD: db_command.c,v 1.82 2005/12/01 13:21:05 yamt Exp $ */
2
3 /*
4 * Mach Operating System
5 * Copyright (c) 1991,1990 Carnegie Mellon University
6 * All Rights Reserved.
7 *
8 * Permission to use, copy, modify and distribute this software and its
9 * documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation.
13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
16 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 *
18 * Carnegie Mellon requests users of this software to return to
19 *
20 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
24 *
25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes.
27 */
28
29 /*
30 * Command dispatcher.
31 */
32
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.82 2005/12/01 13:21:05 yamt Exp $");
35
36 #include "opt_ddb.h"
37 #include "opt_kgdb.h"
38 #include "opt_inet.h"
39 #include "opt_ddbparam.h"
40
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/reboot.h>
44 #include <sys/device.h>
45 #include <sys/malloc.h>
46 #include <sys/namei.h>
47 #include <sys/pool.h>
48 #include <sys/proc.h>
49 #include <sys/vnode.h>
50
51 #include <machine/db_machdep.h> /* type definitions */
52
53 #if defined(_KERNEL_OPT)
54 #include "opt_multiprocessor.h"
55 #endif
56 #ifdef MULTIPROCESSOR
57 #include <machine/cpu.h>
58 #endif
59
60 #include <ddb/db_lex.h>
61 #include <ddb/db_output.h>
62 #include <ddb/db_command.h>
63 #include <ddb/db_break.h>
64 #include <ddb/db_watch.h>
65 #include <ddb/db_run.h>
66 #include <ddb/db_variables.h>
67 #include <ddb/db_interface.h>
68 #include <ddb/db_sym.h>
69 #include <ddb/db_extern.h>
70
71 #include <uvm/uvm_extern.h>
72 #include <uvm/uvm_ddb.h>
73
74 #include "arp.h"
75
76 /*
77 * Results of command search.
78 */
79 #define CMD_UNIQUE 0
80 #define CMD_FOUND 1
81 #define CMD_NONE 2
82 #define CMD_AMBIGUOUS 3
83 #define CMD_HELP 4
84
85 /*
86 * Exported global variables
87 */
88 boolean_t db_cmd_loop_done;
89 label_t *db_recover;
90 db_addr_t db_dot;
91 db_addr_t db_last_addr;
92 db_addr_t db_prev;
93 db_addr_t db_next;
94
95 /*
96 * if 'ed' style: 'dot' is set at start of last item printed,
97 * and '+' points to next line.
98 * Otherwise: 'dot' points to next item, '..' points to last.
99 */
100 static boolean_t db_ed_style = TRUE;
101
102 static void db_buf_print_cmd(db_expr_t, int, db_expr_t, const char *);
103 static void db_cmd_list(const struct db_command *);
104 static int db_cmd_search(const char *, const struct db_command *,
105 const struct db_command **);
106 static void db_command(const struct db_command **,
107 const struct db_command *);
108 static void db_event_print_cmd(db_expr_t, int, db_expr_t, const char *);
109 static void db_fncall(db_expr_t, int, db_expr_t, const char *);
110 static void db_malloc_print_cmd(db_expr_t, int, db_expr_t, const char *);
111 static void db_map_print_cmd(db_expr_t, int, db_expr_t, const char *);
112 static void db_namecache_print_cmd(db_expr_t, int, db_expr_t, const char *);
113 static void db_object_print_cmd(db_expr_t, int, db_expr_t, const char *);
114 static void db_page_print_cmd(db_expr_t, int, db_expr_t, const char *);
115 static void db_pool_print_cmd(db_expr_t, int, db_expr_t, const char *);
116 static void db_reboot_cmd(db_expr_t, int, db_expr_t, const char *);
117 static void db_sifting_cmd(db_expr_t, int, db_expr_t, const char *);
118 static void db_stack_trace_cmd(db_expr_t, int, db_expr_t, const char *);
119 static void db_sync_cmd(db_expr_t, int, db_expr_t, const char *);
120 static void db_uvmexp_print_cmd(db_expr_t, int, db_expr_t, const char *);
121 static void db_vnode_print_cmd(db_expr_t, int, db_expr_t, const char *);
122 static void db_mount_print_cmd(db_expr_t, int, db_expr_t, const char *);
123
124 /*
125 * 'show' commands
126 */
127
128 static const struct db_command db_show_all_cmds[] = {
129 { "callout", db_show_callout, 0, NULL },
130 { "procs", db_show_all_procs, 0, NULL },
131 { "pools", db_show_all_pools, 0, NULL },
132 { NULL, NULL, 0, NULL }
133 };
134
135 static const struct db_command db_show_cmds[] = {
136 { "all", NULL, 0, db_show_all_cmds },
137 #if defined(INET) && (NARP > 0)
138 { "arptab", db_show_arptab, 0, NULL },
139 #endif
140 { "breaks", db_listbreak_cmd, 0, NULL },
141 { "buf", db_buf_print_cmd, 0, NULL },
142 { "event", db_event_print_cmd, 0, NULL },
143 { "malloc", db_malloc_print_cmd, 0, NULL },
144 { "map", db_map_print_cmd, 0, NULL },
145 { "mount", db_mount_print_cmd, 0, NULL },
146 { "ncache", db_namecache_print_cmd, 0, NULL },
147 { "object", db_object_print_cmd, 0, NULL },
148 { "page", db_page_print_cmd, 0, NULL },
149 { "pool", db_pool_print_cmd, 0, NULL },
150 { "registers", db_show_regs, 0, NULL },
151 { "sched_qs", db_show_sched_qs, 0, NULL },
152 { "uvmexp", db_uvmexp_print_cmd, 0, NULL },
153 { "vnode", db_vnode_print_cmd, 0, NULL },
154 { "watches", db_listwatch_cmd, 0, NULL },
155 { NULL, NULL, 0, NULL }
156 };
157
158 /* arch/<arch>/<arch>/db_interface.c */
159 #ifdef DB_MACHINE_COMMANDS
160 extern const struct db_command db_machine_command_table[];
161 #endif
162
163 static const struct db_command db_command_table[] = {
164 { "b", db_breakpoint_cmd, 0, NULL },
165 { "break", db_breakpoint_cmd, 0, NULL },
166 { "bt", db_stack_trace_cmd, 0, NULL },
167 { "c", db_continue_cmd, 0, NULL },
168 { "call", db_fncall, CS_OWN, NULL },
169 { "callout", db_show_callout, 0, NULL },
170 { "continue", db_continue_cmd, 0, NULL },
171 { "d", db_delete_cmd, 0, NULL },
172 { "delete", db_delete_cmd, 0, NULL },
173 { "dmesg", db_dmesg, 0, NULL },
174 { "dwatch", db_deletewatch_cmd, 0, NULL },
175 { "examine", db_examine_cmd, CS_SET_DOT, NULL },
176 { "kill", db_kill_proc, CS_OWN, NULL },
177 #ifdef KGDB
178 { "kgdb", db_kgdb_cmd, 0, NULL },
179 #endif
180 #ifdef DB_MACHINE_COMMANDS
181 { "machine", NULL, 0, db_machine_command_table },
182 #endif
183 { "match", db_trace_until_matching_cmd,0, NULL },
184 { "next", db_trace_until_matching_cmd,0, NULL },
185 { "p", db_print_cmd, 0, NULL },
186 { "print", db_print_cmd, 0, NULL },
187 { "ps", db_show_all_procs, 0, NULL },
188 { "reboot", db_reboot_cmd, CS_OWN, NULL },
189 { "s", db_single_step_cmd, 0, NULL },
190 { "search", db_search_cmd, CS_OWN|CS_SET_DOT, NULL },
191 { "set", db_set_cmd, CS_OWN, NULL },
192 { "show", NULL, 0, db_show_cmds },
193 { "sifting", db_sifting_cmd, CS_OWN, NULL },
194 { "step", db_single_step_cmd, 0, NULL },
195 { "sync", db_sync_cmd, CS_OWN, NULL },
196 { "trace", db_stack_trace_cmd, 0, NULL },
197 { "until", db_trace_until_call_cmd,0, NULL },
198 { "w", db_write_cmd, CS_MORE|CS_SET_DOT, NULL },
199 { "watch", db_watchpoint_cmd, CS_MORE, NULL },
200 { "write", db_write_cmd, CS_MORE|CS_SET_DOT, NULL },
201 { "x", db_examine_cmd, CS_SET_DOT, NULL },
202 { NULL, NULL, 0, NULL }
203 };
204
205 static const struct db_command *db_last_command = NULL;
206 #if defined(DDB_COMMANDONENTER)
207 char db_cmd_on_enter[DB_LINE_MAXLEN + 1] = ___STRING(DDB_COMMANDONENTER);
208 #else /* defined(DDB_COMMANDONENTER) */
209 char db_cmd_on_enter[DB_LINE_MAXLEN + 1] = "";
210 #endif /* defined(DDB_COMMANDONENTER) */
211 #define DB_LINE_SEP ';'
212
213 /*
214 * Utility routine - discard tokens through end-of-line.
215 */
216 void
217 db_skip_to_eol(void)
218 {
219 int t;
220
221 do {
222 t = db_read_token();
223 } while (t != tEOL);
224 }
225
226 void
227 db_error(s)
228 const char *s;
229 {
230
231 if (s)
232 db_printf("%s", s);
233 db_flush_lex();
234 longjmp(db_recover);
235 }
236
237 static void
238 db_execute_commandlist(const char *cmdlist)
239 {
240 const char *cmd = cmdlist;
241 const struct db_command *dummy = NULL;
242
243 while (*cmd != '\0') {
244 const char *ep = cmd;
245
246 while (*ep != '\0' && *ep != DB_LINE_SEP) {
247 ep++;
248 }
249 db_set_line(cmd, ep);
250 db_command(&dummy, db_command_table);
251 cmd = ep;
252 if (*cmd == DB_LINE_SEP) {
253 cmd++;
254 }
255 }
256 }
257
258 void
259 db_command_loop(void)
260 {
261 label_t db_jmpbuf;
262 label_t *savejmp;
263
264 /*
265 * Initialize 'prev' and 'next' to dot.
266 */
267 db_prev = db_dot;
268 db_next = db_dot;
269
270 db_cmd_loop_done = 0;
271
272 savejmp = db_recover;
273 db_recover = &db_jmpbuf;
274 (void) setjmp(&db_jmpbuf);
275
276 db_execute_commandlist(db_cmd_on_enter);
277
278 while (!db_cmd_loop_done) {
279 if (db_print_position() != 0)
280 db_printf("\n");
281 db_output_line = 0;
282
283
284 #ifdef MULTIPROCESSOR
285 db_printf("db{%ld}> ", (long)cpu_number());
286 #else
287 db_printf("db> ");
288 #endif
289 (void) db_read_line();
290
291 db_command(&db_last_command, db_command_table);
292 }
293
294 db_recover = savejmp;
295 }
296
297 /*
298 * Search for command prefix.
299 */
300 static int
301 db_cmd_search(const char *name, const struct db_command *table,
302 const struct db_command **cmdp)
303 {
304 const struct db_command *cmd;
305 int result = CMD_NONE;
306
307 for (cmd = table; cmd->name != 0; cmd++) {
308 const char *lp;
309 const char *rp;
310 int c;
311
312 lp = name;
313 rp = cmd->name;
314 while ((c = *lp) == *rp) {
315 if (c == 0) {
316 /* complete match */
317 *cmdp = cmd;
318 return (CMD_UNIQUE);
319 }
320 lp++;
321 rp++;
322 }
323 if (c == 0) {
324 /* end of name, not end of command -
325 partial match */
326 if (result == CMD_FOUND) {
327 result = CMD_AMBIGUOUS;
328 /* but keep looking for a full match -
329 this lets us match single letters */
330 } else {
331 *cmdp = cmd;
332 result = CMD_FOUND;
333 }
334 }
335 }
336 if (result == CMD_NONE) {
337 /* check for 'help' */
338 if (name[0] == 'h' && name[1] == 'e'
339 && name[2] == 'l' && name[3] == 'p')
340 result = CMD_HELP;
341 }
342 return (result);
343 }
344
345 static void
346 db_cmd_list(const struct db_command *table)
347 {
348 int i, j, w, columns, lines, width=0, numcmds;
349 const char *p;
350
351 for (numcmds = 0; table[numcmds].name != NULL; numcmds++) {
352 w = strlen(table[numcmds].name);
353 if (w > width)
354 width = w;
355 }
356 width = DB_NEXT_TAB(width);
357
358 columns = db_max_width / width;
359 if (columns == 0)
360 columns = 1;
361 lines = (numcmds + columns - 1) / columns;
362 for (i = 0; i < lines; i++) {
363 for (j = 0; j < columns; j++) {
364 p = table[j * lines + i].name;
365 if (p)
366 db_printf("%s", p);
367 if (j * lines + i + lines >= numcmds) {
368 db_putchar('\n');
369 break;
370 }
371 w = strlen(p);
372 while (w < width) {
373 w = DB_NEXT_TAB(w);
374 db_putchar('\t');
375 }
376 }
377 }
378 }
379
380 static void
381 db_command(const struct db_command **last_cmdp,
382 const struct db_command *cmd_table)
383 {
384 const struct db_command *cmd;
385 int t;
386 char modif[TOK_STRING_SIZE];
387 db_expr_t addr, count;
388 boolean_t have_addr = FALSE;
389 int result;
390
391 static db_expr_t last_count = 0;
392
393 t = db_read_token();
394 if ((t == tEOL) || (t == tCOMMA)) {
395 /*
396 * An empty line repeats last command, at 'next'.
397 * Only a count repeats the last command with the new count.
398 */
399 cmd = *last_cmdp;
400 addr = (db_expr_t)db_next;
401 if (t == tCOMMA) {
402 if (!db_expression(&count)) {
403 db_printf("Count missing\n");
404 db_flush_lex();
405 return;
406 }
407 } else
408 count = last_count;
409 have_addr = FALSE;
410 modif[0] = '\0';
411 db_skip_to_eol();
412 } else if (t == tEXCL) {
413 db_fncall(0, 0, 0, NULL);
414 return;
415 } else if (t != tIDENT) {
416 db_printf("?\n");
417 db_flush_lex();
418 return;
419 } else {
420 /*
421 * Search for command
422 */
423 while (cmd_table) {
424 result = db_cmd_search(db_tok_string, cmd_table, &cmd);
425 switch (result) {
426 case CMD_NONE:
427 db_printf("No such command\n");
428 db_flush_lex();
429 return;
430 case CMD_AMBIGUOUS:
431 db_printf("Ambiguous\n");
432 db_flush_lex();
433 return;
434 case CMD_HELP:
435 db_cmd_list(cmd_table);
436 db_flush_lex();
437 return;
438 default:
439 break;
440 }
441 if ((cmd_table = cmd->more) != 0) {
442 t = db_read_token();
443 if (t != tIDENT) {
444 db_cmd_list(cmd_table);
445 db_flush_lex();
446 return;
447 }
448 }
449 }
450
451 if ((cmd->flag & CS_OWN) == 0) {
452 /*
453 * Standard syntax:
454 * command [/modifier] [addr] [,count]
455 */
456 t = db_read_token();
457 if (t == tSLASH) {
458 t = db_read_token();
459 if (t != tIDENT) {
460 db_printf("Bad modifier\n");
461 db_flush_lex();
462 return;
463 }
464 strlcpy(modif, db_tok_string, sizeof(modif));
465 } else {
466 db_unread_token(t);
467 modif[0] = '\0';
468 }
469
470 if (db_expression(&addr)) {
471 db_dot = (db_addr_t) addr;
472 db_last_addr = db_dot;
473 have_addr = TRUE;
474 } else {
475 addr = (db_expr_t) db_dot;
476 have_addr = FALSE;
477 }
478 t = db_read_token();
479 if (t == tCOMMA) {
480 if (!db_expression(&count)) {
481 db_printf("Count missing\n");
482 db_flush_lex();
483 return;
484 }
485 } else {
486 db_unread_token(t);
487 count = -1;
488 }
489 if ((cmd->flag & CS_MORE) == 0) {
490 db_skip_to_eol();
491 }
492 }
493 }
494 *last_cmdp = cmd;
495 last_count = count;
496 if (cmd != 0) {
497 /*
498 * Execute the command.
499 */
500 (*cmd->fcn)(addr, have_addr, count, modif);
501
502 if (cmd->flag & CS_SET_DOT) {
503 /*
504 * If command changes dot, set dot to
505 * previous address displayed (if 'ed' style).
506 */
507 if (db_ed_style)
508 db_dot = db_prev;
509 else
510 db_dot = db_next;
511 } else {
512 /*
513 * If command does not change dot,
514 * set 'next' location to be the same.
515 */
516 db_next = db_dot;
517 }
518 }
519 }
520
521 /*ARGSUSED*/
522 static void
523 db_map_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
524 {
525 boolean_t full = FALSE;
526
527 if (modif[0] == 'f')
528 full = TRUE;
529
530 if (have_addr == FALSE)
531 addr = (db_expr_t)(intptr_t) kernel_map;
532
533 uvm_map_printit((struct vm_map *)(intptr_t) addr, full, db_printf);
534 }
535
536 /*ARGSUSED*/
537 static void
538 db_malloc_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
539 {
540
541 #ifdef MALLOC_DEBUG
542 if (!have_addr)
543 addr = 0;
544
545 debug_malloc_printit(db_printf, (vaddr_t) addr);
546 #else
547 db_printf("The kernel is not built with the MALLOC_DEBUG option.\n");
548 #endif /* MALLOC_DEBUG */
549 }
550
551 /*ARGSUSED*/
552 static void
553 db_object_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
554 {
555 boolean_t full = FALSE;
556
557 if (modif[0] == 'f')
558 full = TRUE;
559
560 uvm_object_printit((struct uvm_object *)(intptr_t) addr, full,
561 db_printf);
562 }
563
564 /*ARGSUSED*/
565 static void
566 db_page_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
567 {
568 boolean_t full = FALSE;
569
570 if (modif[0] == 'f')
571 full = TRUE;
572
573 uvm_page_printit((struct vm_page *)(intptr_t) addr, full, db_printf);
574 }
575
576 /*ARGSUSED*/
577 static void
578 db_buf_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
579 {
580 boolean_t full = FALSE;
581
582 if (modif[0] == 'f')
583 full = TRUE;
584
585 vfs_buf_print((struct buf *)(intptr_t) addr, full, db_printf);
586 }
587
588 /*ARGSUSED*/
589 static void
590 db_event_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
591 {
592 boolean_t full = FALSE;
593
594 if (modif[0] == 'f')
595 full = TRUE;
596
597 event_print(full, db_printf);
598 }
599
600 /*ARGSUSED*/
601 static void
602 db_vnode_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
603 {
604 boolean_t full = FALSE;
605
606 if (modif[0] == 'f')
607 full = TRUE;
608
609 vfs_vnode_print((struct vnode *)(intptr_t) addr, full, db_printf);
610 }
611
612 static void
613 db_mount_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
614 {
615 boolean_t full = FALSE;
616
617 if (modif[0] == 'f')
618 full = TRUE;
619
620 vfs_mount_print((struct mount *)(intptr_t) addr, full, db_printf);
621 }
622
623 /*ARGSUSED*/
624 static void
625 db_pool_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
626 {
627
628 pool_printit((struct pool *)(intptr_t) addr, modif, db_printf);
629 }
630
631 /*ARGSUSED*/
632 static void
633 db_namecache_print_cmd(db_expr_t addr, int have_addr, db_expr_t count,
634 const char *modif)
635 {
636
637 namecache_print((struct vnode *)(intptr_t) addr, db_printf);
638 }
639
640 /*ARGSUSED*/
641 static void
642 db_uvmexp_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
643 {
644
645 uvmexp_print(db_printf);
646 }
647
648 /*
649 * Call random function:
650 * !expr(arg,arg,arg)
651 */
652 /*ARGSUSED*/
653 static void
654 db_fncall(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
655 {
656 db_expr_t fn_addr;
657 #define MAXARGS 11
658 db_expr_t args[MAXARGS];
659 int nargs = 0;
660 db_expr_t retval;
661 db_expr_t (*func)(db_expr_t, ...);
662 int t;
663
664 if (!db_expression(&fn_addr)) {
665 db_printf("Bad function\n");
666 db_flush_lex();
667 return;
668 }
669 func = (db_expr_t (*)(db_expr_t, ...))(intptr_t) fn_addr;
670
671 t = db_read_token();
672 if (t == tLPAREN) {
673 if (db_expression(&args[0])) {
674 nargs++;
675 while ((t = db_read_token()) == tCOMMA) {
676 if (nargs == MAXARGS) {
677 db_printf("Too many arguments\n");
678 db_flush_lex();
679 return;
680 }
681 if (!db_expression(&args[nargs])) {
682 db_printf("Argument missing\n");
683 db_flush_lex();
684 return;
685 }
686 nargs++;
687 }
688 db_unread_token(t);
689 }
690 if (db_read_token() != tRPAREN) {
691 db_printf("?\n");
692 db_flush_lex();
693 return;
694 }
695 }
696 db_skip_to_eol();
697
698 while (nargs < MAXARGS) {
699 args[nargs++] = 0;
700 }
701
702 retval = (*func)(args[0], args[1], args[2], args[3], args[4],
703 args[5], args[6], args[7], args[8], args[9]);
704 db_printf("%s\n", db_num_to_str(retval));
705 }
706
707 static void
708 db_reboot_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
709 {
710 db_expr_t bootflags;
711
712 /* Flags, default to RB_AUTOBOOT */
713 if (!db_expression(&bootflags))
714 bootflags = (db_expr_t)RB_AUTOBOOT;
715 if (db_read_token() != tEOL) {
716 db_error("?\n");
717 /*NOTREACHED*/
718 }
719 /*
720 * We are leaving DDB, never to return upward.
721 * Clear db_recover so that we can debug faults in functions
722 * called from cpu_reboot.
723 */
724 db_recover = 0;
725 cpu_reboot((int)bootflags, NULL);
726 }
727
728 static void
729 db_sifting_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
730 {
731 int mode, t;
732
733 t = db_read_token();
734 if (t == tSLASH) {
735 t = db_read_token();
736 if (t != tIDENT) {
737 bad_modifier:
738 db_printf("Bad modifier\n");
739 db_flush_lex();
740 return;
741 }
742 if (!strcmp(db_tok_string, "F"))
743 mode = 'F';
744 else
745 goto bad_modifier;
746 t = db_read_token();
747 } else
748 mode = 0;
749
750 if (t == tIDENT)
751 db_sifting(db_tok_string, mode);
752 else {
753 db_printf("Bad argument (non-string)\n");
754 db_flush_lex();
755 }
756 }
757
758 static void
759 db_stack_trace_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
760 {
761 register const char *cp = modif;
762 register char c;
763 void (*pr)(const char *, ...);
764
765 pr = db_printf;
766 while ((c = *cp++) != 0)
767 if (c == 'l')
768 pr = printf;
769
770 if (count == -1)
771 count = 65535;
772
773 db_stack_trace_print(addr, have_addr, count, modif, pr);
774 }
775
776 static void
777 db_sync_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
778 {
779
780 /*
781 * We are leaving DDB, never to return upward.
782 * Clear db_recover so that we can debug faults in functions
783 * called from cpu_reboot.
784 */
785 db_recover = 0;
786 cpu_reboot(RB_DUMP, NULL);
787 }
788