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