From 6145ccc494dd78b38c63342fcc1fbcd59fd4eff9 Mon Sep 17 00:00:00 2001 From: bde Date: Sat, 14 Sep 1996 09:13:15 +0000 Subject: Support statically attaching of ddb commands in non-ddb modules. The details are hidden in the DB_COMMAND(cmd_name, func_name) and DB_SHOW_COMMAND(cmd_name, func_name) macros. DB_COMMAND() adds to the top-level ddb command table and DB_SHOW_COMMAND adds to the `show' subtable. Most external commands will probably be `show' commands with no side effects. They should check their pointer args more carefully than `show map' :-), or ddb should trap internal faults better (like it does for memory accesses). The vm ddb commands are temporarily unattached. ddb.h: Also declare `db_indent' and db_iprintf() which will replace vm's `indent' and iprintf(). --- sys/ddb/ddb.h | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) (limited to 'sys/ddb/ddb.h') diff --git a/sys/ddb/ddb.h b/sys/ddb/ddb.h index 9ebb68c..193bddb 100644 --- a/sys/ddb/ddb.h +++ b/sys/ddb/ddb.h @@ -27,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ddb.h,v 1.10 1995/12/10 13:32:43 phk Exp $ + * $Id: ddb.h,v 1.11 1996/05/08 04:28:36 gpalmer Exp $ */ /* @@ -42,11 +42,32 @@ typedef void db_cmdfcn_t __P((db_expr_t addr, boolean_t have_addr, db_expr_t count, char *modif)); -/* - * Global variables... - */ +#define DB_COMMAND(cmd_name, func_name) \ + DB_SET(cmd_name, func_name, db_cmd_set) +#define DB_SHOW_COMMAND(cmd_name, func_name) \ + DB_SET(cmd_name, func_name, db_show_cmd_set) + +#define DB_SET(cmd_name, func_name, set) \ +static db_cmdfcn_t func_name; \ + \ +static const struct command __CONCAT(func_name,_cmd) = { \ + __STRING(cmd_name), \ + func_name, \ + 0, \ + 0, \ +}; \ +TEXT_SET(set, __CONCAT(func_name,_cmd)); \ + \ +static void \ +func_name(addr, have_addr, count, modif) \ + db_expr_t addr; \ + boolean_t have_addr; \ + db_expr_t count; \ + char *modif; + extern char *esym; extern unsigned int db_maxoff; +extern int db_indent; extern int db_inst_count; extern int db_load_count; extern int db_store_count; @@ -54,11 +75,7 @@ extern int db_radix; extern int db_max_width; extern int db_tab_stop_width; -struct vm_map; /* forward declaration */ - -/* - * Functions... - */ +struct vm_map; void cnpollc __P((int)); void db_check_interrupt __P((void)); @@ -68,6 +85,7 @@ db_addr_t db_disasm __P((db_addr_t loc, boolean_t altfmt)); void db_error __P((char *s)); int db_expression __P((db_expr_t *valuep)); int db_get_variable __P((db_expr_t *valuep)); +void db_iprintf __P((const char *,...)); struct vm_map *db_map_addr __P((vm_offset_t)); boolean_t db_map_current __P((struct vm_map *)); boolean_t db_map_equal __P((struct vm_map *, struct vm_map *)); @@ -115,4 +133,18 @@ db_cmdfcn_t ipc_port_print; db_cmdfcn_t vm_page_print; #endif +/* + * Command table. + */ +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 *more; /* another level of command */ +}; + #endif /* !_DDB_DDB_H_ */ -- cgit v1.1