xref: /freebsd/sys/ddb/ddb.h (revision 6337f4efa89277ef1e67a8bf6f310ada97bc0d9b)
1381fe1aaSGarrett Wollman /*-
2381fe1aaSGarrett Wollman  * Copyright (c) 1993, Garrett A. Wollman.
3381fe1aaSGarrett Wollman  * Copyright (c) 1993, University of Vermont and State Agricultural College.
4381fe1aaSGarrett Wollman  * All rights reserved.
5381fe1aaSGarrett Wollman  *
6381fe1aaSGarrett Wollman  * Redistribution and use in source and binary forms, with or without
7381fe1aaSGarrett Wollman  * modification, are permitted provided that the following conditions
8381fe1aaSGarrett Wollman  * are met:
9381fe1aaSGarrett Wollman  * 1. Redistributions of source code must retain the above copyright
10381fe1aaSGarrett Wollman  *    notice, this list of conditions and the following disclaimer.
11381fe1aaSGarrett Wollman  * 2. Redistributions in binary form must reproduce the above copyright
12381fe1aaSGarrett Wollman  *    notice, this list of conditions and the following disclaimer in the
13381fe1aaSGarrett Wollman  *    documentation and/or other materials provided with the distribution.
14381fe1aaSGarrett Wollman  * 3. Neither the name of the University nor the names of its contributors
15381fe1aaSGarrett Wollman  *    may be used to endorse or promote products derived from this software
16381fe1aaSGarrett Wollman  *    without specific prior written permission.
17381fe1aaSGarrett Wollman  *
18381fe1aaSGarrett Wollman  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19381fe1aaSGarrett Wollman  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20381fe1aaSGarrett Wollman  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21381fe1aaSGarrett Wollman  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22381fe1aaSGarrett Wollman  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23381fe1aaSGarrett Wollman  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24381fe1aaSGarrett Wollman  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25381fe1aaSGarrett Wollman  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26381fe1aaSGarrett Wollman  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27381fe1aaSGarrett Wollman  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28381fe1aaSGarrett Wollman  * SUCH DAMAGE.
29381fe1aaSGarrett Wollman  *
306337f4efSBruce Evans  *	$Id: ddb.h,v 1.11 1996/05/08 04:28:36 gpalmer Exp $
31381fe1aaSGarrett Wollman  */
32381fe1aaSGarrett Wollman 
33381fe1aaSGarrett Wollman /*
34381fe1aaSGarrett Wollman  * Necessary declarations for the `ddb' kernel debugger.
35381fe1aaSGarrett Wollman  */
36381fe1aaSGarrett Wollman 
374753168fSBruce Evans #ifndef _DDB_DDB_H_
384753168fSBruce Evans #define	_DDB_DDB_H_
39381fe1aaSGarrett Wollman 
4026f9a767SRodney W. Grimes #include <machine/db_machdep.h>		/* type definitions */
41381fe1aaSGarrett Wollman 
424753168fSBruce Evans typedef void db_cmdfcn_t __P((db_expr_t addr, boolean_t have_addr,
434753168fSBruce Evans 			      db_expr_t count, char *modif));
444753168fSBruce Evans 
456337f4efSBruce Evans #define DB_COMMAND(cmd_name, func_name) \
466337f4efSBruce Evans 	DB_SET(cmd_name, func_name, db_cmd_set)
476337f4efSBruce Evans #define DB_SHOW_COMMAND(cmd_name, func_name) \
486337f4efSBruce Evans 	DB_SET(cmd_name, func_name, db_show_cmd_set)
496337f4efSBruce Evans 
506337f4efSBruce Evans #define DB_SET(cmd_name, func_name, set)			\
516337f4efSBruce Evans static db_cmdfcn_t	func_name;				\
526337f4efSBruce Evans 								\
536337f4efSBruce Evans static const struct command __CONCAT(func_name,_cmd) = {	\
546337f4efSBruce Evans 	__STRING(cmd_name),					\
556337f4efSBruce Evans 	func_name,						\
566337f4efSBruce Evans 	0,							\
576337f4efSBruce Evans 	0,							\
586337f4efSBruce Evans };								\
596337f4efSBruce Evans TEXT_SET(set, __CONCAT(func_name,_cmd));			\
606337f4efSBruce Evans 								\
616337f4efSBruce Evans static void							\
626337f4efSBruce Evans func_name(addr, have_addr, count, modif)			\
636337f4efSBruce Evans 	db_expr_t addr;						\
646337f4efSBruce Evans 	boolean_t have_addr;					\
656337f4efSBruce Evans 	db_expr_t count;					\
666337f4efSBruce Evans 	char *modif;
676337f4efSBruce Evans 
68381fe1aaSGarrett Wollman extern char *esym;
69381fe1aaSGarrett Wollman extern unsigned int db_maxoff;
706337f4efSBruce Evans extern int db_indent;
71381fe1aaSGarrett Wollman extern int db_inst_count;
72381fe1aaSGarrett Wollman extern int db_load_count;
73381fe1aaSGarrett Wollman extern int db_store_count;
74381fe1aaSGarrett Wollman extern int db_radix;
75381fe1aaSGarrett Wollman extern int db_max_width;
76381fe1aaSGarrett Wollman extern int db_tab_stop_width;
77381fe1aaSGarrett Wollman 
786337f4efSBruce Evans struct vm_map;
79381fe1aaSGarrett Wollman 
804753168fSBruce Evans void		cnpollc __P((int));
814753168fSBruce Evans void		db_check_interrupt __P((void));
824753168fSBruce Evans void		db_clear_watchpoints __P((void));
834753168fSBruce Evans db_addr_t	db_disasm __P((db_addr_t loc, boolean_t altfmt));
84381fe1aaSGarrett Wollman 				/* instruction disassembler */
854753168fSBruce Evans void		db_error __P((char *s));
864753168fSBruce Evans int		db_expression __P((db_expr_t *valuep));
874753168fSBruce Evans int		db_get_variable __P((db_expr_t *valuep));
886337f4efSBruce Evans void		db_iprintf __P((const char *,...));
894753168fSBruce Evans struct vm_map	*db_map_addr __P((vm_offset_t));
904753168fSBruce Evans boolean_t	db_map_current __P((struct vm_map *));
914753168fSBruce Evans boolean_t	db_map_equal __P((struct vm_map *, struct vm_map *));
924753168fSBruce Evans void		db_print_loc_and_inst __P((db_addr_t loc));
934753168fSBruce Evans void		db_printf __P((const char *fmt, ...));
944753168fSBruce Evans void		db_read_bytes __P((vm_offset_t addr, int size, char *data));
954753168fSBruce Evans 				/* machine-dependent */
964753168fSBruce Evans int		db_readline __P((char *lstart, int lsize));
974753168fSBruce Evans void		db_restart_at_pc __P((boolean_t watchpt));
984753168fSBruce Evans void		db_set_watchpoints __P((void));
994753168fSBruce Evans void		db_skip_to_eol __P((void));
1004753168fSBruce Evans boolean_t	db_stop_at_pc __P((boolean_t *is_breakpoint));
1014753168fSBruce Evans #define		db_strcpy	strcpy
1024753168fSBruce Evans void		db_trap __P((int type, int code));
1034753168fSBruce Evans int		db_value_of_name __P((char *name, db_expr_t *valuep));
1044753168fSBruce Evans void		db_write_bytes __P((vm_offset_t addr, int size, char *data));
1054753168fSBruce Evans 				/* machine-dependent */
1064753168fSBruce Evans void		kdb_init __P((void));
1074753168fSBruce Evans void		kdbprintf __P((const char *fmt, ...));
108381fe1aaSGarrett Wollman 
1094753168fSBruce Evans db_cmdfcn_t	db_breakpoint_cmd;
1104753168fSBruce Evans db_cmdfcn_t	db_continue_cmd;
1114753168fSBruce Evans db_cmdfcn_t	db_delete_cmd;
1124753168fSBruce Evans db_cmdfcn_t	db_deletewatch_cmd;
1134753168fSBruce Evans db_cmdfcn_t	db_examine_cmd;
1144753168fSBruce Evans db_cmdfcn_t	db_listbreak_cmd;
1154753168fSBruce Evans db_cmdfcn_t	db_listwatch_cmd;
1164753168fSBruce Evans db_cmdfcn_t	db_print_cmd;
1174753168fSBruce Evans db_cmdfcn_t	db_ps;
1184753168fSBruce Evans db_cmdfcn_t	db_search_cmd;
1194753168fSBruce Evans db_cmdfcn_t	db_set_cmd;
1204753168fSBruce Evans db_cmdfcn_t	db_show_regs;
1214753168fSBruce Evans db_cmdfcn_t	db_single_step_cmd;
1224753168fSBruce Evans db_cmdfcn_t	db_stack_trace_cmd;
1234753168fSBruce Evans db_cmdfcn_t	db_trace_until_call_cmd;
1244753168fSBruce Evans db_cmdfcn_t	db_trace_until_matching_cmd;
1254753168fSBruce Evans db_cmdfcn_t	db_watchpoint_cmd;
1264753168fSBruce Evans db_cmdfcn_t	db_write_cmd;
127381fe1aaSGarrett Wollman 
1284753168fSBruce Evans #if 0
1294753168fSBruce Evans db_cmdfcn_t	db_help_cmd;
1304753168fSBruce Evans db_cmdfcn_t	db_show_all_threads;
1314753168fSBruce Evans db_cmdfcn_t	db_show_one_thread;
1324753168fSBruce Evans db_cmdfcn_t	ipc_port_print;
1334753168fSBruce Evans db_cmdfcn_t	vm_page_print;
1344753168fSBruce Evans #endif
135381fe1aaSGarrett Wollman 
1366337f4efSBruce Evans /*
1376337f4efSBruce Evans  * Command table.
1386337f4efSBruce Evans  */
1396337f4efSBruce Evans struct command {
1406337f4efSBruce Evans 	char *	name;		/* command name */
1416337f4efSBruce Evans 	db_cmdfcn_t *fcn;	/* function to call */
1426337f4efSBruce Evans 	int	flag;		/* extra info: */
1436337f4efSBruce Evans #define	CS_OWN		0x1	/* non-standard syntax */
1446337f4efSBruce Evans #define	CS_MORE		0x2	/* standard syntax, but may have other words
1456337f4efSBruce Evans 				 * at end */
1466337f4efSBruce Evans #define	CS_SET_DOT	0x100	/* set dot after command */
1476337f4efSBruce Evans 	struct command *more;	/* another level of command */
1486337f4efSBruce Evans };
1496337f4efSBruce Evans 
1504753168fSBruce Evans #endif /* !_DDB_DDB_H_ */
151