db_machdep.h revision 50477
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 50477 1999-08-28 01:08:13Z peter $
274Srgrimes */
284Srgrimes
295592Sbde#ifndef _MACHINE_DB_MACHDEP_H_
305592Sbde#define	_MACHINE_DB_MACHDEP_H_
314Srgrimes
3212589Sbde#include <machine/frame.h>
332578Sbde#include <machine/psl.h>
344Srgrimes
354Srgrimes#define i386_saved_state trapframe
364Srgrimes
374Srgrimestypedef	vm_offset_t	db_addr_t;	/* address - unsigned */
384Srgrimestypedef	int		db_expr_t;	/* expression - signed */
394Srgrimes
404Srgrimestypedef struct i386_saved_state db_regs_t;
41719Swollmanextern db_regs_t	ddb_regs;	/* register state */
424Srgrimes#define	DDB_REGS	(&ddb_regs)
434Srgrimes
4424344Sbde#define	PC_REGS(regs)	((db_addr_t)(regs)->tf_eip)
454Srgrimes
464Srgrimes#define	BKPT_INST	0xcc		/* breakpoint instruction */
474Srgrimes#define	BKPT_SIZE	(1)		/* size of breakpoint inst */
484Srgrimes#define	BKPT_SET(inst)	(BKPT_INST)
494Srgrimes
504Srgrimes#define	FIXUP_PC_AFTER_BREAK	ddb_regs.tf_eip -= 1;
514Srgrimes
522578Sbde#define	db_clear_single_step(regs)	((regs)->tf_eflags &= ~PSL_T)
532578Sbde#define	db_set_single_step(regs)	((regs)->tf_eflags |=  PSL_T)
544Srgrimes
554Srgrimes#define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BPTFLT)
565592Sbde/*
575592Sbde * Watchpoints are not supported.  The debug exception type is in %dr6
585592Sbde * and not yet in the args to this macro.
595592Sbde */
605592Sbde#define IS_WATCHPOINT_TRAP(type, code)	0
614Srgrimes
624Srgrimes#define	I_CALL		0xe8
634Srgrimes#define	I_CALLI		0xff
644Srgrimes#define	I_RET		0xc3
654Srgrimes#define	I_IRET		0xcf
664Srgrimes
674Srgrimes#define	inst_trap_return(ins)	(((ins)&0xff) == I_IRET)
684Srgrimes#define	inst_return(ins)	(((ins)&0xff) == I_RET)
694Srgrimes#define	inst_call(ins)		(((ins)&0xff) == I_CALL || \
704Srgrimes				 (((ins)&0xff) == I_CALLI && \
714Srgrimes				  ((ins)&0x3800) == 0x1000))
724Srgrimes#define inst_load(ins)		0
734Srgrimes#define inst_store(ins)		0
744Srgrimes
7521767Sbde/*
7621767Sbde * There no interesting addresses below _kstack = 0xefbfe000.  There
7721767Sbde * are small absolute values for GUPROF, but we don't want to see them.
7821767Sbde * Treat "negative" addresses below _kstack as non-small to allow for
7921767Sbde * future reductions of _kstack and to avoid sign extension problems.
8021767Sbde *
8121767Sbde * There is one interesting symbol above -db_maxoff = 0xffff0000,
8221767Sbde * namely _APTD = 0xfffff000.  Accepting this would mess up the
8321767Sbde * printing of small negative offsets.  The next largest symbol is
8421767Sbde * _APTmap = 0xffc00000.  Accepting this is OK (unless db_maxoff is
8521767Sbde * set to >= 0x400000 - (max stack offset)).
8621767Sbde */
8721767Sbde#define	DB_SMALL_VALUE_MAX	0x7fffffff
8821767Sbde#define	DB_SMALL_VALUE_MIN	(-0x400001)
8921767Sbde
905592Sbde#endif /* !_MACHINE_DB_MACHDEP_H_ */
91