ddb.h revision 79573
1/*- 2 * Copyright (c) 1993, Garrett A. Wollman. 3 * Copyright (c) 1993, University of Vermont and State Agricultural College. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. Neither the name of the University nor the names of its contributors 15 * may be used to endorse or promote products derived from this software 16 * without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * $FreeBSD: head/sys/ddb/ddb.h 79573 2001-07-11 03:15:25Z bsd $ 31 */ 32 33/* 34 * Necessary declarations for the `ddb' kernel debugger. 35 */ 36 37#ifndef _DDB_DDB_H_ 38#define _DDB_DDB_H_ 39 40#include <machine/db_machdep.h> /* type definitions */ 41 42typedef void db_cmdfcn_t __P((db_expr_t addr, boolean_t have_addr, 43 db_expr_t count, char *modif)); 44 45#define DB_COMMAND(cmd_name, func_name) \ 46 DB_SET(cmd_name, func_name, db_cmd_set) 47#define DB_SHOW_COMMAND(cmd_name, func_name) \ 48 DB_SET(cmd_name, func_name, db_show_cmd_set) 49 50#define DB_SET(cmd_name, func_name, set) \ 51static db_cmdfcn_t func_name; \ 52 \ 53static const struct command __CONCAT(func_name,_cmd) = { \ 54 __STRING(cmd_name), \ 55 func_name, \ 56 0, \ 57 0, \ 58}; \ 59TEXT_SET(set, __CONCAT(func_name,_cmd)); \ 60 \ 61static void \ 62func_name(addr, have_addr, count, modif) \ 63 db_expr_t addr; \ 64 boolean_t have_addr; \ 65 db_expr_t count; \ 66 char *modif; 67 68extern char *esym; 69extern db_expr_t db_maxoff; 70extern int db_active; 71extern int db_indent; 72extern int db_inst_count; 73extern int db_load_count; 74extern int debugger_on_panic; 75extern int db_store_count; 76extern db_expr_t db_radix; 77extern db_expr_t db_max_width; 78extern db_expr_t db_tab_stop_width; 79 80struct vm_map; 81 82void db_check_interrupt __P((void)); 83void db_clear_watchpoints __P((void)); 84db_addr_t db_disasm __P((db_addr_t loc, boolean_t altfmt)); 85 /* instruction disassembler */ 86void db_error __P((char *s)); 87int db_expression __P((db_expr_t *valuep)); 88int db_get_variable __P((db_expr_t *valuep)); 89void db_iprintf __P((const char *,...)) __printflike(1, 2); 90struct vm_map *db_map_addr __P((vm_offset_t)); 91boolean_t db_map_current __P((struct vm_map *)); 92boolean_t db_map_equal __P((struct vm_map *, struct vm_map *)); 93void db_print_loc_and_inst __P((db_addr_t loc)); 94void db_printf __P((const char *fmt, ...)) __printflike(1, 2); 95void db_read_bytes __P((vm_offset_t addr, size_t size, char *data)); 96 /* machine-dependent */ 97int db_readline __P((char *lstart, int lsize)); 98void db_restart_at_pc __P((boolean_t watchpt)); 99void db_set_watchpoints __P((void)); 100void db_skip_to_eol __P((void)); 101boolean_t db_stop_at_pc __P((boolean_t *is_breakpoint)); 102#define db_strcpy strcpy 103void db_trap __P((int type, int code)); 104int db_value_of_name __P((const char *name, db_expr_t *valuep)); 105void db_write_bytes __P((vm_offset_t addr, size_t size, char *data)); 106 /* machine-dependent */ 107void kdb_init __P((void)); 108 109db_cmdfcn_t db_breakpoint_cmd; 110db_cmdfcn_t db_continue_cmd; 111db_cmdfcn_t db_delete_cmd; 112db_cmdfcn_t db_deletehwatch_cmd; 113db_cmdfcn_t db_deletewatch_cmd; 114db_cmdfcn_t db_examine_cmd; 115db_cmdfcn_t db_hwatchpoint_cmd; 116db_cmdfcn_t db_listbreak_cmd; 117db_cmdfcn_t db_print_cmd; 118db_cmdfcn_t db_ps; 119db_cmdfcn_t db_search_cmd; 120db_cmdfcn_t db_set_cmd; 121db_cmdfcn_t db_show_regs; 122db_cmdfcn_t db_single_step_cmd; 123db_cmdfcn_t db_stack_trace_cmd; 124db_cmdfcn_t db_trace_until_call_cmd; 125db_cmdfcn_t db_trace_until_matching_cmd; 126db_cmdfcn_t db_watchpoint_cmd; 127db_cmdfcn_t db_write_cmd; 128 129#if 0 130db_cmdfcn_t db_help_cmd; 131db_cmdfcn_t db_show_all_threads; 132db_cmdfcn_t db_show_one_thread; 133db_cmdfcn_t ipc_port_print; 134db_cmdfcn_t vm_page_print; 135#endif 136 137/* 138 * Command table. 139 */ 140struct command { 141 char * name; /* command name */ 142 db_cmdfcn_t *fcn; /* function to call */ 143 int flag; /* extra info: */ 144#define CS_OWN 0x1 /* non-standard syntax */ 145#define CS_MORE 0x2 /* standard syntax, but may have other words 146 * at end */ 147#define CS_SET_DOT 0x100 /* set dot after command */ 148 struct command *more; /* another level of command */ 149}; 150 151/* XXX: UGLY hack */ 152#ifdef CN_DEAD 153/* 154 * Routines to support GDB on an sio port. 155 */ 156extern dev_t gdbdev; 157extern cn_getc_t *gdb_getc; 158extern cn_putc_t *gdb_putc; 159#endif 160 161#endif /* !_DDB_DDB_H_ */ 162