db_command.c (174910) | db_command.c (174914) |
---|---|
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 174910 2007-12-25 23:06:51Z rwatson $"); | 35__FBSDID("$FreeBSD: head/sys/ddb/db_command.c 174914 2007-12-26 09:33:19Z rwatson $"); |
36 37#include <sys/param.h> 38#include <sys/linker_set.h> 39#include <sys/lock.h> 40#include <sys/kdb.h> 41#include <sys/mutex.h> 42#include <sys/proc.h> 43#include <sys/reboot.h> --- 92 unchanged lines hidden (view full) --- 136 { "ps", db_ps, 0, 0 }, 137 { "gdb", db_gdb, 0, 0 }, 138 { "halt", db_halt, 0, 0 }, 139 { "reboot", db_reset, 0, 0 }, 140 { "reset", db_reset, 0, 0 }, 141 { "kill", db_kill, CS_OWN, 0 }, 142 { "watchdog", db_watchdog, 0, 0 }, 143 { "thread", db_set_thread, CS_OWN, 0 }, | 36 37#include <sys/param.h> 38#include <sys/linker_set.h> 39#include <sys/lock.h> 40#include <sys/kdb.h> 41#include <sys/mutex.h> 42#include <sys/proc.h> 43#include <sys/reboot.h> --- 92 unchanged lines hidden (view full) --- 136 { "ps", db_ps, 0, 0 }, 137 { "gdb", db_gdb, 0, 0 }, 138 { "halt", db_halt, 0, 0 }, 139 { "reboot", db_reset, 0, 0 }, 140 { "reset", db_reset, 0, 0 }, 141 { "kill", db_kill, CS_OWN, 0 }, 142 { "watchdog", db_watchdog, 0, 0 }, 143 { "thread", db_set_thread, CS_OWN, 0 }, |
144 { "run", db_run_cmd, CS_OWN, 0 }, 145 { "script", db_script_cmd, CS_OWN, 0 }, 146 { "scripts", db_scripts_cmd, 0, 0 }, 147 { "unscript", db_unscript_cmd, CS_OWN, 0 }, |
|
144 { "capture", db_capture_cmd, CS_OWN, 0 }, 145 { (char *)0, } 146}; 147 148static struct command_table db_command_table = { 149 db_commands, 150 SET_BEGIN(db_cmd_set), 151 SET_LIMIT(db_cmd_set) --- 30 unchanged lines hidden (view full) --- 182#define CMD_HELP 4 183 184static void db_cmd_match(char *name, struct command *cmd, 185 struct command **cmdp, int *resultp); 186static void db_cmd_list(struct command_table *table); 187static int db_cmd_search(char *name, struct command_table *table, 188 struct command **cmdp); 189static void db_command(struct command **last_cmdp, | 148 { "capture", db_capture_cmd, CS_OWN, 0 }, 149 { (char *)0, } 150}; 151 152static struct command_table db_command_table = { 153 db_commands, 154 SET_BEGIN(db_cmd_set), 155 SET_LIMIT(db_cmd_set) --- 30 unchanged lines hidden (view full) --- 186#define CMD_HELP 4 187 188static void db_cmd_match(char *name, struct command *cmd, 189 struct command **cmdp, int *resultp); 190static void db_cmd_list(struct command_table *table); 191static int db_cmd_search(char *name, struct command_table *table, 192 struct command **cmdp); 193static void db_command(struct command **last_cmdp, |
190 struct command_table *cmd_table); | 194 struct command_table *cmd_table, int dopager); |
191 192/* 193 * Helper function to match a single command. 194 */ 195static void 196db_cmd_match(name, cmd, cmdp, resultp) 197 char * name; 198 struct command *cmd; --- 80 unchanged lines hidden (view full) --- 279 for (aux_cmdp = table->aux_tablep; aux_cmdp < table->aux_tablep_end; 280 aux_cmdp++) { 281 db_printf("%-12s", (*aux_cmdp)->name); 282 db_end_line(12); 283 } 284} 285 286static void | 195 196/* 197 * Helper function to match a single command. 198 */ 199static void 200db_cmd_match(name, cmd, cmdp, resultp) 201 char * name; 202 struct command *cmd; --- 80 unchanged lines hidden (view full) --- 283 for (aux_cmdp = table->aux_tablep; aux_cmdp < table->aux_tablep_end; 284 aux_cmdp++) { 285 db_printf("%-12s", (*aux_cmdp)->name); 286 db_end_line(12); 287 } 288} 289 290static void |
287db_command(last_cmdp, cmd_table) | 291db_command(last_cmdp, cmd_table, dopager) |
288 struct command **last_cmdp; /* IN_OUT */ 289 struct command_table *cmd_table; | 292 struct command **last_cmdp; /* IN_OUT */ 293 struct command_table *cmd_table; |
294 int dopager; |
|
290{ 291 struct command *cmd; 292 int t; 293 char modif[TOK_STRING_SIZE]; 294 db_expr_t addr, count; 295 boolean_t have_addr = FALSE; 296 int result; 297 --- 95 unchanged lines hidden (view full) --- 393 } 394 } 395 } 396 *last_cmdp = cmd; 397 if (cmd != 0) { 398 /* 399 * Execute the command. 400 */ | 295{ 296 struct command *cmd; 297 int t; 298 char modif[TOK_STRING_SIZE]; 299 db_expr_t addr, count; 300 boolean_t have_addr = FALSE; 301 int result; 302 --- 95 unchanged lines hidden (view full) --- 398 } 399 } 400 } 401 *last_cmdp = cmd; 402 if (cmd != 0) { 403 /* 404 * Execute the command. 405 */ |
401 db_enable_pager(); | 406 if (dopager) 407 db_enable_pager(); 408 else 409 db_disable_pager(); |
402 (*cmd->fcn)(addr, have_addr, count, modif); | 410 (*cmd->fcn)(addr, have_addr, count, modif); |
403 db_disable_pager(); | 411 if (dopager) 412 db_disable_pager(); |
404 405 if (cmd->flag & CS_SET_DOT) { 406 /* 407 * If command changes dot, set dot to 408 * previous address displayed (if 'ed' style). 409 */ 410 if (db_ed_style) { 411 db_dot = db_prev; --- 34 unchanged lines hidden (view full) --- 446 db_cmd_loop_done = 0; 447 while (!db_cmd_loop_done) { 448 if (db_print_position() != 0) 449 db_printf("\n"); 450 451 db_printf("db> "); 452 (void) db_read_line(); 453 | 413 414 if (cmd->flag & CS_SET_DOT) { 415 /* 416 * If command changes dot, set dot to 417 * previous address displayed (if 'ed' style). 418 */ 419 if (db_ed_style) { 420 db_dot = db_prev; --- 34 unchanged lines hidden (view full) --- 455 db_cmd_loop_done = 0; 456 while (!db_cmd_loop_done) { 457 if (db_print_position() != 0) 458 db_printf("\n"); 459 460 db_printf("db> "); 461 (void) db_read_line(); 462 |
454 db_command(&db_last_command, &db_command_table); | 463 db_command(&db_last_command, &db_command_table, /* dopager */ 1); |
455 } 456} 457 | 464 } 465} 466 |
467/* 468 * Execute a command on behalf of a script. The caller is responsible for 469 * making sure that the command string is < DB_MAXLINE or it will be 470 * truncated. 471 * 472 * XXXRW: Runs by injecting faked input into DDB input stream; it would be 473 * nicer to use an alternative approach that didn't mess with the previous 474 * command buffer. 475 */ |
|
458void | 476void |
477db_command_script(const char *command) 478{ 479 db_prev = db_next = db_dot; 480 db_inject_line(command); 481 db_command(&db_last_command, &db_command_table, /* dopager */ 0); 482} 483 484void |
|
459db_error(s) 460 const char *s; 461{ 462 if (s) 463 db_printf("%s", s); 464 db_flush_lex(); 465 kdb_reenter(); 466} --- 246 unchanged lines hidden --- | 485db_error(s) 486 const char *s; 487{ 488 if (s) 489 db_printf("%s", s); 490 db_flush_lex(); 491 kdb_reenter(); 492} --- 246 unchanged lines hidden --- |