1993-11-25 01:38:01 +00:00
|
|
|
/*-
|
|
|
|
* 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.
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1993-11-25 01:38:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Necessary declarations for the `ddb' kernel debugger.
|
|
|
|
*/
|
|
|
|
|
1995-11-24 13:53:05 +00:00
|
|
|
#ifndef _DDB_DDB_H_
|
|
|
|
#define _DDB_DDB_H_
|
1993-11-25 01:38:01 +00:00
|
|
|
|
Add a new DDB(4) facility, output capture. Input and output from DDB may be
captured to a memory buffer for later inspection using sysctl(8), or in the
future, to a textdump.
A new DDB command, "capture", is added, which accepts arguments "on", "off",
"reset", and "status".
A new DDB sysctl tree, debug.ddb.capture, is added, which can be used to
resize the capture buffer and extract buffer contents.
MFC after: 3 months
2007-12-25 23:06:51 +00:00
|
|
|
#ifdef SYSCTL_DECL
|
|
|
|
SYSCTL_DECL(_debug_ddb);
|
|
|
|
#endif
|
|
|
|
|
1994-05-25 09:21:21 +00:00
|
|
|
#include <machine/db_machdep.h> /* type definitions */
|
1993-11-25 01:38:01 +00:00
|
|
|
|
2008-09-15 22:45:14 +00:00
|
|
|
#include <sys/queue.h> /* LIST_* */
|
|
|
|
#include <sys/kernel.h> /* SYSINIT */
|
|
|
|
|
2005-07-02 23:52:37 +00:00
|
|
|
#ifndef DB_MAXARGS
|
|
|
|
#define DB_MAXARGS 10
|
|
|
|
#endif
|
|
|
|
|
Add a simple scripting facility to DDB(4), allowing the user to
define a set of named scripts. Each script consists of a list of DDB
commands separated by ";"s that will be executed verbatim. No higher
level language constructs, such as branching, are provided for:
scripts are executed by sequentially injecting commands into the DDB
input buffer.
Four new commands are present in DDB: "run" to run a specific script,
"script" to define or print a script, "scripts" to list currently
defined scripts, and "unscript" to delete a script, modeled on shell
alias commands. Scripts may also be manipulated using sysctls in the
debug.ddb.scripting MIB space, although users will prefer to use the
soon-to-be-added ddb(8) tool for usability reasons.
Scripts with certain names are automatically executed on various DDB
events, such as entering the debugger via a panic, a witness error,
watchdog, breakpoint, sysctl, serial break, etc, allowing customized
handling.
MFC after: 3 months
2007-12-26 09:33:19 +00:00
|
|
|
#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
|
|
|
|
|
2005-07-02 23:52:37 +00:00
|
|
|
#ifndef DB_CALL
|
|
|
|
#define DB_CALL db_fncall_generic
|
|
|
|
#else
|
|
|
|
int DB_CALL(db_expr_t, db_expr_t *, int, db_expr_t[]);
|
|
|
|
#endif
|
|
|
|
|
2014-09-25 08:28:10 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
2008-09-15 22:45:14 +00:00
|
|
|
/*
|
|
|
|
* There are three "command tables":
|
|
|
|
* - One for simple commands; a list of these is displayed
|
|
|
|
* by typing 'help' at the debugger prompt.
|
|
|
|
* - One for sub-commands of 'show'; to see this type 'show'
|
|
|
|
* without any arguments.
|
|
|
|
* - The last one for sub-commands of 'show all'; type 'show all'
|
|
|
|
* without any argument to get a list.
|
|
|
|
*/
|
|
|
|
struct command;
|
|
|
|
LIST_HEAD(command_table, command);
|
|
|
|
extern struct command_table db_cmd_table;
|
|
|
|
extern struct command_table db_show_table;
|
|
|
|
extern struct command_table db_show_all_table;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Type signature for a function implementing a ddb command.
|
|
|
|
*/
|
2015-05-21 15:16:18 +00:00
|
|
|
typedef void db_cmdfcn_t(db_expr_t addr, bool have_addr, db_expr_t count,
|
2002-03-23 11:53:03 +00:00
|
|
|
char *modif);
|
1995-11-24 13:53:05 +00:00
|
|
|
|
2008-09-15 22:45:14 +00:00
|
|
|
/*
|
|
|
|
* Command table entry.
|
|
|
|
*/
|
|
|
|
struct command {
|
|
|
|
char * name; /* command name */
|
|
|
|
db_cmdfcn_t *fcn; /* function to call */
|
|
|
|
int flag; /* extra info: */
|
|
|
|
#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 */
|
|
|
|
struct command_table *more; /* another level of command */
|
|
|
|
LIST_ENTRY(command) next; /* next entry in the command table */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-03-31 16:37:41 +00:00
|
|
|
#define _DB_SET(_suffix, _name, _func, list, _flag, _more) \
|
2008-09-15 22:45:14 +00:00
|
|
|
static struct command __CONCAT(_name,_suffix) = { \
|
|
|
|
.name = __STRING(_name), \
|
|
|
|
.fcn = _func, \
|
|
|
|
.flag = _flag, \
|
|
|
|
.more = _more \
|
1996-09-14 09:13:15 +00:00
|
|
|
}; \
|
2008-09-15 22:45:14 +00:00
|
|
|
static void __CONCAT(__CONCAT(_name,_suffix),_add)(void *arg __unused) \
|
|
|
|
{ db_command_register(&list, &__CONCAT(_name,_suffix)); } \
|
|
|
|
SYSINIT(__CONCAT(_name,_suffix), SI_SUB_KLD, SI_ORDER_ANY, \
|
|
|
|
__CONCAT(__CONCAT(_name,_suffix),_add), NULL); \
|
|
|
|
static void __CONCAT(__CONCAT(_name,_suffix),_del)(void *arg __unused) \
|
|
|
|
{ db_command_unregister(&list, &__CONCAT(_name,_suffix)); } \
|
|
|
|
SYSUNINIT(__CONCAT(_name,_suffix), SI_SUB_KLD, SI_ORDER_ANY, \
|
|
|
|
__CONCAT(__CONCAT(_name,_suffix),_del), NULL);
|
2006-03-07 22:17:06 +00:00
|
|
|
|
2008-09-15 22:45:14 +00:00
|
|
|
/*
|
|
|
|
* Like _DB_SET but also create the function declaration which
|
|
|
|
* must be followed immediately by the body; e.g.
|
|
|
|
* _DB_FUNC(_cmd, panic, db_panic, db_cmd_table, 0, NULL)
|
|
|
|
* {
|
|
|
|
* ...panic implementation...
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* This macro is mostly used to define commands placed in one of
|
|
|
|
* the ddb command tables; see DB_COMMAND, etc. below.
|
|
|
|
*/
|
2014-03-31 16:37:41 +00:00
|
|
|
#define _DB_FUNC(_suffix, _name, _func, list, _flag, _more) \
|
2008-09-15 22:45:14 +00:00
|
|
|
static db_cmdfcn_t _func; \
|
|
|
|
_DB_SET(_suffix, _name, _func, list, _flag, _more); \
|
1996-09-14 09:13:15 +00:00
|
|
|
static void \
|
2015-05-21 15:16:18 +00:00
|
|
|
_func(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
|
2008-09-15 22:45:14 +00:00
|
|
|
|
|
|
|
/* common idom provided for backwards compatibility */
|
2014-03-31 16:37:41 +00:00
|
|
|
#define DB_FUNC(_name, _func, list, _flag, _more) \
|
2008-09-15 22:45:14 +00:00
|
|
|
_DB_FUNC(_cmd, _name, _func, list, _flag, _more)
|
|
|
|
|
2014-03-31 16:37:41 +00:00
|
|
|
#define DB_COMMAND(cmd_name, func_name) \
|
2008-09-15 22:45:14 +00:00
|
|
|
_DB_FUNC(_cmd, cmd_name, func_name, db_cmd_table, 0, NULL)
|
2014-03-31 16:37:41 +00:00
|
|
|
#define DB_ALIAS(alias_name, func_name) \
|
2008-09-15 22:45:14 +00:00
|
|
|
_DB_SET(_cmd, alias_name, func_name, db_cmd_table, 0, NULL)
|
2014-03-31 16:37:41 +00:00
|
|
|
#define DB_SHOW_COMMAND(cmd_name, func_name) \
|
2008-09-15 22:45:14 +00:00
|
|
|
_DB_FUNC(_show, cmd_name, func_name, db_show_table, 0, NULL)
|
2014-03-31 16:37:41 +00:00
|
|
|
#define DB_SHOW_ALIAS(alias_name, func_name) \
|
2008-09-15 22:45:14 +00:00
|
|
|
_DB_SET(_show, alias_name, func_name, db_show_table, 0, NULL)
|
2014-03-31 16:37:41 +00:00
|
|
|
#define DB_SHOW_ALL_COMMAND(cmd_name, func_name) \
|
2008-09-15 22:45:14 +00:00
|
|
|
_DB_FUNC(_show_all, cmd_name, func_name, db_show_all_table, 0, NULL)
|
2014-03-31 16:37:41 +00:00
|
|
|
#define DB_SHOW_ALL_ALIAS(alias_name, func_name) \
|
2008-09-15 22:45:14 +00:00
|
|
|
_DB_SET(_show_all, alias_name, func_name, db_show_all_table, 0, NULL)
|
1996-09-14 09:13:15 +00:00
|
|
|
|
1998-07-08 09:11:43 +00:00
|
|
|
extern db_expr_t db_maxoff;
|
1996-09-14 09:13:15 +00:00
|
|
|
extern int db_indent;
|
1993-11-25 01:38:01 +00:00
|
|
|
extern int db_inst_count;
|
|
|
|
extern int db_load_count;
|
|
|
|
extern int db_store_count;
|
2006-07-12 21:22:44 +00:00
|
|
|
extern volatile int db_pager_quit;
|
1998-07-08 09:11:43 +00:00
|
|
|
extern db_expr_t db_radix;
|
|
|
|
extern db_expr_t db_max_width;
|
|
|
|
extern db_expr_t db_tab_stop_width;
|
2004-11-01 22:15:15 +00:00
|
|
|
extern db_expr_t db_lines_per_page;
|
1993-11-25 01:38:01 +00:00
|
|
|
|
2004-07-10 23:47:20 +00:00
|
|
|
struct thread;
|
1996-09-14 09:13:15 +00:00
|
|
|
struct vm_map;
|
1993-11-25 01:38:01 +00:00
|
|
|
|
2002-03-20 05:14:42 +00:00
|
|
|
void db_check_interrupt(void);
|
|
|
|
void db_clear_watchpoints(void);
|
2015-05-21 15:16:18 +00:00
|
|
|
db_addr_t db_disasm(db_addr_t loc, bool altfmt);
|
1995-11-24 13:53:05 +00:00
|
|
|
/* instruction disassembler */
|
2002-09-21 17:29:36 +00:00
|
|
|
void db_error(const char *s);
|
2002-03-20 05:14:42 +00:00
|
|
|
int db_expression(db_expr_t *valuep);
|
|
|
|
int db_get_variable(db_expr_t *valuep);
|
|
|
|
void db_iprintf(const char *,...) __printflike(1, 2);
|
2006-04-25 20:22:48 +00:00
|
|
|
struct proc *db_lookup_proc(db_expr_t addr);
|
2015-05-21 15:16:18 +00:00
|
|
|
struct thread *db_lookup_thread(db_expr_t addr, bool check_pid);
|
2002-03-20 05:14:42 +00:00
|
|
|
struct vm_map *db_map_addr(vm_offset_t);
|
2015-05-21 15:16:18 +00:00
|
|
|
bool db_map_current(struct vm_map *);
|
|
|
|
bool db_map_equal(struct vm_map *, struct vm_map *);
|
2005-09-10 03:01:25 +00:00
|
|
|
int db_md_set_watchpoint(db_expr_t addr, db_expr_t size);
|
|
|
|
int db_md_clr_watchpoint(db_expr_t addr, db_expr_t size);
|
|
|
|
void db_md_list_watchpoints(void);
|
2002-03-20 05:14:42 +00:00
|
|
|
void db_print_loc_and_inst(db_addr_t loc);
|
2004-07-10 23:47:20 +00:00
|
|
|
void db_print_thread(void);
|
2010-05-11 17:01:14 +00:00
|
|
|
int db_printf(const char *fmt, ...) __printflike(1, 2);
|
2004-07-10 23:47:20 +00:00
|
|
|
int db_read_bytes(vm_offset_t addr, size_t size, char *data);
|
1993-11-25 01:38:01 +00:00
|
|
|
/* machine-dependent */
|
2002-03-20 05:14:42 +00:00
|
|
|
int db_readline(char *lstart, int lsize);
|
2015-05-21 15:16:18 +00:00
|
|
|
void db_restart_at_pc(bool watchpt);
|
2004-07-10 23:47:20 +00:00
|
|
|
int db_set_variable(db_expr_t value);
|
2002-03-20 05:14:42 +00:00
|
|
|
void db_set_watchpoints(void);
|
|
|
|
void db_skip_to_eol(void);
|
2016-09-09 15:53:42 +00:00
|
|
|
bool db_stop_at_pc(int type, int code, bool *is_breakpoint,
|
|
|
|
bool *is_watchpoint);
|
1995-11-24 13:53:05 +00:00
|
|
|
#define db_strcpy strcpy
|
2004-07-10 23:47:20 +00:00
|
|
|
void db_trace_self(void);
|
2017-01-28 16:30:14 +00:00
|
|
|
void db_trace_self_depth(int);
|
2004-07-10 23:47:20 +00:00
|
|
|
int db_trace_thread(struct thread *, int);
|
2015-05-21 15:16:18 +00:00
|
|
|
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);
|
2004-07-10 23:47:20 +00:00
|
|
|
int db_write_bytes(vm_offset_t addr, size_t size, char *data);
|
2008-09-15 22:45:14 +00:00
|
|
|
void db_command_register(struct command_table *, struct command *);
|
|
|
|
void db_command_unregister(struct command_table *, struct command *);
|
2014-09-25 08:28:10 +00:00
|
|
|
int db_fetch_ksymtab(vm_offset_t ksym_start, vm_offset_t ksym_end);
|
1995-11-24 13:53:05 +00:00
|
|
|
|
|
|
|
db_cmdfcn_t db_breakpoint_cmd;
|
Add a new DDB(4) facility, output capture. Input and output from DDB may be
captured to a memory buffer for later inspection using sysctl(8), or in the
future, to a textdump.
A new DDB command, "capture", is added, which accepts arguments "on", "off",
"reset", and "status".
A new DDB sysctl tree, debug.ddb.capture, is added, which can be used to
resize the capture buffer and extract buffer contents.
MFC after: 3 months
2007-12-25 23:06:51 +00:00
|
|
|
db_cmdfcn_t db_capture_cmd;
|
1995-11-24 13:53:05 +00:00
|
|
|
db_cmdfcn_t db_continue_cmd;
|
|
|
|
db_cmdfcn_t db_delete_cmd;
|
2001-07-11 03:15:25 +00:00
|
|
|
db_cmdfcn_t db_deletehwatch_cmd;
|
1995-11-24 13:53:05 +00:00
|
|
|
db_cmdfcn_t db_deletewatch_cmd;
|
|
|
|
db_cmdfcn_t db_examine_cmd;
|
2011-12-16 11:44:20 +00:00
|
|
|
db_cmdfcn_t db_findstack_cmd;
|
2001-07-11 03:15:25 +00:00
|
|
|
db_cmdfcn_t db_hwatchpoint_cmd;
|
1995-11-24 13:53:05 +00:00
|
|
|
db_cmdfcn_t db_listbreak_cmd;
|
Add a simple scripting facility to DDB(4), allowing the user to
define a set of named scripts. Each script consists of a list of DDB
commands separated by ";"s that will be executed verbatim. No higher
level language constructs, such as branching, are provided for:
scripts are executed by sequentially injecting commands into the DDB
input buffer.
Four new commands are present in DDB: "run" to run a specific script,
"script" to define or print a script, "scripts" to list currently
defined scripts, and "unscript" to delete a script, modeled on shell
alias commands. Scripts may also be manipulated using sysctls in the
debug.ddb.scripting MIB space, although users will prefer to use the
soon-to-be-added ddb(8) tool for usability reasons.
Scripts with certain names are automatically executed on various DDB
events, such as entering the debugger via a panic, a witness error,
watchdog, breakpoint, sysctl, serial break, etc, allowing customized
handling.
MFC after: 3 months
2007-12-26 09:33:19 +00:00
|
|
|
db_cmdfcn_t db_scripts_cmd;
|
1995-11-24 13:53:05 +00:00
|
|
|
db_cmdfcn_t db_print_cmd;
|
|
|
|
db_cmdfcn_t db_ps;
|
Add a simple scripting facility to DDB(4), allowing the user to
define a set of named scripts. Each script consists of a list of DDB
commands separated by ";"s that will be executed verbatim. No higher
level language constructs, such as branching, are provided for:
scripts are executed by sequentially injecting commands into the DDB
input buffer.
Four new commands are present in DDB: "run" to run a specific script,
"script" to define or print a script, "scripts" to list currently
defined scripts, and "unscript" to delete a script, modeled on shell
alias commands. Scripts may also be manipulated using sysctls in the
debug.ddb.scripting MIB space, although users will prefer to use the
soon-to-be-added ddb(8) tool for usability reasons.
Scripts with certain names are automatically executed on various DDB
events, such as entering the debugger via a panic, a witness error,
watchdog, breakpoint, sysctl, serial break, etc, allowing customized
handling.
MFC after: 3 months
2007-12-26 09:33:19 +00:00
|
|
|
db_cmdfcn_t db_run_cmd;
|
|
|
|
db_cmdfcn_t db_script_cmd;
|
1995-11-24 13:53:05 +00:00
|
|
|
db_cmdfcn_t db_search_cmd;
|
|
|
|
db_cmdfcn_t db_set_cmd;
|
2004-07-10 23:47:20 +00:00
|
|
|
db_cmdfcn_t db_set_thread;
|
1995-11-24 13:53:05 +00:00
|
|
|
db_cmdfcn_t db_show_regs;
|
2004-07-10 23:47:20 +00:00
|
|
|
db_cmdfcn_t db_show_threads;
|
1995-11-24 13:53:05 +00:00
|
|
|
db_cmdfcn_t db_single_step_cmd;
|
Add textdump(4) facility, which provides an alternative form of kernel
dump using mechanically generated/extracted debugging output rather than
a simple memory dump. Current sources of debugging output are:
- DDB output capture buffer, if there is captured output to save
- Kernel message buffer
- Kernel configuration, if included in kernel
- Kernel version string
- Panic message
Textdumps are stored in swap/dump partitions as with regular dumps, but
are laid out as ustar files in order to allow multiple parts to be stored
as a stream of sequentially written blocks. Blocks are written out in
reverse order, as the size of a textdump isn't known a priori. As with
regular dumps, they will be extracted using savecore(8).
One new DDB(4) command is added, "textdump", which accepts "set",
"unset", and "status" arguments. By default, normal kernel dumps are
generated unless "textdump set" is run in order to schedule a textdump.
It can be canceled using "textdump unset" to restore generation of a
normal kernel dump.
Several sysctls exist to configure aspects of textdumps;
debug.ddb.textdump.pending can be set to check whether a textdump is
pending, or set/unset in order to control whether the next kernel dump
will be a textdump from userspace.
While textdumps don't have to be generated as a result of a DDB script
run automatically as part of a kernel panic, this is a particular useful
way to use them, as instead of generating a complete memory dump, a
simple transcript of an automated DDB session can be captured using the
DDB output capture and textdump facilities. This can be used to
generate quite brief kernel bug reports rich in debugging information
but not dependent on kernel symbol tables or precisely synchronized
source code. Most textdumps I generate are less than 100k including
the full message buffer. Using textdumps with an interactive debugging
session is also useful, with capture being enabled/disabled in order to
record some but not all of the DDB session.
MFC after: 3 months
2007-12-26 11:32:33 +00:00
|
|
|
db_cmdfcn_t db_textdump_cmd;
|
1995-11-24 13:53:05 +00:00
|
|
|
db_cmdfcn_t db_trace_until_call_cmd;
|
|
|
|
db_cmdfcn_t db_trace_until_matching_cmd;
|
Add a simple scripting facility to DDB(4), allowing the user to
define a set of named scripts. Each script consists of a list of DDB
commands separated by ";"s that will be executed verbatim. No higher
level language constructs, such as branching, are provided for:
scripts are executed by sequentially injecting commands into the DDB
input buffer.
Four new commands are present in DDB: "run" to run a specific script,
"script" to define or print a script, "scripts" to list currently
defined scripts, and "unscript" to delete a script, modeled on shell
alias commands. Scripts may also be manipulated using sysctls in the
debug.ddb.scripting MIB space, although users will prefer to use the
soon-to-be-added ddb(8) tool for usability reasons.
Scripts with certain names are automatically executed on various DDB
events, such as entering the debugger via a panic, a witness error,
watchdog, breakpoint, sysctl, serial break, etc, allowing customized
handling.
MFC after: 3 months
2007-12-26 09:33:19 +00:00
|
|
|
db_cmdfcn_t db_unscript_cmd;
|
1995-11-24 13:53:05 +00:00
|
|
|
db_cmdfcn_t db_watchpoint_cmd;
|
|
|
|
db_cmdfcn_t db_write_cmd;
|
|
|
|
|
Add a new DDB(4) facility, output capture. Input and output from DDB may be
captured to a memory buffer for later inspection using sysctl(8), or in the
future, to a textdump.
A new DDB command, "capture", is added, which accepts arguments "on", "off",
"reset", and "status".
A new DDB sysctl tree, debug.ddb.capture, is added, which can be used to
resize the capture buffer and extract buffer contents.
MFC after: 3 months
2007-12-25 23:06:51 +00:00
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
|
Add a simple scripting facility to DDB(4), allowing the user to
define a set of named scripts. Each script consists of a list of DDB
commands separated by ";"s that will be executed verbatim. No higher
level language constructs, such as branching, are provided for:
scripts are executed by sequentially injecting commands into the DDB
input buffer.
Four new commands are present in DDB: "run" to run a specific script,
"script" to define or print a script, "scripts" to list currently
defined scripts, and "unscript" to delete a script, modeled on shell
alias commands. Scripts may also be manipulated using sysctls in the
debug.ddb.scripting MIB space, although users will prefer to use the
soon-to-be-added ddb(8) tool for usability reasons.
Scripts with certain names are automatically executed on various DDB
events, such as entering the debugger via a panic, a witness error,
watchdog, breakpoint, sysctl, serial break, etc, allowing customized
handling.
MFC after: 3 months
2007-12-26 09:33:19 +00:00
|
|
|
/*
|
|
|
|
* Interface between DDB and the script facility.
|
|
|
|
*/
|
|
|
|
void db_script_kdbenter(const char *eventname); /* KDB enter event. */
|
|
|
|
|
Add textdump(4) facility, which provides an alternative form of kernel
dump using mechanically generated/extracted debugging output rather than
a simple memory dump. Current sources of debugging output are:
- DDB output capture buffer, if there is captured output to save
- Kernel message buffer
- Kernel configuration, if included in kernel
- Kernel version string
- Panic message
Textdumps are stored in swap/dump partitions as with regular dumps, but
are laid out as ustar files in order to allow multiple parts to be stored
as a stream of sequentially written blocks. Blocks are written out in
reverse order, as the size of a textdump isn't known a priori. As with
regular dumps, they will be extracted using savecore(8).
One new DDB(4) command is added, "textdump", which accepts "set",
"unset", and "status" arguments. By default, normal kernel dumps are
generated unless "textdump set" is run in order to schedule a textdump.
It can be canceled using "textdump unset" to restore generation of a
normal kernel dump.
Several sysctls exist to configure aspects of textdumps;
debug.ddb.textdump.pending can be set to check whether a textdump is
pending, or set/unset in order to control whether the next kernel dump
will be a textdump from userspace.
While textdumps don't have to be generated as a result of a DDB script
run automatically as part of a kernel panic, this is a particular useful
way to use them, as instead of generating a complete memory dump, a
simple transcript of an automated DDB session can be captured using the
DDB output capture and textdump facilities. This can be used to
generate quite brief kernel bug reports rich in debugging information
but not dependent on kernel symbol tables or precisely synchronized
source code. Most textdumps I generate are less than 100k including
the full message buffer. Using textdumps with an interactive debugging
session is also useful, with capture being enabled/disabled in order to
record some but not all of the DDB session.
MFC after: 3 months
2007-12-26 11:32:33 +00:00
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
|
1995-11-24 13:53:05 +00:00
|
|
|
#endif /* !_DDB_DDB_H_ */
|