Deleted Added
full compact
db_command.c (256281) db_command.c (273265)
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: stable/10/sys/ddb/db_command.c 242424 2012-11-01 04:07:08Z alfred $");
35__FBSDID("$FreeBSD: stable/10/sys/ddb/db_command.c 273265 2014-10-18 19:22:59Z pfg $");
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>

--- 108 unchanged lines hidden (view full) ---

152 * Otherwise: 'dot' points to next item, '..' points to last.
153 */
154static boolean_t db_ed_style = TRUE;
155
156/*
157 * Utility routine - discard tokens through end-of-line.
158 */
159void
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>

--- 108 unchanged lines hidden (view full) ---

152 * Otherwise: 'dot' points to next item, '..' points to last.
153 */
154static boolean_t db_ed_style = TRUE;
155
156/*
157 * Utility routine - discard tokens through end-of-line.
158 */
159void
160db_skip_to_eol()
160db_skip_to_eol(void)
161{
162 int t;
163 do {
164 t = db_read_token();
165 } while (t != tEOL);
166}
167
168/*

--- 78 unchanged lines hidden (view full) ---

247 }
248 /* NB: intentionally quiet */
249}
250
251/*
252 * Helper function to match a single command.
253 */
254static void
161{
162 int t;
163 do {
164 t = db_read_token();
165 } while (t != tEOL);
166}
167
168/*

--- 78 unchanged lines hidden (view full) ---

247 }
248 /* NB: intentionally quiet */
249}
250
251/*
252 * Helper function to match a single command.
253 */
254static void
255db_cmd_match(name, cmd, cmdp, resultp)
256 char * name;
257 struct command *cmd;
258 struct command **cmdp; /* out */
259 int * resultp;
255db_cmd_match(char *name, struct command *cmd, struct command **cmdp,
256 int *resultp)
260{
261 char *lp, *rp;
262 int c;
263
264 lp = name;
265 rp = cmd->name;
266 while ((c = *lp) == *rp) {
267 if (c == 0) {

--- 18 unchanged lines hidden (view full) ---

286 }
287 }
288}
289
290/*
291 * Search for command prefix.
292 */
293static int
257{
258 char *lp, *rp;
259 int c;
260
261 lp = name;
262 rp = cmd->name;
263 while ((c = *lp) == *rp) {
264 if (c == 0) {

--- 18 unchanged lines hidden (view full) ---

283 }
284 }
285}
286
287/*
288 * Search for command prefix.
289 */
290static int
294db_cmd_search(name, table, cmdp)
295 char * name;
296 struct command_table *table;
297 struct command **cmdp; /* out */
291db_cmd_search(char *name, struct command_table *table, struct command **cmdp)
298{
299 struct command *cmd;
300 int result = CMD_NONE;
301
302 LIST_FOREACH(cmd, table, next) {
303 db_cmd_match(name,cmd,cmdp,&result);
304 if (result == CMD_UNIQUE)
305 break;

--- 4 unchanged lines hidden (view full) ---

310 if (name[0] == 'h' && name[1] == 'e'
311 && name[2] == 'l' && name[3] == 'p')
312 result = CMD_HELP;
313 }
314 return (result);
315}
316
317static void
292{
293 struct command *cmd;
294 int result = CMD_NONE;
295
296 LIST_FOREACH(cmd, table, next) {
297 db_cmd_match(name,cmd,cmdp,&result);
298 if (result == CMD_UNIQUE)
299 break;

--- 4 unchanged lines hidden (view full) ---

304 if (name[0] == 'h' && name[1] == 'e'
305 && name[2] == 'l' && name[3] == 'p')
306 result = CMD_HELP;
307 }
308 return (result);
309}
310
311static void
318db_cmd_list(table)
319 struct command_table *table;
312db_cmd_list(struct command_table *table)
320{
321 register struct command *cmd;
322
323 LIST_FOREACH(cmd, table, next) {
324 db_printf("%-12s", cmd->name);
325 db_end_line(12);
326 }
327}
328
329static void
313{
314 register struct command *cmd;
315
316 LIST_FOREACH(cmd, table, next) {
317 db_printf("%-12s", cmd->name);
318 db_end_line(12);
319 }
320}
321
322static void
330db_command(last_cmdp, cmd_table, dopager)
331 struct command **last_cmdp; /* IN_OUT */
332 struct command_table *cmd_table;
333 int dopager;
323db_command(struct command **last_cmdp, struct command_table *cmd_table,
324 int dopager)
334{
335 struct command *cmd = NULL;
336 int t;
337 char modif[TOK_STRING_SIZE];
338 db_expr_t addr, count;
339 boolean_t have_addr = FALSE;
340 int result;
341

--- 136 unchanged lines hidden (view full) ---

478 */
479DB_COMMAND(panic, db_panic)
480{
481 db_disable_pager();
482 panic("from debugger");
483}
484
485void
325{
326 struct command *cmd = NULL;
327 int t;
328 char modif[TOK_STRING_SIZE];
329 db_expr_t addr, count;
330 boolean_t have_addr = FALSE;
331 int result;
332

--- 136 unchanged lines hidden (view full) ---

469 */
470DB_COMMAND(panic, db_panic)
471{
472 db_disable_pager();
473 panic("from debugger");
474}
475
476void
486db_command_loop()
477db_command_loop(void)
487{
488 /*
489 * Initialize 'prev' and 'next' to dot.
490 */
491 db_prev = db_dot;
492 db_next = db_dot;
493
494 db_cmd_loop_done = 0;

--- 21 unchanged lines hidden (view full) ---

516db_command_script(const char *command)
517{
518 db_prev = db_next = db_dot;
519 db_inject_line(command);
520 db_command(&db_last_command, &db_cmd_table, /* dopager */ 0);
521}
522
523void
478{
479 /*
480 * Initialize 'prev' and 'next' to dot.
481 */
482 db_prev = db_dot;
483 db_next = db_dot;
484
485 db_cmd_loop_done = 0;

--- 21 unchanged lines hidden (view full) ---

507db_command_script(const char *command)
508{
509 db_prev = db_next = db_dot;
510 db_inject_line(command);
511 db_command(&db_last_command, &db_cmd_table, /* dopager */ 0);
512}
513
514void
524db_error(s)
525 const char *s;
515db_error(const char *s)
526{
527 if (s)
528 db_printf("%s", s);
529 db_flush_lex();
530 kdb_reenter();
531}
532
533static void

--- 42 unchanged lines hidden (view full) ---

576 return (0);
577 }
578 *rv = (*f)(args[0], args[1], args[2], args[3], args[4], args[5],
579 args[6], args[7], args[8], args[9]);
580 return (1);
581}
582
583static void
516{
517 if (s)
518 db_printf("%s", s);
519 db_flush_lex();
520 kdb_reenter();
521}
522
523static void

--- 42 unchanged lines hidden (view full) ---

566 return (0);
567 }
568 *rv = (*f)(args[0], args[1], args[2], args[3], args[4], args[5],
569 args[6], args[7], args[8], args[9]);
570 return (1);
571}
572
573static void
584db_fncall(dummy1, dummy2, dummy3, dummy4)
585 db_expr_t dummy1;
586 boolean_t dummy2;
587 db_expr_t dummy3;
588 char * dummy4;
574db_fncall(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
589{
590 db_expr_t fn_addr;
591 db_expr_t args[DB_MAXARGS];
592 int nargs = 0;
593 db_expr_t retval;
594 int t;
595
596 if (!db_expression(&fn_addr)) {

--- 37 unchanged lines hidden (view full) ---

634static void
635db_halt(db_expr_t dummy, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
636{
637
638 cpu_halt();
639}
640
641static void
575{
576 db_expr_t fn_addr;
577 db_expr_t args[DB_MAXARGS];
578 int nargs = 0;
579 db_expr_t retval;
580 int t;
581
582 if (!db_expression(&fn_addr)) {

--- 37 unchanged lines hidden (view full) ---

620static void
621db_halt(db_expr_t dummy, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
622{
623
624 cpu_halt();
625}
626
627static void
642db_kill(dummy1, dummy2, dummy3, dummy4)
643 db_expr_t dummy1;
644 boolean_t dummy2;
645 db_expr_t dummy3;
646 char * dummy4;
628db_kill(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
647{
648 db_expr_t old_radix, pid, sig;
649 struct proc *p;
650
629{
630 db_expr_t old_radix, pid, sig;
631 struct proc *p;
632
651#define DB_ERROR(f) do { db_printf f; db_flush_lex(); goto out; } while (0)
633#define DB_ERROR(f) do { db_printf f; db_flush_lex(); goto out; } while (0)
652
653 /*
654 * PIDs and signal numbers are typically represented in base
655 * 10, so make that the default here. It can, of course, be
656 * overridden by specifying a prefix.
657 */
658 old_radix = db_radix;
659 db_radix = 10;

--- 67 unchanged lines hidden (view full) ---

727 return;
728 }
729 }
730
731 cpu_reset();
732}
733
734static void
634
635 /*
636 * PIDs and signal numbers are typically represented in base
637 * 10, so make that the default here. It can, of course, be
638 * overridden by specifying a prefix.
639 */
640 old_radix = db_radix;
641 db_radix = 10;

--- 67 unchanged lines hidden (view full) ---

709 return;
710 }
711 }
712
713 cpu_reset();
714}
715
716static void
735db_watchdog(dummy1, dummy2, dummy3, dummy4)
736 db_expr_t dummy1;
737 boolean_t dummy2;
738 db_expr_t dummy3;
739 char * dummy4;
717db_watchdog(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
740{
741 db_expr_t old_radix, tout;
742 int err, i;
743
744 old_radix = db_radix;
745 db_radix = 10;
746 err = db_expression(&tout);
747 db_skip_to_eol();

--- 125 unchanged lines hidden ---
718{
719 db_expr_t old_radix, tout;
720 int err, i;
721
722 old_radix = db_radix;
723 db_radix = 10;
724 err = db_expression(&tout);
725 db_skip_to_eol();

--- 125 unchanged lines hidden ---