db_command.c (126399) | db_command.c (131952) |
---|---|
1/* 2 * Mach Operating System 3 * Copyright (c) 1991,1990 Carnegie Mellon University 4 * All Rights Reserved. 5 * 6 * Permission to use, copy, modify and distribute this software and its 7 * documentation is hereby granted, provided that both the copyright 8 * notice and this permission notice appear in all copies of the --- 18 unchanged lines hidden (view full) --- 27 * Author: David B. Golub, Carnegie Mellon University 28 * Date: 7/90 29 */ 30/* 31 * Command dispatcher. 32 */ 33 34#include <sys/cdefs.h> | 1/* 2 * Mach Operating System 3 * Copyright (c) 1991,1990 Carnegie Mellon University 4 * All Rights Reserved. 5 * 6 * Permission to use, copy, modify and distribute this software and its 7 * documentation is hereby granted, provided that both the copyright 8 * notice and this permission notice appear in all copies of the --- 18 unchanged lines hidden (view full) --- 27 * Author: David B. Golub, Carnegie Mellon University 28 * Date: 7/90 29 */ 30/* 31 * Command dispatcher. 32 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/sys/ddb/db_command.c 126399 2004-02-29 09:55:32Z phk $"); | 35__FBSDID("$FreeBSD: head/sys/ddb/db_command.c 131952 2004-07-10 23:47:20Z marcel $"); |
36 37#include <sys/param.h> 38#include <sys/linker_set.h> 39#include <sys/lock.h> | 36 37#include <sys/param.h> 38#include <sys/linker_set.h> 39#include <sys/lock.h> |
40#include <sys/kdb.h> |
|
40#include <sys/mutex.h> 41#include <sys/proc.h> 42#include <sys/reboot.h> 43#include <sys/signalvar.h> 44#include <sys/systm.h> 45#include <sys/cons.h> 46#include <sys/watchdog.h> 47 --- 5 unchanged lines hidden (view full) --- 53#include <machine/cpu.h> 54#include <machine/setjmp.h> 55 56/* 57 * Exported global variables 58 */ 59boolean_t db_cmd_loop_done; 60db_addr_t db_dot; | 41#include <sys/mutex.h> 42#include <sys/proc.h> 43#include <sys/reboot.h> 44#include <sys/signalvar.h> 45#include <sys/systm.h> 46#include <sys/cons.h> 47#include <sys/watchdog.h> 48 --- 5 unchanged lines hidden (view full) --- 54#include <machine/cpu.h> 55#include <machine/setjmp.h> 56 57/* 58 * Exported global variables 59 */ 60boolean_t db_cmd_loop_done; 61db_addr_t db_dot; |
61jmp_buf db_jmpbuf; | |
62db_addr_t db_last_addr; 63db_addr_t db_prev; 64db_addr_t db_next; 65 66SET_DECLARE(db_cmd_set, struct command); 67SET_DECLARE(db_show_cmd_set, struct command); 68 69static db_cmdfcn_t db_fncall; | 62db_addr_t db_last_addr; 63db_addr_t db_prev; 64db_addr_t db_next; 65 66SET_DECLARE(db_cmd_set, struct command); 67SET_DECLARE(db_show_cmd_set, struct command); 68 69static db_cmdfcn_t db_fncall; |
70static db_cmdfcn_t db_gdb; | |
71static db_cmdfcn_t db_kill; 72static db_cmdfcn_t db_reset; 73static db_cmdfcn_t db_watchdog; 74 75/* XXX this is actually forward-static. */ 76extern struct command db_show_cmds[]; 77 78/* --- 291 unchanged lines hidden (view full) --- 370 } 371} 372 373/* 374 * 'show' commands 375 */ 376 377static struct command db_show_all_cmds[] = { | 70static db_cmdfcn_t db_kill; 71static db_cmdfcn_t db_reset; 72static db_cmdfcn_t db_watchdog; 73 74/* XXX this is actually forward-static. */ 75extern struct command db_show_cmds[]; 76 77/* --- 291 unchanged lines hidden (view full) --- 369 } 370} 371 372/* 373 * 'show' commands 374 */ 375 376static struct command db_show_all_cmds[] = { |
378#if 0 379 { "threads", db_show_all_threads, 0, 0 }, 380#endif | |
381 { "procs", db_ps, 0, 0 }, 382 { (char *)0 } 383}; 384 385static struct command db_show_cmds[] = { 386 { "all", 0, 0, db_show_all_cmds }, 387 { "registers", db_show_regs, 0, 0 }, 388 { "breaks", db_listbreak_cmd, 0, 0 }, | 377 { "procs", db_ps, 0, 0 }, 378 { (char *)0 } 379}; 380 381static struct command db_show_cmds[] = { 382 { "all", 0, 0, db_show_all_cmds }, 383 { "registers", db_show_regs, 0, 0 }, 384 { "breaks", db_listbreak_cmd, 0, 0 }, |
389 { "thread", db_show_one_thread, 0, 0 }, 390#if 0 391 { "port", ipc_port_print, 0, 0 }, 392#endif | 385 { "threads", db_show_threads, 0, 0 }, |
393 { (char *)0, } 394}; 395 396static struct command db_command_table[] = { 397 { "print", db_print_cmd, 0, 0 }, 398 { "p", db_print_cmd, 0, 0 }, 399 { "examine", db_examine_cmd, CS_SET_DOT, 0 }, 400 { "x", db_examine_cmd, CS_SET_DOT, 0 }, --- 15 unchanged lines hidden (view full) --- 416 { "until", db_trace_until_call_cmd,0, 0 }, 417 { "next", db_trace_until_matching_cmd,0, 0 }, 418 { "match", db_trace_until_matching_cmd,0, 0 }, 419 { "trace", db_stack_trace_cmd, 0, 0 }, 420 { "where", db_stack_trace_cmd, 0, 0 }, 421 { "call", db_fncall, CS_OWN, 0 }, 422 { "show", 0, 0, db_show_cmds }, 423 { "ps", db_ps, 0, 0 }, | 386 { (char *)0, } 387}; 388 389static struct command db_command_table[] = { 390 { "print", db_print_cmd, 0, 0 }, 391 { "p", db_print_cmd, 0, 0 }, 392 { "examine", db_examine_cmd, CS_SET_DOT, 0 }, 393 { "x", db_examine_cmd, CS_SET_DOT, 0 }, --- 15 unchanged lines hidden (view full) --- 409 { "until", db_trace_until_call_cmd,0, 0 }, 410 { "next", db_trace_until_matching_cmd,0, 0 }, 411 { "match", db_trace_until_matching_cmd,0, 0 }, 412 { "trace", db_stack_trace_cmd, 0, 0 }, 413 { "where", db_stack_trace_cmd, 0, 0 }, 414 { "call", db_fncall, CS_OWN, 0 }, 415 { "show", 0, 0, db_show_cmds }, 416 { "ps", db_ps, 0, 0 }, |
424 { "gdb", db_gdb, 0, 0 }, | |
425 { "reset", db_reset, 0, 0 }, 426 { "kill", db_kill, CS_OWN, 0 }, 427 { "watchdog", db_watchdog, 0, 0 }, | 417 { "reset", db_reset, 0, 0 }, 418 { "kill", db_kill, CS_OWN, 0 }, 419 { "watchdog", db_watchdog, 0, 0 }, |
420 { "thread", db_set_thread, CS_OWN, 0 }, |
|
428 { (char *)0, } 429}; 430 431static struct command *db_last_command = 0; 432 | 421 { (char *)0, } 422}; 423 424static struct command *db_last_command = 0; 425 |
433#if 0 434void 435db_help_cmd() 436{ 437 struct command *cmd = db_command_table; 438 439 while (cmd->name != 0) { 440 db_printf("%-12s", cmd->name); 441 db_end_line(); 442 cmd++; 443 } 444} 445#endif 446 | |
447/* 448 * At least one non-optional command must be implemented using 449 * DB_COMMAND() so that db_cmd_set gets created. Here is one. 450 */ 451DB_COMMAND(panic, db_panic) 452{ 453 panic("from debugger"); 454} --- 4 unchanged lines hidden (view full) --- 459 /* 460 * Initialize 'prev' and 'next' to dot. 461 */ 462 db_prev = db_dot; 463 db_next = db_dot; 464 465 db_cmd_loop_done = 0; 466 while (!db_cmd_loop_done) { | 426/* 427 * At least one non-optional command must be implemented using 428 * DB_COMMAND() so that db_cmd_set gets created. Here is one. 429 */ 430DB_COMMAND(panic, db_panic) 431{ 432 panic("from debugger"); 433} --- 4 unchanged lines hidden (view full) --- 438 /* 439 * Initialize 'prev' and 'next' to dot. 440 */ 441 db_prev = db_dot; 442 db_next = db_dot; 443 444 db_cmd_loop_done = 0; 445 while (!db_cmd_loop_done) { |
467 468 (void) setjmp(db_jmpbuf); | |
469 if (db_print_position() != 0) 470 db_printf("\n"); 471 472 db_printf("db> "); 473 (void) db_read_line(); 474 475 db_command(&db_last_command, db_command_table, 476 SET_BEGIN(db_cmd_set), SET_LIMIT(db_cmd_set)); 477 } 478} 479 480void 481db_error(s) 482 const char *s; 483{ 484 if (s) 485 db_printf("%s", s); 486 db_flush_lex(); | 446 if (db_print_position() != 0) 447 db_printf("\n"); 448 449 db_printf("db> "); 450 (void) db_read_line(); 451 452 db_command(&db_last_command, db_command_table, 453 SET_BEGIN(db_cmd_set), SET_LIMIT(db_cmd_set)); 454 } 455} 456 457void 458db_error(s) 459 const char *s; 460{ 461 if (s) 462 db_printf("%s", s); 463 db_flush_lex(); |
487 longjmp(db_jmpbuf, 1); | 464 kdb_reenter(); |
488} 489 490 491/* 492 * Call random function: 493 * !expr(arg,arg,arg) 494 */ 495static void --- 52 unchanged lines hidden (view full) --- 548 args[nargs++] = 0; 549 } 550 551 retval = (*func)(args[0], args[1], args[2], args[3], args[4], 552 args[5], args[6], args[7], args[8], args[9] ); 553 db_printf("%#lr\n", (long)retval); 554} 555 | 465} 466 467 468/* 469 * Call random function: 470 * !expr(arg,arg,arg) 471 */ 472static void --- 52 unchanged lines hidden (view full) --- 525 args[nargs++] = 0; 526 } 527 528 retval = (*func)(args[0], args[1], args[2], args[3], args[4], 529 args[5], args[6], args[7], args[8], args[9] ); 530 db_printf("%#lr\n", (long)retval); 531} 532 |
556/* Enter GDB remote protocol debugger on the next trap. */ 557 558void *gdb_arg = NULL; 559cn_getc_t *gdb_getc; 560cn_putc_t *gdb_putc; 561 | |
562static void | 533static void |
563db_gdb (dummy1, dummy2, dummy3, dummy4) 564 db_expr_t dummy1; 565 boolean_t dummy2; 566 db_expr_t dummy3; 567 char * dummy4; 568{ 569 570 if (gdb_arg == NULL) { 571 db_printf("No gdb port enabled. Set flag 0x80 on desired port\n"); 572 db_printf("in your configuration file (currently sio only).\n"); 573 return; 574 } 575 boothowto ^= RB_GDB; 576 577 db_printf("Next trap will enter %s\n", 578 boothowto & RB_GDB ? "GDB remote protocol mode" 579 : "DDB debugger"); 580} 581 582static void | |
583db_kill(dummy1, dummy2, dummy3, dummy4) 584 db_expr_t dummy1; 585 boolean_t dummy2; 586 db_expr_t dummy3; 587 char * dummy4; 588{ 589 db_expr_t old_radix, pid, sig; 590 struct proc *p; --- 72 unchanged lines hidden --- | 534db_kill(dummy1, dummy2, dummy3, dummy4) 535 db_expr_t dummy1; 536 boolean_t dummy2; 537 db_expr_t dummy3; 538 char * dummy4; 539{ 540 db_expr_t old_radix, pid, sig; 541 struct proc *p; --- 72 unchanged lines hidden --- |