db_machdep.h revision 114349
18876Srgrimes/*
24Srgrimes * Mach Operating System
34Srgrimes * Copyright (c) 1991,1990 Carnegie Mellon University
44Srgrimes * All Rights Reserved.
58876Srgrimes *
64Srgrimes * Permission to use, copy, modify and distribute this software and its
74Srgrimes * documentation is hereby granted, provided that both the copyright
84Srgrimes * notice and this permission notice appear in all copies of the
94Srgrimes * software, derivative works or modified versions, and any portions
104Srgrimes * thereof, and that both notices appear in supporting documentation.
118876Srgrimes *
124Srgrimes * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
134Srgrimes * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
144Srgrimes * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
158876Srgrimes *
164Srgrimes * Carnegie Mellon requests users of this software to return to
178876Srgrimes *
184Srgrimes *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
194Srgrimes *  School of Computer Science
204Srgrimes *  Carnegie Mellon University
214Srgrimes *  Pittsburgh PA 15213-3890
228876Srgrimes *
234Srgrimes * any improvements or extensions that they make and grant Carnegie Mellon
244Srgrimes * the rights to redistribute these changes.
254Srgrimes *
2650477Speter * $FreeBSD: head/sys/amd64/include/db_machdep.h 114349 2003-05-01 01:05:25Z peter $
274Srgrimes */
284Srgrimes
295592Sbde#ifndef _MACHINE_DB_MACHDEP_H_
305592Sbde#define	_MACHINE_DB_MACHDEP_H_
314Srgrimes
3212589Sbde#include <machine/frame.h>
3351931Smarcel#include <machine/psl.h>
3451792Smarcel#include <machine/trap.h>
354Srgrimes
364Srgrimes#define i386_saved_state trapframe
374Srgrimes
384Srgrimestypedef	vm_offset_t	db_addr_t;	/* address - unsigned */
39114349Spetertypedef	long		db_expr_t;	/* expression - signed */
404Srgrimes
414Srgrimestypedef struct i386_saved_state db_regs_t;
42719Swollmanextern db_regs_t	ddb_regs;	/* register state */
434Srgrimes#define	DDB_REGS	(&ddb_regs)
444Srgrimes
45114349Speter#define	PC_REGS(regs)	((db_addr_t)(regs)->tf_rip)
464Srgrimes
474Srgrimes#define	BKPT_INST	0xcc		/* breakpoint instruction */
484Srgrimes#define	BKPT_SIZE	(1)		/* size of breakpoint inst */
494Srgrimes#define	BKPT_SET(inst)	(BKPT_INST)
504Srgrimes
5183506Sdfr#define BKPT_SKIP		ddb_regs.tf_eip += 1
5283506Sdfr
534Srgrimes#define	FIXUP_PC_AFTER_BREAK	ddb_regs.tf_eip -= 1;
544Srgrimes
552578Sbde#define	db_clear_single_step(regs)	((regs)->tf_eflags &= ~PSL_T)
562578Sbde#define	db_set_single_step(regs)	((regs)->tf_eflags |=  PSL_T)
574Srgrimes
584Srgrimes#define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BPTFLT)
595592Sbde/*
605592Sbde * Watchpoints are not supported.  The debug exception type is in %dr6
615592Sbde * and not yet in the args to this macro.
625592Sbde */
635592Sbde#define IS_WATCHPOINT_TRAP(type, code)	0
644Srgrimes
654Srgrimes#define	I_CALL		0xe8
664Srgrimes#define	I_CALLI		0xff
674Srgrimes#define	I_RET		0xc3
684Srgrimes#define	I_IRET		0xcf
694Srgrimes
704Srgrimes#define	inst_trap_return(ins)	(((ins)&0xff) == I_IRET)
714Srgrimes#define	inst_return(ins)	(((ins)&0xff) == I_RET)
724Srgrimes#define	inst_call(ins)		(((ins)&0xff) == I_CALL || \
734Srgrimes				 (((ins)&0xff) == I_CALLI && \
744Srgrimes				  ((ins)&0x3800) == 0x1000))
754Srgrimes#define inst_load(ins)		0
764Srgrimes#define inst_store(ins)		0
774Srgrimes
7821767Sbde/*
7921767Sbde * There no interesting addresses below _kstack = 0xefbfe000.  There
8021767Sbde * are small absolute values for GUPROF, but we don't want to see them.
8121767Sbde * Treat "negative" addresses below _kstack as non-small to allow for
8221767Sbde * future reductions of _kstack and to avoid sign extension problems.
8321767Sbde *
8421767Sbde * There is one interesting symbol above -db_maxoff = 0xffff0000,
8521767Sbde * namely _APTD = 0xfffff000.  Accepting this would mess up the
8621767Sbde * printing of small negative offsets.  The next largest symbol is
8721767Sbde * _APTmap = 0xffc00000.  Accepting this is OK (unless db_maxoff is
8821767Sbde * set to >= 0x400000 - (max stack offset)).
8921767Sbde */
9021767Sbde#define	DB_SMALL_VALUE_MAX	0x7fffffff
9121767Sbde#define	DB_SMALL_VALUE_MIN	(-0x400001)
9221767Sbde
935592Sbde#endif /* !_MACHINE_DB_MACHDEP_H_ */
94