xref: /dragonfly/sys/ddb/ddb.h (revision 6e285212)
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: src/sys/ddb/ddb.h,v 1.24.2.2 2002/08/30 22:27:49 gibbs Exp $
31  * $DragonFly: src/sys/ddb/ddb.h,v 1.2 2003/06/17 04:28:21 dillon Exp $
32  */
33 
34 /*
35  * Necessary declarations for the `ddb' kernel debugger.
36  */
37 
38 #ifndef _DDB_DDB_H_
39 #define	_DDB_DDB_H_
40 
41 #include <machine/db_machdep.h>		/* type definitions */
42 
43 typedef void db_cmdfcn_t __P((db_expr_t addr, boolean_t have_addr,
44 			      db_expr_t count, char *modif));
45 
46 #define DB_COMMAND(cmd_name, func_name) \
47 	DB_SET(cmd_name, func_name, db_cmd_set, 0, NULL)
48 #define DB_SHOW_COMMAND(cmd_name, func_name) \
49 	DB_SET(cmd_name, func_name, db_show_cmd_set, 0, NULL)
50 
51 #define DB_SET(cmd_name, func_name, set, flag, more)		\
52 static db_cmdfcn_t	func_name;				\
53 								\
54 static const struct command __CONCAT(func_name,_cmd) = {	\
55 	__STRING(cmd_name),					\
56 	func_name,						\
57 	flag,							\
58 	more							\
59 };								\
60 TEXT_SET(set, __CONCAT(func_name,_cmd));			\
61 								\
62 static void							\
63 func_name(addr, have_addr, count, modif)			\
64 	db_expr_t addr;						\
65 	boolean_t have_addr;					\
66 	db_expr_t count;					\
67 	char *modif;
68 
69 extern char *esym;
70 extern db_expr_t db_maxoff;
71 extern int db_active;
72 extern int db_indent;
73 extern int db_inst_count;
74 extern int db_load_count;
75 extern int debugger_on_panic;
76 extern int db_store_count;
77 extern db_expr_t db_radix;
78 extern db_expr_t db_max_width;
79 extern db_expr_t db_tab_stop_width;
80 
81 struct vm_map;
82 
83 void		db_check_interrupt __P((void));
84 void		db_clear_watchpoints __P((void));
85 db_addr_t	db_disasm __P((db_addr_t loc, boolean_t altfmt));
86 				/* instruction disassembler */
87 void		db_error __P((char *s));
88 int		db_expression __P((db_expr_t *valuep));
89 int		db_get_variable __P((db_expr_t *valuep));
90 void		db_iprintf __P((const char *,...)) __printflike(1, 2);
91 struct vm_map	*db_map_addr __P((vm_offset_t));
92 boolean_t	db_map_current __P((struct vm_map *));
93 boolean_t	db_map_equal __P((struct vm_map *, struct vm_map *));
94 void		db_print_loc_and_inst __P((db_addr_t loc));
95 void		db_printf __P((const char *fmt, ...)) __printflike(1, 2);
96 void		db_read_bytes __P((vm_offset_t addr, size_t size, char *data));
97 				/* machine-dependent */
98 int		db_readline __P((char *lstart, int lsize));
99 void		db_restart_at_pc __P((boolean_t watchpt));
100 void		db_set_watchpoints __P((void));
101 void		db_skip_to_eol __P((void));
102 boolean_t	db_stop_at_pc __P((boolean_t *is_breakpoint));
103 #define		db_strcpy	strcpy
104 void		db_trap __P((int type, int code));
105 int		db_value_of_name __P((const char *name, db_expr_t *valuep));
106 void		db_write_bytes __P((vm_offset_t addr, size_t size, char *data));
107 				/* machine-dependent */
108 void		kdb_init __P((void));
109 
110 db_cmdfcn_t	db_breakpoint_cmd;
111 db_cmdfcn_t	db_continue_cmd;
112 db_cmdfcn_t	db_delete_cmd;
113 db_cmdfcn_t	db_deletehwatch_cmd;
114 db_cmdfcn_t	db_deletewatch_cmd;
115 db_cmdfcn_t	db_examine_cmd;
116 db_cmdfcn_t	db_hwatchpoint_cmd;
117 db_cmdfcn_t	db_listbreak_cmd;
118 db_cmdfcn_t	db_print_cmd;
119 db_cmdfcn_t	db_ps;
120 db_cmdfcn_t	db_search_cmd;
121 db_cmdfcn_t	db_set_cmd;
122 db_cmdfcn_t	db_show_regs;
123 db_cmdfcn_t	db_single_step_cmd;
124 db_cmdfcn_t	db_stack_trace_cmd;
125 db_cmdfcn_t	db_trace_until_call_cmd;
126 db_cmdfcn_t	db_trace_until_matching_cmd;
127 db_cmdfcn_t	db_watchpoint_cmd;
128 db_cmdfcn_t	db_write_cmd;
129 
130 #if 0
131 db_cmdfcn_t	db_help_cmd;
132 db_cmdfcn_t	db_show_all_threads;
133 db_cmdfcn_t	db_show_one_thread;
134 db_cmdfcn_t	ipc_port_print;
135 db_cmdfcn_t	vm_page_print;
136 #endif
137 
138 /*
139  * Command table.
140  */
141 struct command {
142 	char *	name;		/* command name */
143 	db_cmdfcn_t *fcn;	/* function to call */
144 	int	flag;		/* extra info: */
145 #define	CS_OWN		0x1	/* non-standard syntax */
146 #define	CS_MORE		0x2	/* standard syntax, but may have other words
147 				 * at end */
148 #define	CS_SET_DOT	0x100	/* set dot after command */
149 	struct command *more;	/* another level of command */
150 };
151 
152 /* XXX: UGLY hack */
153 #ifdef CN_DEAD
154 /*
155  * Routines to support GDB on an sio port.
156  */
157 extern dev_t	   gdbdev;
158 extern cn_getc_t *gdb_getc;
159 extern cn_putc_t *gdb_putc;
160 #endif
161 
162 #endif /* !_DDB_DDB_H_ */
163