db_machdep.h revision 4
14Srgrimes/*
24Srgrimes * Mach Operating System
34Srgrimes * Copyright (c) 1991,1990 Carnegie Mellon University
44Srgrimes * All Rights Reserved.
54Srgrimes *
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.
114Srgrimes *
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.
154Srgrimes *
164Srgrimes * Carnegie Mellon requests users of this software to return to
174Srgrimes *
184Srgrimes *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
194Srgrimes *  School of Computer Science
204Srgrimes *  Carnegie Mellon University
214Srgrimes *  Pittsburgh PA 15213-3890
224Srgrimes *
234Srgrimes * any improvements or extensions that they make and grant Carnegie Mellon
244Srgrimes * the rights to redistribute these changes.
254Srgrimes */
264Srgrimes/*
274Srgrimes * HISTORY
284Srgrimes * $Log:	db_machdep.h,v $
294Srgrimes * Revision 2.8  92/02/19  15:07:56  elf
304Srgrimes * 	Added db_thread_fp_used.
314Srgrimes * 	[92/02/19            rpd]
324Srgrimes *
334Srgrimes * Revision 2.7  91/10/09  16:06:28  af
344Srgrimes * 	 Revision 2.6.3.1  91/10/05  13:10:32  jeffreyh
354Srgrimes * 	 	Added access and task name macros.
364Srgrimes * 	 	[91/08/29            tak]
374Srgrimes *
384Srgrimes * Revision 2.6.3.1  91/10/05  13:10:32  jeffreyh
394Srgrimes * 	Added access and task name macros.
404Srgrimes * 	[91/08/29            tak]
414Srgrimes *
424Srgrimes * Revision 2.6  91/05/14  16:05:58  mrt
434Srgrimes * 	Correcting copyright
444Srgrimes *
454Srgrimes * Revision 2.5  91/02/05  17:11:17  mrt
464Srgrimes * 	Changed to new Mach copyright
474Srgrimes * 	[91/02/01  17:31:24  mrt]
484Srgrimes *
494Srgrimes * Revision 2.4  91/01/08  15:10:16  rpd
504Srgrimes * 	Added dummy inst_load/inst_store macros.
514Srgrimes * 	[90/12/11            rpd]
524Srgrimes *
534Srgrimes * Revision 2.3  90/10/25  14:44:49  rwd
544Srgrimes * 	Added watchpoint support.
554Srgrimes * 	[90/10/18            rpd]
564Srgrimes *
574Srgrimes * Revision 2.2  90/08/27  21:56:15  dbg
584Srgrimes * 	Created.
594Srgrimes * 	[90/07/25            dbg]
604Srgrimes *
614Srgrimes */
624Srgrimes
634Srgrimes#ifndef	_I386_DB_MACHDEP_H_
644Srgrimes#define	_I386_DB_MACHDEP_H_
654Srgrimes
664Srgrimes/*
674Srgrimes * Machine-dependent defines for new kernel debugger.
684Srgrimes */
694Srgrimes
704Srgrimes
714Srgrimes/* #include <mach/i386/vm_types.h> */
724Srgrimes/* #include <mach/i386/vm_param.h> */
734Srgrimes#include <vm/vm_prot.h>
744Srgrimes#include <vm/vm_param.h>
754Srgrimes#include <vm/vm_inherit.h>
764Srgrimes#include <vm/lock.h>
774Srgrimes/* #include <i386/thread.h> */		/* for thread_status */
784Srgrimes#include <machine/frame.h>	/* for struct trapframe */
794Srgrimes/* #include <i386/eflags.h> */
804Srgrimes#include <machine/eflags.h>		/* from Mach... */
814Srgrimes/* #include <i386/trap.h> */
824Srgrimes#include <machine/trap.h>
834Srgrimes
844Srgrimes#define i386_saved_state trapframe
854Srgrimes/* end of mangling */
864Srgrimes
874Srgrimestypedef	vm_offset_t	db_addr_t;	/* address - unsigned */
884Srgrimestypedef	int		db_expr_t;	/* expression - signed */
894Srgrimes
904Srgrimestypedef struct i386_saved_state db_regs_t;
914Srgrimesdb_regs_t	ddb_regs;	/* register state */
924Srgrimes#define	DDB_REGS	(&ddb_regs)
934Srgrimes
944Srgrimes#define	PC_REGS(regs)	((db_addr_t)(regs)->tf_eip)
954Srgrimes
964Srgrimes#define	BKPT_INST	0xcc		/* breakpoint instruction */
974Srgrimes#define	BKPT_SIZE	(1)		/* size of breakpoint inst */
984Srgrimes#define	BKPT_SET(inst)	(BKPT_INST)
994Srgrimes
1004Srgrimes#define	FIXUP_PC_AFTER_BREAK	ddb_regs.tf_eip -= 1;
1014Srgrimes
1024Srgrimes#define	db_clear_single_step(regs)	((regs)->tf_eflags &= ~EFL_TF)
1034Srgrimes#define	db_set_single_step(regs)	((regs)->tf_eflags |=  EFL_TF)
1044Srgrimes
1054Srgrimes/* #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_INT3) */
1064Srgrimes/* #define IS_WATCHPOINT_TRAP(type, code)	((type) == T_WATCHPOINT) */
1074Srgrimes/* using the 386bsd values, rather than the Mach ones: */
1084Srgrimes#define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BPTFLT)
1094Srgrimes#define IS_WATCHPOINT_TRAP(type, code)	((type) == T_KDBTRAP)
1104Srgrimes
1114Srgrimes#define	I_CALL		0xe8
1124Srgrimes#define	I_CALLI		0xff
1134Srgrimes#define	I_RET		0xc3
1144Srgrimes#define	I_IRET		0xcf
1154Srgrimes
1164Srgrimes#define	inst_trap_return(ins)	(((ins)&0xff) == I_IRET)
1174Srgrimes#define	inst_return(ins)	(((ins)&0xff) == I_RET)
1184Srgrimes#define	inst_call(ins)		(((ins)&0xff) == I_CALL || \
1194Srgrimes				 (((ins)&0xff) == I_CALLI && \
1204Srgrimes				  ((ins)&0x3800) == 0x1000))
1214Srgrimes#define inst_load(ins)		0
1224Srgrimes#define inst_store(ins)		0
1234Srgrimes
1244Srgrimes/* access capability and access macros */
1254Srgrimes
1264Srgrimes#define DB_ACCESS_LEVEL		2	/* access any space */
1274Srgrimes#define DB_CHECK_ACCESS(addr,size,task)				\
1284Srgrimes	db_check_access(addr,size,task)
1294Srgrimes#define DB_PHYS_EQ(task1,addr1,task2,addr2)			\
1304Srgrimes	db_phys_eq(task1,addr1,task2,addr2)
1314Srgrimes#define DB_VALID_KERN_ADDR(addr)				\
1324Srgrimes	((addr) >= VM_MIN_KERNEL_ADDRESS && 			\
1334Srgrimes	 (addr) < VM_MAX_KERNEL_ADDRESS)
1344Srgrimes#define DB_VALID_ADDRESS(addr,user)				\
1354Srgrimes	((!(user) && DB_VALID_KERN_ADDR(addr)) ||		\
1364Srgrimes	 ((user) && (addr) < VM_MIN_KERNEL_ADDRESS))
1374Srgrimes
1384Srgrimesboolean_t 	db_check_access(/* vm_offset_t, int, task_t */);
1394Srgrimesboolean_t	db_phys_eq(/* task_t, vm_offset_t, task_t, vm_offset_t */);
1404Srgrimes
1414Srgrimes/* macros for printing OS server dependent task name */
1424Srgrimes
1434Srgrimes#define DB_TASK_NAME(task)	db_task_name(task)
1444Srgrimes#define DB_TASK_NAME_TITLE	"COMMAND                "
1454Srgrimes#define DB_TASK_NAME_LEN	23
1464Srgrimes#define DB_NULL_TASK_NAME	"?                      "
1474Srgrimes
1484Srgrimesvoid		db_task_name(/* task_t */);
1494Srgrimes
1504Srgrimes/* macro for checking if a thread has used floating-point */
1514Srgrimes
1524Srgrimes#define db_thread_fp_used(thread)	((thread)->pcb->ims.ifps != 0)
1534Srgrimes
1544Srgrimes#endif	/* _I386_DB_MACHDEP_H_ */
155