diff --git a/sys/ddb/db_break.c b/sys/ddb/db_break.c index 65045d909890..44b51fb7f402 100644 --- a/sys/ddb/db_break.c +++ b/sys/ddb/db_break.c @@ -1,325 +1,405 @@ /*- * SPDX-License-Identifier: MIT-CMU * * Mach Operating System * Copyright (c) 1991,1990 Carnegie Mellon University * All Rights Reserved. * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * */ /* * Author: David B. Golub, Carnegie Mellon University * Date: 7/90 */ /* * Breakpoints. */ #include +#include +#include #include #include +#include + #include #include #include #include struct db_breakpoint_type { db_breakpoint_t db_next_free_breakpoint; db_breakpoint_t db_breakpoint_limit; db_breakpoint_t db_free_breakpoints; db_breakpoint_t db_breakpoint_list; }; #define NBREAKPOINTS 100 static struct db_breakpoint db_break_table[NBREAKPOINTS]; static struct db_breakpoint_type db_breakpoint = { .db_next_free_breakpoint = &db_break_table[0], .db_breakpoint_limit = &db_break_table[NBREAKPOINTS], .db_free_breakpoints = NULL, .db_breakpoint_list = NULL, }; +#ifdef HAS_HW_BREAKPOINT +static struct db_breakpoint db_hbreak_table[NHBREAKPOINTS]; + +static struct db_breakpoint_type db_hbreakpoint = { + .db_next_free_breakpoint = &db_hbreak_table[0], + .db_breakpoint_limit = &db_hbreak_table[NHBREAKPOINTS], + .db_free_breakpoints = NULL, + .db_breakpoint_list = NULL, +}; +#endif + static db_breakpoint_t db_breakpoint_alloc( struct db_breakpoint_type *bkpt_type); static void db_breakpoint_free(struct db_breakpoint_type *bkpt_typ, db_breakpoint_t bkpt); static void db_delete_breakpoint(struct db_breakpoint_type *bkpt_type, vm_map_t map, db_addr_t addr); static db_breakpoint_t db_find_breakpoint(struct db_breakpoint_type *bkpt_type, vm_map_t map, db_addr_t addr); static void db_list_breakpoints(void); -static void db_set_breakpoint(struct db_breakpoint_type *bkpt_type, +static bool db_set_breakpoint(struct db_breakpoint_type *bkpt_type, vm_map_t map, db_addr_t addr, int count); static db_breakpoint_t db_breakpoint_alloc(struct db_breakpoint_type *bkpt_type) { register db_breakpoint_t bkpt; if ((bkpt = bkpt_type->db_free_breakpoints) != 0) { bkpt_type->db_free_breakpoints = bkpt->link; return (bkpt); } if (bkpt_type->db_next_free_breakpoint == bkpt_type->db_breakpoint_limit) { db_printf("All breakpoints used.\n"); return (0); } bkpt = bkpt_type->db_next_free_breakpoint; bkpt_type->db_next_free_breakpoint++; return (bkpt); } static void db_breakpoint_free(struct db_breakpoint_type *bkpt_type, db_breakpoint_t bkpt) { bkpt->link = bkpt_type->db_free_breakpoints; bkpt_type->db_free_breakpoints = bkpt; } -static void +static bool db_set_breakpoint(struct db_breakpoint_type *bkpt_type, vm_map_t map, db_addr_t addr, int count) { register db_breakpoint_t bkpt; if (db_find_breakpoint(bkpt_type, map, addr)) { db_printf("Already set.\n"); - return; + return (false); } bkpt = db_breakpoint_alloc(bkpt_type); if (bkpt == 0) { db_printf("Too many breakpoints.\n"); - return; + return (false); } bkpt->map = map; bkpt->address = addr; bkpt->flags = 0; bkpt->init_count = count; bkpt->count = count; bkpt->link = bkpt_type->db_breakpoint_list; bkpt_type->db_breakpoint_list = bkpt; + + return (true); } static void db_delete_breakpoint(struct db_breakpoint_type *bkpt_type, vm_map_t map, db_addr_t addr) { register db_breakpoint_t bkpt; register db_breakpoint_t *prev; for (prev = &bkpt_type->db_breakpoint_list; (bkpt = *prev) != 0; prev = &bkpt->link) { if (db_map_equal(bkpt->map, map) && (bkpt->address == addr)) { *prev = bkpt->link; break; } } if (bkpt == 0) { db_printf("Not set.\n"); return; } db_breakpoint_free(bkpt_type, bkpt); } static db_breakpoint_t db_find_breakpoint(struct db_breakpoint_type *bkpt_type, vm_map_t map, db_addr_t addr) { register db_breakpoint_t bkpt; for (bkpt = bkpt_type->db_breakpoint_list; bkpt != 0; bkpt = bkpt->link) { if (db_map_equal(bkpt->map, map) && (bkpt->address == addr)) return (bkpt); } return (0); } db_breakpoint_t db_find_breakpoint_here(db_addr_t addr) { - return db_find_breakpoint(&db_breakpoint, db_map_addr(addr), addr); + db_breakpoint_t bkpt; + + bkpt = db_find_breakpoint(&db_breakpoint, db_map_addr(addr), addr); +#ifdef HAS_HW_BREAKPOINT + if (bkpt == NULL) + bkpt = db_find_breakpoint(&db_hbreakpoint, db_map_addr(addr), + addr); +#endif + + return (bkpt); } static bool db_breakpoints_inserted = true; #ifndef BKPT_WRITE #define BKPT_WRITE(addr, storage) \ do { \ *storage = db_get_value(addr, BKPT_SIZE, false); \ db_put_value(addr, BKPT_SIZE, BKPT_SET(*storage)); \ } while (0) #endif #ifndef BKPT_CLEAR #define BKPT_CLEAR(addr, storage) \ db_put_value(addr, BKPT_SIZE, *storage) #endif +/* + * Set software breakpoints. + */ void db_set_breakpoints(void) { register db_breakpoint_t bkpt; if (!db_breakpoints_inserted) { for (bkpt = db_breakpoint.db_breakpoint_list; bkpt != 0; bkpt = bkpt->link) if (db_map_current(bkpt->map)) { BKPT_WRITE(bkpt->address, &bkpt->bkpt_inst); } db_breakpoints_inserted = true; } } +/* + * Clean software breakpoints. + */ void db_clear_breakpoints(void) { register db_breakpoint_t bkpt; if (db_breakpoints_inserted) { for (bkpt = db_breakpoint.db_breakpoint_list; bkpt != 0; bkpt = bkpt->link) if (db_map_current(bkpt->map)) { BKPT_CLEAR(bkpt->address, &bkpt->bkpt_inst); } db_breakpoints_inserted = false; } } /* - * List breakpoints. + * List software breakpoints. */ static void db_list_breakpoints(void) { register db_breakpoint_t bkpt; if (db_breakpoint.db_breakpoint_list == 0) { db_printf("No breakpoints set\n"); return; } db_printf(" Map Count Address\n"); for (bkpt = db_breakpoint.db_breakpoint_list; bkpt != 0; bkpt = bkpt->link) { db_printf("%s%8p %5d ", db_map_current(bkpt->map) ? "*" : " ", (void *)bkpt->map, bkpt->init_count); db_printsym(bkpt->address, DB_STGY_PROC); db_printf("\n"); } } -/* Delete breakpoint */ +/* + * Delete software breakpoint + */ /*ARGSUSED*/ void db_delete_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif) { db_delete_breakpoint(&db_breakpoint, db_map_addr(addr), (db_addr_t)addr); } -/* Set breakpoint with skip count */ +/* + * Set software breakpoint with skip count + */ /*ARGSUSED*/ void db_breakpoint_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif) { if (count == -1) count = 1; db_set_breakpoint(&db_breakpoint, db_map_addr(addr), (db_addr_t)addr, count); } +#ifdef HAS_HW_BREAKPOINT +/* + * Delete hardware breakpoint + */ +void +db_deletehbreak_cmd(db_expr_t addr, bool have_addr, db_expr_t count, + char *modif) +{ + if (count == -1) + count = 1; + + if (kdb_cpu_clr_breakpoint(addr) != 0) { + db_printf("hardware breakpoint could not be delete\n"); + return; + } + + db_delete_breakpoint(&db_hbreakpoint, db_map_addr(addr), + (db_addr_t)addr); +} + +/* + * Set hardware breakpoint + */ +void +db_hbreakpoint_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif) +{ + if (count == -1) + count = 1; + + if (!db_set_breakpoint(&db_hbreakpoint, db_map_addr(addr), + (db_addr_t)addr, count)) + return; + + if (kdb_cpu_set_breakpoint(addr) != 0) { + db_printf("hardware breakpoint could not be set\n"); + db_delete_breakpoint(&db_hbreakpoint, db_map_addr(addr), + (db_addr_t)addr); + } +} +#endif + /* list breakpoints */ void db_listbreak_cmd(db_expr_t dummy1, bool dummy2, db_expr_t dummy3, char *dummy4) { db_list_breakpoints(); +#ifdef HAS_HW_BREAKPOINT + db_md_list_breakpoints(); +#endif } /* * We want ddb to be usable before most of the kernel has been * initialized. In particular, current_thread() or kernel_map * (or both) may be null. */ bool db_map_equal(vm_map_t map1, vm_map_t map2) { return ((map1 == map2) || ((map1 == NULL) && (map2 == kernel_map)) || ((map1 == kernel_map) && (map2 == NULL))); } bool db_map_current(vm_map_t map) { #if 0 thread_t thread; return ((map == NULL) || (map == kernel_map) || (((thread = current_thread()) != NULL) && (map == thread->task->map))); #else return (true); #endif } vm_map_t db_map_addr(vm_offset_t addr) { #if 0 thread_t thread; /* * We want to return kernel_map for all * non-user addresses, even when debugging * kernel tasks with their own maps. */ if ((VM_MIN_ADDRESS <= addr) && (addr < VM_MAX_ADDRESS) && ((thread = current_thread()) != NULL)) return thread->task->map; else #endif return kernel_map; } diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 0c88d496f6b8..f621bd614ca2 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,948 +1,952 @@ /*- * SPDX-License-Identifier: MIT-CMU * * Mach Operating System * Copyright (c) 1991,1990 Carnegie Mellon University * All Rights Reserved. * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. */ /* * Author: David B. Golub, Carnegie Mellon University * Date: 7/90 */ /* * Command dispatcher. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * Exported global variables */ int db_cmd_loop_done; db_addr_t db_dot; db_addr_t db_last_addr; db_addr_t db_prev; db_addr_t db_next; static db_cmdfcn_t db_dump; static db_cmdfcn_t db_fncall; static db_cmdfcn_t db_gdb; static db_cmdfcn_t db_halt; static db_cmdfcn_t db_kill; static db_cmdfcn_t db_reset; static db_cmdfcn_t db_stack_trace; static db_cmdfcn_t db_stack_trace_active; static db_cmdfcn_t db_stack_trace_all; static db_cmdfcn_t db_watchdog; #define DB_CMD(_name, _func, _flags) \ { \ .name = (_name), \ .fcn = (_func), \ .flag = (_flags), \ .more = NULL, \ } #define DB_TABLE(_name, _more) \ { \ .name = (_name), \ .fcn = NULL, \ .more = (_more), \ } static struct db_command db_show_active_cmds[] = { DB_CMD("trace", db_stack_trace_active, DB_CMD_MEMSAFE), }; struct db_command_table db_show_active_table = LIST_HEAD_INITIALIZER(db_show_active_table); static struct db_command db_show_all_cmds[] = { DB_CMD("trace", db_stack_trace_all, DB_CMD_MEMSAFE), }; struct db_command_table db_show_all_table = LIST_HEAD_INITIALIZER(db_show_all_table); static struct db_command db_show_cmds[] = { DB_TABLE("active", &db_show_active_table), DB_TABLE("all", &db_show_all_table), DB_CMD("registers", db_show_regs, DB_CMD_MEMSAFE), DB_CMD("breaks", db_listbreak_cmd, DB_CMD_MEMSAFE), DB_CMD("threads", db_show_threads, DB_CMD_MEMSAFE), }; struct db_command_table db_show_table = LIST_HEAD_INITIALIZER(db_show_table); static struct db_command db_cmds[] = { DB_TABLE("show", &db_show_table), DB_CMD("print", db_print_cmd, 0), DB_CMD("p", db_print_cmd, 0), DB_CMD("examine", db_examine_cmd, CS_SET_DOT), DB_CMD("x", db_examine_cmd, CS_SET_DOT), DB_CMD("search", db_search_cmd, CS_OWN|CS_SET_DOT), DB_CMD("set", db_set_cmd, CS_OWN|DB_CMD_MEMSAFE), DB_CMD("write", db_write_cmd, CS_MORE|CS_SET_DOT), DB_CMD("w", db_write_cmd, CS_MORE|CS_SET_DOT), DB_CMD("delete", db_delete_cmd, 0), DB_CMD("d", db_delete_cmd, 0), DB_CMD("dump", db_dump, DB_CMD_MEMSAFE), +#ifdef HAS_HW_BREAKPOINT + DB_CMD("dhbreak", db_deletehbreak_cmd, 0), + DB_CMD("hbreak", db_hbreakpoint_cmd, 0), +#endif DB_CMD("break", db_breakpoint_cmd, 0), DB_CMD("b", db_breakpoint_cmd, 0), DB_CMD("dwatch", db_deletewatch_cmd, 0), DB_CMD("watch", db_watchpoint_cmd, CS_MORE), DB_CMD("dhwatch", db_deletehwatch_cmd, 0), DB_CMD("hwatch", db_hwatchpoint_cmd, 0), DB_CMD("step", db_single_step_cmd, DB_CMD_MEMSAFE), DB_CMD("s", db_single_step_cmd, DB_CMD_MEMSAFE), DB_CMD("continue", db_continue_cmd, DB_CMD_MEMSAFE), DB_CMD("c", db_continue_cmd, DB_CMD_MEMSAFE), DB_CMD("until", db_trace_until_call_cmd, DB_CMD_MEMSAFE), DB_CMD("next", db_trace_until_matching_cmd, DB_CMD_MEMSAFE), DB_CMD("match", db_trace_until_matching_cmd, 0), DB_CMD("trace", db_stack_trace, CS_OWN|DB_CMD_MEMSAFE), DB_CMD("t", db_stack_trace, CS_OWN|DB_CMD_MEMSAFE), /* XXX alias for active trace */ DB_CMD("acttrace", db_stack_trace_active, DB_CMD_MEMSAFE), /* XXX alias for all trace */ DB_CMD("alltrace", db_stack_trace_all, DB_CMD_MEMSAFE), DB_CMD("where", db_stack_trace, CS_OWN|DB_CMD_MEMSAFE), DB_CMD("bt", db_stack_trace, CS_OWN|DB_CMD_MEMSAFE), DB_CMD("call", db_fncall, CS_OWN), DB_CMD("ps", db_ps, DB_CMD_MEMSAFE), DB_CMD("gdb", db_gdb, 0), DB_CMD("halt", db_halt, DB_CMD_MEMSAFE), DB_CMD("reboot", db_reset, DB_CMD_MEMSAFE), DB_CMD("reset", db_reset, DB_CMD_MEMSAFE), DB_CMD("kill", db_kill, CS_OWN|DB_CMD_MEMSAFE), DB_CMD("watchdog", db_watchdog, CS_OWN|DB_CMD_MEMSAFE), DB_CMD("thread", db_set_thread, 0), DB_CMD("run", db_run_cmd, CS_OWN|DB_CMD_MEMSAFE), DB_CMD("script", db_script_cmd, CS_OWN|DB_CMD_MEMSAFE), DB_CMD("scripts", db_scripts_cmd, DB_CMD_MEMSAFE), DB_CMD("unscript", db_unscript_cmd, CS_OWN|DB_CMD_MEMSAFE), DB_CMD("capture", db_capture_cmd, CS_OWN|DB_CMD_MEMSAFE), DB_CMD("textdump", db_textdump_cmd, CS_OWN|DB_CMD_MEMSAFE), DB_CMD("findstack", db_findstack_cmd, 0), DB_CMD("pprint", db_pprint_cmd, CS_OWN), }; struct db_command_table db_cmd_table = LIST_HEAD_INITIALIZER(db_cmd_table); #undef DB_CMD #undef DB_TABLE static struct db_command *db_last_command = NULL; /* * if 'ed' style: 'dot' is set at start of last item printed, * and '+' points to next line. * Otherwise: 'dot' points to next item, '..' points to last. */ static bool db_ed_style = true; /* * Utility routine - discard tokens through end-of-line. */ void db_skip_to_eol(void) { int t; do { t = db_read_token(); } while (t != tEOL); } /* * Results of command search. */ #define CMD_UNIQUE 0 #define CMD_FOUND 1 #define CMD_NONE 2 #define CMD_AMBIGUOUS 3 #define CMD_HELP 4 static void db_cmd_match(char *name, struct db_command *cmd, struct db_command **cmdp, int *resultp); static void db_cmd_list(struct db_command_table *table); static int db_cmd_search(char *name, struct db_command_table *table, struct db_command **cmdp); static void db_command(struct db_command **last_cmdp, struct db_command_table *cmd_table, bool dopager); /* * Initialize the command lists from the static tables. */ void db_command_init(void) { int i; for (i = 0; i < nitems(db_cmds); i++) db_command_register(&db_cmd_table, &db_cmds[i]); for (i = 0; i < nitems(db_show_cmds); i++) db_command_register(&db_show_table, &db_show_cmds[i]); for (i = 0; i < nitems(db_show_active_cmds); i++) db_command_register(&db_show_active_table, &db_show_active_cmds[i]); for (i = 0; i < nitems(db_show_all_cmds); i++) db_command_register(&db_show_all_table, &db_show_all_cmds[i]); } /* * Register a command. */ void db_command_register(struct db_command_table *list, struct db_command *cmd) { struct db_command *c, *last; #ifdef MAC if (mac_ddb_command_register(list, cmd)) { printf("%s: MAC policy refused registration of command %s\n", __func__, cmd->name); return; } #endif last = NULL; LIST_FOREACH(c, list, next) { int n = strcmp(cmd->name, c->name); /* Check that the command is not already present. */ if (n == 0) { printf("%s: Warning, the command \"%s\" already exists;" " ignoring request\n", __func__, cmd->name); return; } if (n < 0) { /* NB: keep list sorted lexicographically */ LIST_INSERT_BEFORE(c, cmd, next); return; } last = c; } if (last == NULL) LIST_INSERT_HEAD(list, cmd, next); else LIST_INSERT_AFTER(last, cmd, next); } /* * Remove a command previously registered with db_command_register. */ void db_command_unregister(struct db_command_table *list, struct db_command *cmd) { struct db_command *c; LIST_FOREACH(c, list, next) { if (cmd == c) { LIST_REMOVE(cmd, next); return; } } /* NB: intentionally quiet */ } /* * Helper function to match a single command. */ static void db_cmd_match(char *name, struct db_command *cmd, struct db_command **cmdp, int *resultp) { char *lp, *rp; int c; lp = name; rp = cmd->name; while ((c = *lp) == *rp) { if (c == 0) { /* complete match */ *cmdp = cmd; *resultp = CMD_UNIQUE; return; } lp++; rp++; } if (c == 0) { /* end of name, not end of command - partial match */ if (*resultp == CMD_FOUND) { *resultp = CMD_AMBIGUOUS; /* but keep looking for a full match - this lets us match single letters */ } else if (*resultp == CMD_NONE) { *cmdp = cmd; *resultp = CMD_FOUND; } } } /* * Search for command prefix. */ static int db_cmd_search(char *name, struct db_command_table *table, struct db_command **cmdp) { struct db_command *cmd; int result = CMD_NONE; LIST_FOREACH(cmd, table, next) { db_cmd_match(name,cmd,cmdp,&result); if (result == CMD_UNIQUE) break; } if (result == CMD_NONE) { /* check for 'help' */ if (name[0] == 'h' && name[1] == 'e' && name[2] == 'l' && name[3] == 'p') result = CMD_HELP; } return (result); } static void db_cmd_list(struct db_command_table *table) { struct db_command *cmd; int have_subcommands; have_subcommands = 0; LIST_FOREACH(cmd, table, next) { if (cmd->more != NULL) have_subcommands++; db_printf("%-16s", cmd->name); db_end_line(16); } if (have_subcommands > 0) { db_printf("\nThe following have subcommands; append \"help\" " "to list (e.g. \"show help\"):\n"); LIST_FOREACH(cmd, table, next) { if (cmd->more == NULL) continue; db_printf("%-16s", cmd->name); db_end_line(16); } } } static void db_command(struct db_command **last_cmdp, struct db_command_table *cmd_table, bool dopager) { char modif[TOK_STRING_SIZE]; struct db_command *cmd = NULL; db_expr_t addr, count; int t, result; bool have_addr = false; t = db_read_token(); if (t == tEOL) { /* empty line repeats last command, at 'next' */ cmd = *last_cmdp; addr = (db_expr_t)db_next; have_addr = false; count = 1; modif[0] = '\0'; } else if (t == tEXCL) { db_fncall((db_expr_t)0, false, (db_expr_t)0, NULL); return; } else if (t != tIDENT) { db_printf("Unrecognized input; use \"help\" " "to list available commands\n"); db_flush_lex(); return; } else { /* * Search for command */ while (cmd_table != NULL) { result = db_cmd_search(db_tok_string, cmd_table, &cmd); switch (result) { case CMD_NONE: db_printf("No such command; use \"help\" " "to list available commands\n"); db_flush_lex(); return; case CMD_AMBIGUOUS: db_printf("Ambiguous\n"); db_flush_lex(); return; case CMD_HELP: if (cmd_table == &db_cmd_table) { db_printf("This is ddb(4), the kernel debugger; " "see https://man.FreeBSD.org/ddb/4 for help.\n"); db_printf("Use \"bt\" for backtrace, \"dump\" for " "kernel core dump, \"reset\" to reboot.\n"); db_printf("Available commands:\n"); } db_cmd_list(cmd_table); db_flush_lex(); return; case CMD_UNIQUE: case CMD_FOUND: break; } if ((cmd_table = cmd->more) != NULL) { t = db_read_token(); if (t != tIDENT) { db_printf("Subcommand required; " "available subcommands:\n"); db_cmd_list(cmd_table); db_flush_lex(); return; } } } if ((cmd->flag & CS_OWN) == 0) { /* * Standard syntax: * command [/modifier] [addr] [,count] */ t = db_read_token(); if (t == tSLASH) { t = db_read_token(); if (t != tIDENT) { db_printf("Bad modifier\n"); db_flush_lex(); return; } db_strcpy(modif, db_tok_string); } else { db_unread_token(t); modif[0] = '\0'; } if (db_expression(&addr)) { db_dot = (db_addr_t) addr; db_last_addr = db_dot; have_addr = true; } else { addr = (db_expr_t) db_dot; have_addr = false; } t = db_read_token(); if (t == tCOMMA) { if (!db_expression(&count)) { db_printf("Count missing\n"); db_flush_lex(); return; } } else { db_unread_token(t); count = -1; } if ((cmd->flag & CS_MORE) == 0) { db_skip_to_eol(); } } } *last_cmdp = cmd; if (cmd != NULL) { #ifdef MAC if (mac_ddb_command_exec(cmd, addr, have_addr, count, modif)) { db_printf("MAC prevented execution of command %s\n", cmd->name); return; } #endif /* * Execute the command. */ if (dopager) db_enable_pager(); else db_disable_pager(); (*cmd->fcn)(addr, have_addr, count, modif); if (dopager) db_disable_pager(); if (cmd->flag & CS_SET_DOT) { /* * If command changes dot, set dot to previous address * displayed (if 'ed' style). */ db_dot = db_ed_style ? db_prev : db_next; } else { /* * If command does not change dot, set 'next' location * to be the same. */ db_next = db_dot; } } } /* * At least one non-optional command must be implemented using * DB_COMMAND() so that db_cmd_set gets created. Here is one. */ DB_COMMAND_FLAGS(panic, db_panic, DB_CMD_MEMSAFE) { db_disable_pager(); panic("from debugger"); } void db_command_loop(void) { /* * Initialize 'prev' and 'next' to dot. */ db_prev = db_dot; db_next = db_dot; db_cmd_loop_done = 0; while (!db_cmd_loop_done) { if (db_print_position() != 0) db_printf("\n"); db_printf("db> "); (void)db_read_line(); db_command(&db_last_command, &db_cmd_table, /* dopager */ true); } } /* * Execute a command on behalf of a script. The caller is responsible for * making sure that the command string is < DB_MAXLINE or it will be * truncated. * * XXXRW: Runs by injecting faked input into DDB input stream; it would be * nicer to use an alternative approach that didn't mess with the previous * command buffer. */ void db_command_script(const char *command) { db_prev = db_next = db_dot; db_inject_line(command); db_command(&db_last_command, &db_cmd_table, /* dopager */ false); } void db_error(const char *s) { if (s) db_printf("%s", s); db_flush_lex(); kdb_reenter_silent(); } static void db_dump(db_expr_t dummy, bool dummy2, db_expr_t dummy3, char *dummy4) { int error; if (textdump_pending) { db_printf("textdump_pending set.\n" "run \"textdump unset\" first or \"textdump dump\" for a textdump.\n"); return; } error = doadump(false); if (error) { db_printf("Cannot dump: "); switch (error) { case EBUSY: db_printf("debugger got invoked while dumping.\n"); break; case ENXIO: db_printf("no dump device specified.\n"); break; default: db_printf("unknown error (error=%d).\n", error); break; } } } /* * Call random function: * !expr(arg,arg,arg) */ /* The generic implementation supports a maximum of 10 arguments. */ typedef db_expr_t __db_f(db_expr_t, db_expr_t, db_expr_t, db_expr_t, db_expr_t, db_expr_t, db_expr_t, db_expr_t, db_expr_t, db_expr_t); static __inline int db_fncall_generic(db_expr_t addr, db_expr_t *rv, int nargs, db_expr_t args[]) { __db_f *f = (__db_f *)addr; if (nargs > 10) { db_printf("Too many arguments (max 10)\n"); return (0); } *rv = (*f)(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]); return (1); } static void db_fncall(db_expr_t dummy1, bool dummy2, db_expr_t dummy3, char *dummy4) { db_expr_t fn_addr; db_expr_t args[DB_MAXARGS]; int nargs = 0; db_expr_t retval; int t; if (!db_expression(&fn_addr)) { db_printf("Bad function\n"); db_flush_lex(); return; } t = db_read_token(); if (t == tLPAREN) { if (db_expression(&args[0])) { nargs++; while ((t = db_read_token()) == tCOMMA) { if (nargs == DB_MAXARGS) { db_printf("Too many arguments (max %d)\n", DB_MAXARGS); db_flush_lex(); return; } if (!db_expression(&args[nargs])) { db_printf("Argument missing\n"); db_flush_lex(); return; } nargs++; } db_unread_token(t); } if (db_read_token() != tRPAREN) { db_printf("Mismatched parens\n"); db_flush_lex(); return; } } db_skip_to_eol(); db_disable_pager(); if (DB_CALL(fn_addr, &retval, nargs, args)) db_printf("= %#lr\n", (long)retval); } static void db_halt(db_expr_t dummy, bool dummy2, db_expr_t dummy3, char *dummy4) { cpu_halt(); } static void db_kill(db_expr_t dummy1, bool dummy2, db_expr_t dummy3, char *dummy4) { db_expr_t old_radix, pid, sig; struct proc *p; #define DB_ERROR(f) do { db_printf f; db_flush_lex(); goto out; } while (0) /* * PIDs and signal numbers are typically represented in base * 10, so make that the default here. It can, of course, be * overridden by specifying a prefix. */ old_radix = db_radix; db_radix = 10; /* Retrieve arguments. */ if (!db_expression(&sig)) DB_ERROR(("Missing signal number\n")); if (!db_expression(&pid)) DB_ERROR(("Missing process ID\n")); db_skip_to_eol(); if (!_SIG_VALID(sig)) DB_ERROR(("Signal number out of range\n")); /* * Find the process in question. allproc_lock is not needed * since we're in DDB. */ /* sx_slock(&allproc_lock); */ FOREACH_PROC_IN_SYSTEM(p) if (p->p_pid == pid) break; /* sx_sunlock(&allproc_lock); */ if (p == NULL) DB_ERROR(("Can't find process with pid %ld\n", (long) pid)); /* If it's already locked, bail; otherwise, do the deed. */ if (PROC_TRYLOCK(p) == 0) DB_ERROR(("Can't lock process with pid %ld\n", (long) pid)); else { pksignal(p, sig, NULL); PROC_UNLOCK(p); } out: db_radix = old_radix; #undef DB_ERROR } /* * Reboot. In case there is an additional argument, take it as delay in * seconds. Default to 15s if we cannot parse it and make sure we will * never wait longer than 1 week. Some code is similar to * kern_shutdown.c:shutdown_panic(). */ #ifndef DB_RESET_MAXDELAY #define DB_RESET_MAXDELAY (3600 * 24 * 7) #endif static void db_reset(db_expr_t addr, bool have_addr, db_expr_t count __unused, char *modif) { int delay, loop; if (have_addr) { delay = (int)db_hex2dec(addr); /* If we parse to fail, use 15s. */ if (delay == -1) delay = 15; /* Cap at one week. */ if ((uintmax_t)delay > (uintmax_t)DB_RESET_MAXDELAY) delay = DB_RESET_MAXDELAY; db_printf("Automatic reboot in %d seconds - " "press a key on the console to abort\n", delay); for (loop = delay * 10; loop > 0; --loop) { DELAY(1000 * 100); /* 1/10th second */ /* Did user type a key? */ if (cncheckc() != -1) return; } } /* * Conditionally try the standard reboot path, so any registered * shutdown/reset handlers have a chance to run first. Some platforms * may not support the machine-dependent mechanism used by cpu_reset() * and rely on some other non-standard mechanism to perform the reset. * For example, the BCM2835 watchdog driver or gpio-poweroff driver. */ if (modif[0] != 's') { kern_reboot(RB_NOSYNC); /* NOTREACHED */ } cpu_reset(); } static void db_watchdog(db_expr_t dummy1, bool dummy2, db_expr_t dummy3, char *dummy4) { db_expr_t old_radix, tout; int err, i; old_radix = db_radix; db_radix = 10; err = db_expression(&tout); db_skip_to_eol(); db_radix = old_radix; /* If no argument is provided the watchdog will just be disabled. */ if (err == 0) { db_printf("No argument provided, disabling watchdog\n"); tout = 0; } else if ((tout & WD_INTERVAL) == WD_TO_NEVER) { db_error("Out of range watchdog interval\n"); return; } EVENTHANDLER_INVOKE(watchdog_list, tout, &i); } static void db_gdb(db_expr_t dummy1, bool dummy2, db_expr_t dummy3, char *dummy4) { if (kdb_dbbe_select("gdb") != 0) { db_printf("The remote GDB backend could not be selected.\n"); return; } /* * Mark that we are done in the debugger. kdb_trap() * should re-enter with the new backend. */ db_cmd_loop_done = 1; db_printf("(ctrl-c will return control to ddb)\n"); } static void db_stack_trace(db_expr_t tid, bool hastid, db_expr_t count, char *modif) { struct thread *td; db_expr_t radix; pid_t pid; int t; /* * We parse our own arguments. We don't like the default radix. */ radix = db_radix; db_radix = 10; hastid = db_expression(&tid); t = db_read_token(); if (t == tCOMMA) { if (!db_expression(&count)) { db_printf("Count missing\n"); db_flush_lex(); db_radix = radix; return; } } else { db_unread_token(t); count = -1; } db_skip_to_eol(); db_radix = radix; if (hastid) { td = kdb_thr_lookup((lwpid_t)tid); if (td == NULL) td = kdb_thr_from_pid((pid_t)tid); if (td == NULL) { db_printf("Thread %d not found\n", (int)tid); return; } } else td = kdb_thread; if (td->td_proc != NULL) pid = td->td_proc->p_pid; else pid = -1; db_printf("Tracing pid %d tid %ld td %p\n", pid, (long)td->td_tid, td); if (td->td_proc != NULL && (td->td_proc->p_flag & P_INMEM) == 0) db_printf("--- swapped out\n"); else db_trace_thread(td, count); } static void _db_stack_trace_all(bool active_only) { struct thread *td; jmp_buf jb; void *prev_jb; for (td = kdb_thr_first(); td != NULL; td = kdb_thr_next(td)) { prev_jb = kdb_jmpbuf(jb); if (setjmp(jb) == 0) { if (TD_IS_RUNNING(td)) db_printf("\nTracing command %s pid %d" " tid %ld td %p (CPU %d)\n", td->td_proc->p_comm, td->td_proc->p_pid, (long)td->td_tid, td, td->td_oncpu); else if (active_only) continue; else db_printf("\nTracing command %s pid %d" " tid %ld td %p\n", td->td_proc->p_comm, td->td_proc->p_pid, (long)td->td_tid, td); if (td->td_proc->p_flag & P_INMEM) db_trace_thread(td, -1); else db_printf("--- swapped out\n"); if (db_pager_quit) { kdb_jmpbuf(prev_jb); return; } } kdb_jmpbuf(prev_jb); } } static void db_stack_trace_active(db_expr_t dummy, bool dummy2, db_expr_t dummy3, char *dummy4) { _db_stack_trace_all(true); } static void db_stack_trace_all(db_expr_t dummy, bool dummy2, db_expr_t dummy3, char *dummy4) { _db_stack_trace_all(false); } /* * Take the parsed expression value from the command line that was parsed * as a hexadecimal value and convert it as if the expression was parsed * as a decimal value. Returns -1 if the expression was not a valid * decimal value. */ db_expr_t db_hex2dec(db_expr_t expr) { uintptr_t x, y; db_expr_t val; y = 1; val = 0; x = expr; while (x != 0) { if (x % 16 > 9) return (-1); val += (x % 16) * (y); x >>= 4; y *= 10; } return (val); } diff --git a/sys/ddb/ddb.h b/sys/ddb/ddb.h index bb92fef63e94..ab7dab1daa45 100644 --- a/sys/ddb/ddb.h +++ b/sys/ddb/ddb.h @@ -1,339 +1,346 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1993, Garrett A. Wollman. * Copyright (c) 1993, University of Vermont and State Agricultural College. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * Necessary declarations for the `ddb' kernel debugger. */ #ifndef _DDB_DDB_H_ #define _DDB_DDB_H_ #ifdef SYSCTL_DECL SYSCTL_DECL(_debug_ddb); #endif #include /* type definitions */ #include /* LIST_* */ #include /* SYSINIT */ #ifndef DB_MAXARGS #define DB_MAXARGS 10 #endif #ifndef DB_MAXLINE #define DB_MAXLINE 120 #endif #ifndef DB_MAXSCRIPTS #define DB_MAXSCRIPTS 8 #endif #ifndef DB_MAXSCRIPTNAME #define DB_MAXSCRIPTNAME 32 #endif #ifndef DB_MAXSCRIPTLEN #define DB_MAXSCRIPTLEN 128 #endif #ifndef DB_MAXSCRIPTRECURSION #define DB_MAXSCRIPTRECURSION 3 #endif #ifndef DB_CALL #define DB_CALL db_fncall_generic #else int DB_CALL(db_expr_t, db_expr_t *, int, db_expr_t[]); #endif /* * Extern variables to set the address and size of the symtab and strtab. * Most users should use db_fetch_symtab in order to set them from the * boot loader provided values. */ extern vm_offset_t ksymtab, kstrtab, ksymtab_size, ksymtab_relbase; /* Command tables contain a list of commands. */ struct db_command; LIST_HEAD(db_command_table, db_command); #define _DB_TABLE_NAME(table) db_##table##_table #define DB_DEFINE_TABLE(parent, name, table) \ struct db_command_table _DB_TABLE_NAME(table) = \ LIST_HEAD_INITIALIZER(_DB_TABLE_NAME(table)); \ _DB_SET(parent, name, NULL, 0, &_DB_TABLE_NAME(table)) #define DB_DECLARE_TABLE(table) \ extern struct db_command_table _DB_TABLE_NAME(table) /* * Builtin command tables: * - cmd: Top-level command table; a list of these is displayed * by typing 'help' at the debugger prompt. * - show: Sub-commands of 'show' * - show_all: Sub-commands of 'show all' * - show_active: Sub-commands of 'show active' */ DB_DECLARE_TABLE(cmd); DB_DECLARE_TABLE(show); DB_DECLARE_TABLE(show_all); DB_DECLARE_TABLE(show_active); /* * Type signature for a function implementing a ddb command. */ typedef void db_cmdfcn_t(db_expr_t addr, bool have_addr, db_expr_t count, char *modif); /* * Command table entry. */ struct db_command { char *name; /* command name */ db_cmdfcn_t *fcn; /* function to call */ int flag; #define CS_OWN 0x1 /* non-standard syntax */ #define CS_MORE 0x2 /* standard syntax, but may have other words * at end */ #define CS_SET_DOT 0x100 /* set dot after command */ #define DB_CMD_MEMSAFE 0x1000 /* Command does not allow reads or writes to * arbitrary memory. */ #define DB_MAC1 0x10000 /* For MAC policy use */ #define DB_MAC2 0x20000 struct db_command_table *more; /* another level of command */ LIST_ENTRY(db_command) next; /* next entry in the command table */ void *mac_priv; /* For MAC policy use */ }; /* * Arrange for the specified ddb command to be defined and * bound to the specified function. Commands can be defined * in modules in which case they will be available only when * the module is loaded. */ #define _DB_SET(_table, _name, _func, _flag, _more) \ static struct db_command db_##_table##_##_name##_cmd = { \ .name = __STRING(_name), \ .fcn = _func, \ .flag = _flag, \ .more = _more \ }; \ \ static void \ db##_table##_##_name##_add(void *arg __unused) \ { \ db_command_register(&_DB_TABLE_NAME(_table), \ &db_##_table##_##_name##_cmd); \ } \ SYSINIT(db_##_table##_##_name, SI_SUB_KLD, SI_ORDER_ANY, \ db##_table##_##_name##_add, NULL); \ \ static void \ db##_table##_##_name##_del(void *arg __unused) \ { \ db_command_unregister(&_DB_TABLE_NAME(_table), \ &db_##_table##_##_name##_cmd); \ } \ SYSUNINIT(db_##_table##_##_name, SI_SUB_KLD, SI_ORDER_ANY, \ db##_table##_##_name##_del, NULL) /* * Like _DB_SET but also create the function declaration which * must be followed immediately by the body; e.g. * DB_TABLE_COMMAND_FLAGS(_cmd, panic, db_panic, 0) * { * ...panic implementation... * } * * This macro is mostly used to define commands placed in one of * the ddb command tables; see DB_COMMAND, etc. below. */ #define DB_TABLE_COMMAND_FLAGS(_table, _name, _func, _flag) \ static db_cmdfcn_t _func; \ _DB_SET(_table, _name, _func, _flag, NULL); \ static void \ _func(db_expr_t addr, bool have_addr, db_expr_t count, char *modif) #define DB_TABLE_COMMAND(_table, _name, _func) \ DB_TABLE_COMMAND_FLAGS(_table, _name, _func, 0) /* Wrappers around _DB_SET used for aliases. */ #define DB_TABLE_ALIAS_FLAGS(_table, _name, _func, _flag) \ _DB_SET(_table, _name, _func, _flag, NULL) #define DB_TABLE_ALIAS(_table, _name, _func) \ DB_TABLE_ALIAS_FLAGS(_table, _name, _func, 0) #define DB_COMMAND_FLAGS(cmd_name, func_name, flags) \ DB_TABLE_COMMAND_FLAGS(cmd, cmd_name, func_name, flags) #define DB_COMMAND(cmd_name, func_name) \ DB_COMMAND_FLAGS(cmd_name, func_name, 0) #define DB_ALIAS_FLAGS(alias_name, func_name, flags) \ DB_TABLE_ALIAS_FLAGS(cmd, alias_name, func_name, flags) #define DB_ALIAS(alias_name, func_name) \ DB_ALIAS_FLAGS(alias_name, func_name, 0) #define DB_SHOW_COMMAND_FLAGS(cmd_name, func_name, flags) \ DB_TABLE_COMMAND_FLAGS(show, cmd_name, func_name, flags) #define DB_SHOW_COMMAND(cmd_name, func_name) \ DB_SHOW_COMMAND_FLAGS(cmd_name, func_name, 0) #define DB_SHOW_ALIAS_FLAGS(alias_name, func_name, flags) \ DB_TABLE_ALIAS_FLAGS(show, alias_name, func_name, flags) #define DB_SHOW_ALIAS(alias_name, func_name) \ DB_SHOW_ALIAS_FLAGS(alias_name, func_name, 0) #define DB_SHOW_ALL_COMMAND(cmd_name, func_name) \ DB_TABLE_COMMAND_FLAGS(show_all, cmd_name, func_name, DB_CMD_MEMSAFE) #define DB_SHOW_ALL_ALIAS(alias_name, func_name) \ DB_TABLE_ALIAS_FLAGS(show_all, alias_name, func_name, DB_CMD_MEMSAFE) extern db_expr_t db_maxoff; extern int db_indent; extern int db_inst_count; extern int db_load_count; extern int db_store_count; extern volatile int db_pager_quit; extern db_expr_t db_radix; extern db_expr_t db_max_width; extern db_expr_t db_tab_stop_width; extern db_expr_t db_lines_per_page; struct thread; struct vm_map; void db_check_interrupt(void); void db_clear_watchpoints(void); db_addr_t db_disasm(db_addr_t loc, bool altfmt); /* instruction disassembler */ void db_error(const char *s); int db_expression(db_expr_t *valuep); int db_getc(void); int db_get_variable(db_expr_t *valuep); void db_iprintf(const char *,...) __printflike(1, 2); struct proc *db_lookup_proc(db_expr_t addr); struct thread *db_lookup_thread(db_expr_t addr, bool check_pid); struct vm_map *db_map_addr(vm_offset_t); bool db_map_current(struct vm_map *); bool db_map_equal(struct vm_map *, struct vm_map *); void db_md_list_watchpoints(void); void db_print_loc_and_inst(db_addr_t loc); void db_print_thread(void); int db_printf(const char *fmt, ...) __printflike(1, 2); int db_read_bytes(vm_offset_t addr, size_t size, char *data); /* machine-dependent */ int db_readline(char *lstart, int lsize); void db_restart_at_pc(bool watchpt); int db_set_variable(db_expr_t value); void db_set_watchpoints(void); void db_skip_to_eol(void); bool db_stop_at_pc(int type, int code, bool *is_breakpoint, bool *is_watchpoint); #define db_strcpy strcpy void db_trace_self(void); int db_trace_thread(struct thread *, int); bool db_value_of_name(const char *name, db_expr_t *valuep); bool db_value_of_name_pcpu(const char *name, db_expr_t *valuep); bool db_value_of_name_vnet(const char *name, db_expr_t *valuep); int db_write_bytes(vm_offset_t addr, size_t size, char *data); void db_command_register(struct db_command_table *, struct db_command *); void db_command_unregister(struct db_command_table *, struct db_command *); int db_fetch_ksymtab(vm_offset_t ksym_start, vm_offset_t ksym_end, vm_offset_t relbase); db_cmdfcn_t db_breakpoint_cmd; db_cmdfcn_t db_capture_cmd; db_cmdfcn_t db_continue_cmd; db_cmdfcn_t db_delete_cmd; db_cmdfcn_t db_deletehwatch_cmd; db_cmdfcn_t db_deletewatch_cmd; db_cmdfcn_t db_examine_cmd; db_cmdfcn_t db_findstack_cmd; db_cmdfcn_t db_hwatchpoint_cmd; db_cmdfcn_t db_listbreak_cmd; db_cmdfcn_t db_scripts_cmd; db_cmdfcn_t db_print_cmd; db_cmdfcn_t db_ps; db_cmdfcn_t db_run_cmd; db_cmdfcn_t db_script_cmd; db_cmdfcn_t db_search_cmd; db_cmdfcn_t db_set_cmd; db_cmdfcn_t db_set_thread; db_cmdfcn_t db_show_regs; db_cmdfcn_t db_show_threads; db_cmdfcn_t db_single_step_cmd; db_cmdfcn_t db_textdump_cmd; db_cmdfcn_t db_trace_until_call_cmd; db_cmdfcn_t db_trace_until_matching_cmd; db_cmdfcn_t db_unscript_cmd; db_cmdfcn_t db_watchpoint_cmd; db_cmdfcn_t db_write_cmd; db_cmdfcn_t db_pprint_cmd; +#ifdef HAS_HW_BREAKPOINT +void db_md_list_breakpoints(void); + +db_cmdfcn_t db_deletehbreak_cmd; +db_cmdfcn_t db_hbreakpoint_cmd; +#endif + /* * Interface between DDB and the DDB output capture facility. */ struct dumperinfo; void db_capture_dump(struct dumperinfo *di); void db_capture_enterpager(void); void db_capture_exitpager(void); void db_capture_write(char *buffer, u_int buflen); void db_capture_writech(char ch); /* * Interface between DDB and the script facility. */ void db_script_kdbenter(const char *eventname); /* KDB enter event. */ /* * Interface between DDB and the textdump facility. * * Text dump blocks are of a fixed size; textdump_block_buffer is a * statically allocated buffer that code interacting with textdumps can use * to prepare and hold a pending block in when calling writenextblock(). */ #define TEXTDUMP_BLOCKSIZE 512 extern char textdump_block_buffer[TEXTDUMP_BLOCKSIZE]; void textdump_mkustar(char *block_buffer, const char *filename, u_int size); void textdump_restoreoff(off_t offset); void textdump_saveoff(off_t *offsetp); int textdump_writenextblock(struct dumperinfo *di, char *buffer); /* * Interface between the kernel and textdumps. */ extern int textdump_pending; /* Call textdump_dumpsys() instead. */ void textdump_dumpsys(struct dumperinfo *di); #endif /* !_DDB_DDB_H_ */