ddb.h revision 97880
1139804Simp/*-
21541Srgrimes * Copyright (c) 1993, Garrett A. Wollman.
3165897Srwatson * Copyright (c) 1993, University of Vermont and State Agricultural College.
41541Srgrimes * All rights reserved.
5165897Srwatson *
6165897Srwatson * Redistribution and use in source and binary forms, with or without
7165897Srwatson * modification, are permitted provided that the following conditions
81541Srgrimes * are met:
91541Srgrimes * 1. Redistributions of source code must retain the above copyright
101541Srgrimes *    notice, this list of conditions and the following disclaimer.
111541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
121541Srgrimes *    notice, this list of conditions and the following disclaimer in the
131541Srgrimes *    documentation and/or other materials provided with the distribution.
141541Srgrimes * 3. Neither the name of the University nor the names of its contributors
151541Srgrimes *    may be used to endorse or promote products derived from this software
161541Srgrimes *    without specific prior written permission.
171541Srgrimes *
181541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
191541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
201541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
211541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
221541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
231541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
241541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
251541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
261541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
271541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
281541Srgrimes * SUCH DAMAGE.
291541Srgrimes *
301541Srgrimes * $FreeBSD: head/sys/ddb/ddb.h 97880 2002-06-05 19:00:02Z gibbs $
311541Srgrimes */
321541Srgrimes
331541Srgrimes/*
341541Srgrimes * Necessary declarations for the `ddb' kernel debugger.
351541Srgrimes */
361541Srgrimes
371541Srgrimes#ifndef _DDB_DDB_H_
381541Srgrimes#define	_DDB_DDB_H_
391541Srgrimes
401541Srgrimes#include <machine/db_machdep.h>		/* type definitions */
411541Srgrimes
421541Srgrimestypedef void db_cmdfcn_t(db_expr_t addr, boolean_t have_addr, db_expr_t count,
431541Srgrimes	    char *modif);
44116182Sobrien
45116182Sobrien#define DB_COMMAND(cmd_name, func_name) \
46116182Sobrien	DB_SET(cmd_name, func_name, db_cmd_set, 0, NULL)
4731778Seivind#define DB_SHOW_COMMAND(cmd_name, func_name) \
48183982Sbz	DB_SET(cmd_name, func_name, db_show_cmd_set, 0, NULL)
49183982Sbz
5031778Seivind#define DB_SET(cmd_name, func_name, set, flag, more)		\
511541Srgrimesstatic db_cmdfcn_t	func_name;				\
5276166Smarkm								\
531541Srgrimesstatic const struct command __CONCAT(func_name,_cmd) = {	\
54132548Srwatson	__STRING(cmd_name),					\
5541059Speter	func_name,						\
5670317Sjake	flag,							\
57219304Strasz	more							\
5891140Stanimura};								\
5976166SmarkmTEXT_SET(set, __CONCAT(func_name,_cmd));			\
60150634Sjhb								\
6191140Stanimurastatic void							\
62164032Srwatsonfunc_name(addr, have_addr, count, modif)			\
631541Srgrimes	db_expr_t addr;						\
6476166Smarkm	boolean_t have_addr;					\
6587218Srwatson	db_expr_t count;					\
6631891Ssef	char *modif;
67220212Strasz
6865495Struckmanextern char *esym;
6992976Srwatsonextern db_expr_t db_maxoff;
7092976Srwatsonextern int db_active;
71160139Sjhbextern int db_indent;
7261287Srwatsonextern int db_inst_count;
731541Srgrimesextern int db_load_count;
74219028Snetchildextern int debugger_on_panic;
75219028Snetchildextern int db_store_count;
76229818Shrsextern db_expr_t db_radix;
77219028Snetchildextern db_expr_t db_max_width;
78219028Snetchildextern db_expr_t db_tab_stop_width;
79183982Sbz
80183982Sbzstruct vm_map;
81183982Sbz
82183982Sbzvoid		db_check_interrupt(void);
83183982Sbzvoid		db_clear_watchpoints(void);
84155370Swsalamondb_addr_t	db_disasm(db_addr_t loc, boolean_t altfmt);
85163606Srwatson				/* instruction disassembler */
86155370Swsalamonvoid		db_error(char *s);
8730354Sphkint		db_expression(db_expr_t *valuep);
8830354Sphkint		db_get_variable(db_expr_t *valuep);
89162383Srwatsonvoid		db_iprintf(const char *,...) __printflike(1, 2);
9087138Srwatsonstruct vm_map	*db_map_addr(vm_offset_t);
91194498Sbrooksboolean_t	db_map_current(struct vm_map *);
92194498Sbrooksboolean_t	db_map_equal(struct vm_map *, struct vm_map *);
93194498Sbrooksvoid		db_print_loc_and_inst(db_addr_t loc);
9412221Sbdevoid		db_printf(const char *fmt, ...) __printflike(1, 2);
9511332Sswallacevoid		db_read_bytes(vm_offset_t addr, size_t size, char *data);
961541Srgrimes				/* machine-dependent */
971541Srgrimesint		db_readline(char *lstart, int lsize);
9812221Sbdevoid		db_restart_at_pc(boolean_t watchpt);
991541Srgrimesvoid		db_set_watchpoints(void);
1001549Srgrimesvoid		db_skip_to_eol(void);
101225617Skmacyboolean_t	db_stop_at_pc(boolean_t *is_breakpoint);
1021541Srgrimes#define		db_strcpy	strcpy
10383366Sjulianvoid		db_trap(int type, int code);
1041541Srgrimesint		db_value_of_name(const char *name, db_expr_t *valuep);
10583366Sjulianvoid		db_write_bytes(vm_offset_t addr, size_t size, char *data);
106130344Sphk				/* machine-dependent */
10774728Sjhbvoid		kdb_init(void);
10883366Sjulian
10974728Sjhbdb_cmdfcn_t	db_breakpoint_cmd;
1101541Srgrimesdb_cmdfcn_t	db_continue_cmd;
1111541Srgrimesdb_cmdfcn_t	db_delete_cmd;
1121541Srgrimesdb_cmdfcn_t	db_deletehwatch_cmd;
1131541Srgrimesdb_cmdfcn_t	db_deletewatch_cmd;
11412221Sbdedb_cmdfcn_t	db_examine_cmd;
11511332Sswallacedb_cmdfcn_t	db_hwatchpoint_cmd;
11611332Sswallacedb_cmdfcn_t	db_listbreak_cmd;
11711332Sswallacedb_cmdfcn_t	db_print_cmd;
11812221Sbdedb_cmdfcn_t	db_ps;
1191541Srgrimesdb_cmdfcn_t	db_search_cmd;
1201549Srgrimesdb_cmdfcn_t	db_set_cmd;
121225617Skmacydb_cmdfcn_t	db_show_regs;
1221541Srgrimesdb_cmdfcn_t	db_single_step_cmd;
12383366Sjuliandb_cmdfcn_t	db_stack_trace_cmd;
1241541Srgrimesdb_cmdfcn_t	db_trace_until_call_cmd;
12574728Sjhbdb_cmdfcn_t	db_trace_until_matching_cmd;
12683366Sjuliandb_cmdfcn_t	db_watchpoint_cmd;
12774728Sjhbdb_cmdfcn_t	db_write_cmd;
1281541Srgrimes
1291541Srgrimes#if 0
1301541Srgrimesdb_cmdfcn_t	db_help_cmd;
13187466Srwatsondb_cmdfcn_t	db_show_all_threads;
13287218Srwatsondb_cmdfcn_t	db_show_one_thread;
13358717Sdillondb_cmdfcn_t	ipc_port_print;
13412221Sbdedb_cmdfcn_t	vm_page_print;
13511332Sswallace#endif
13611332Sswallace
13711332Sswallace/*
13812221Sbde * Command table.
1391549Srgrimes */
140225617Skmacystruct command {
1411541Srgrimes	char *	name;		/* command name */
14283366Sjulian	db_cmdfcn_t *fcn;	/* function to call */
1431541Srgrimes	int	flag;		/* extra info: */
14491140Stanimura#define	CS_OWN		0x1	/* non-standard syntax */
14583366Sjulian#define	CS_MORE		0x2	/* standard syntax, but may have other words
14691140Stanimura				 * at end */
1471541Srgrimes#define	CS_SET_DOT	0x100	/* set dot after command */
1481541Srgrimes	struct command *more;	/* another level of command */
1491541Srgrimes};
15028401Speter
15112221Sbde/* XXX: UGLY hack */
15228401Speter#ifdef CN_DEAD
15328401Speter/*
15428401Speter * Routines to support GDB on an sio port.
15528401Speter */
15628401Speterextern dev_t	   gdbdev;
157225617Skmacyextern cn_getc_t *gdb_getc;
15828401Speterextern cn_putc_t *gdb_putc;
159114031Sjhb#endif
16092985Sjhb
16141726Struckman#endif /* !_DDB_DDB_H_ */
16291140Stanimura