1139731Simp/*-
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: releng/10.3/sys/amd64/include/db_machdep.h 139731 2005-01-05 20:17:21Z imp $
274Srgrimes */
284Srgrimes
295592Sbde#ifndef _MACHINE_DB_MACHDEP_H_
305592Sbde#define	_MACHINE_DB_MACHDEP_H_
314Srgrimes
3212589Sbde#include <machine/frame.h>
3351792Smarcel#include <machine/trap.h>
344Srgrimes
354Srgrimestypedef	vm_offset_t	db_addr_t;	/* address - unsigned */
36114349Spetertypedef	long		db_expr_t;	/* expression - signed */
374Srgrimes
38131952Smarcel#define	PC_REGS()	((db_addr_t)kdb_thrctx->pcb_rip)
394Srgrimes
404Srgrimes#define	BKPT_INST	0xcc		/* breakpoint instruction */
414Srgrimes#define	BKPT_SIZE	(1)		/* size of breakpoint inst */
424Srgrimes#define	BKPT_SET(inst)	(BKPT_INST)
434Srgrimes
44135561Speter#define BKPT_SKIP				\
45135561Speterdo {						\
46135561Speter	kdb_frame->tf_rip += 1;			\
47135561Speter	kdb_thrctx->pcb_rip += 1;		\
48135561Speter} while(0)
4983506Sdfr
50135561Speter#define	FIXUP_PC_AFTER_BREAK			\
51135561Speterdo {						\
52135561Speter	kdb_frame->tf_rip -= 1;			\
53135561Speter	kdb_thrctx->pcb_rip -= 1;		\
54135561Speter} while(0);
554Srgrimes
56131952Smarcel#define	db_clear_single_step	kdb_cpu_clear_singlestep
57131952Smarcel#define	db_set_single_step	kdb_cpu_set_singlestep
584Srgrimes
594Srgrimes#define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BPTFLT)
605592Sbde/*
615592Sbde * Watchpoints are not supported.  The debug exception type is in %dr6
625592Sbde * and not yet in the args to this macro.
635592Sbde */
645592Sbde#define IS_WATCHPOINT_TRAP(type, code)	0
654Srgrimes
664Srgrimes#define	I_CALL		0xe8
674Srgrimes#define	I_CALLI		0xff
684Srgrimes#define	I_RET		0xc3
694Srgrimes#define	I_IRET		0xcf
704Srgrimes
714Srgrimes#define	inst_trap_return(ins)	(((ins)&0xff) == I_IRET)
724Srgrimes#define	inst_return(ins)	(((ins)&0xff) == I_RET)
734Srgrimes#define	inst_call(ins)		(((ins)&0xff) == I_CALL || \
744Srgrimes				 (((ins)&0xff) == I_CALLI && \
754Srgrimes				  ((ins)&0x3800) == 0x1000))
764Srgrimes#define inst_load(ins)		0
774Srgrimes#define inst_store(ins)		0
784Srgrimes
7921767Sbde/*
8021767Sbde * There no interesting addresses below _kstack = 0xefbfe000.  There
8121767Sbde * are small absolute values for GUPROF, but we don't want to see them.
8221767Sbde * Treat "negative" addresses below _kstack as non-small to allow for
8321767Sbde * future reductions of _kstack and to avoid sign extension problems.
8421767Sbde *
8521767Sbde * There is one interesting symbol above -db_maxoff = 0xffff0000,
8621767Sbde * namely _APTD = 0xfffff000.  Accepting this would mess up the
8721767Sbde * printing of small negative offsets.  The next largest symbol is
8821767Sbde * _APTmap = 0xffc00000.  Accepting this is OK (unless db_maxoff is
8921767Sbde * set to >= 0x400000 - (max stack offset)).
9021767Sbde */
9121767Sbde#define	DB_SMALL_VALUE_MAX	0x7fffffff
9221767Sbde#define	DB_SMALL_VALUE_MIN	(-0x400001)
9321767Sbde
945592Sbde#endif /* !_MACHINE_DB_MACHDEP_H_ */
95