db_machdep.h revision 51931
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 51931 1999-10-04 13:55:35Z marcel $
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 */
394Srgrimestypedef	int		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
4524344Sbde#define	PC_REGS(regs)	((db_addr_t)(regs)->tf_eip)
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
514Srgrimes#define	FIXUP_PC_AFTER_BREAK	ddb_regs.tf_eip -= 1;
524Srgrimes
532578Sbde#define	db_clear_single_step(regs)	((regs)->tf_eflags &= ~PSL_T)
542578Sbde#define	db_set_single_step(regs)	((regs)->tf_eflags |=  PSL_T)
554Srgrimes
564Srgrimes#define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BPTFLT)
575592Sbde/*
585592Sbde * Watchpoints are not supported.  The debug exception type is in %dr6
595592Sbde * and not yet in the args to this macro.
605592Sbde */
615592Sbde#define IS_WATCHPOINT_TRAP(type, code)	0
624Srgrimes
634Srgrimes#define	I_CALL		0xe8
644Srgrimes#define	I_CALLI		0xff
654Srgrimes#define	I_RET		0xc3
664Srgrimes#define	I_IRET		0xcf
674Srgrimes
684Srgrimes#define	inst_trap_return(ins)	(((ins)&0xff) == I_IRET)
694Srgrimes#define	inst_return(ins)	(((ins)&0xff) == I_RET)
704Srgrimes#define	inst_call(ins)		(((ins)&0xff) == I_CALL || \
714Srgrimes				 (((ins)&0xff) == I_CALLI && \
724Srgrimes				  ((ins)&0x3800) == 0x1000))
734Srgrimes#define inst_load(ins)		0
744Srgrimes#define inst_store(ins)		0
754Srgrimes
7621767Sbde/*
7721767Sbde * There no interesting addresses below _kstack = 0xefbfe000.  There
7821767Sbde * are small absolute values for GUPROF, but we don't want to see them.
7921767Sbde * Treat "negative" addresses below _kstack as non-small to allow for
8021767Sbde * future reductions of _kstack and to avoid sign extension problems.
8121767Sbde *
8221767Sbde * There is one interesting symbol above -db_maxoff = 0xffff0000,
8321767Sbde * namely _APTD = 0xfffff000.  Accepting this would mess up the
8421767Sbde * printing of small negative offsets.  The next largest symbol is
8521767Sbde * _APTmap = 0xffc00000.  Accepting this is OK (unless db_maxoff is
8621767Sbde * set to >= 0x400000 - (max stack offset)).
8721767Sbde */
8821767Sbde#define	DB_SMALL_VALUE_MAX	0x7fffffff
8921767Sbde#define	DB_SMALL_VALUE_MIN	(-0x400001)
9021767Sbde
915592Sbde#endif /* !_MACHINE_DB_MACHDEP_H_ */
92