db_machdep.h revision 719
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 *
26719Swollman *	$Id: db_machdep.h,v 1.2 1993/10/16 14:39:10 rgrimes Exp $
274Srgrimes */
284Srgrimes
294Srgrimes#ifndef	_I386_DB_MACHDEP_H_
304Srgrimes#define	_I386_DB_MACHDEP_H_
314Srgrimes
324Srgrimes/*
334Srgrimes * Machine-dependent defines for new kernel debugger.
344Srgrimes */
354Srgrimes
364Srgrimes
374Srgrimes/* #include <mach/i386/vm_types.h> */
384Srgrimes/* #include <mach/i386/vm_param.h> */
394Srgrimes#include <vm/vm_prot.h>
404Srgrimes#include <vm/vm_param.h>
414Srgrimes#include <vm/vm_inherit.h>
424Srgrimes#include <vm/lock.h>
434Srgrimes/* #include <i386/thread.h> */		/* for thread_status */
444Srgrimes#include <machine/frame.h>	/* for struct trapframe */
454Srgrimes/* #include <i386/eflags.h> */
464Srgrimes#include <machine/eflags.h>		/* from Mach... */
474Srgrimes/* #include <i386/trap.h> */
484Srgrimes#include <machine/trap.h>
494Srgrimes
504Srgrimes#define i386_saved_state trapframe
514Srgrimes/* end of mangling */
524Srgrimes
534Srgrimestypedef	vm_offset_t	db_addr_t;	/* address - unsigned */
544Srgrimestypedef	int		db_expr_t;	/* expression - signed */
554Srgrimes
564Srgrimestypedef struct i386_saved_state db_regs_t;
57719Swollmanextern db_regs_t	ddb_regs;	/* register state */
584Srgrimes#define	DDB_REGS	(&ddb_regs)
594Srgrimes
604Srgrimes#define	PC_REGS(regs)	((db_addr_t)(regs)->tf_eip)
614Srgrimes
624Srgrimes#define	BKPT_INST	0xcc		/* breakpoint instruction */
634Srgrimes#define	BKPT_SIZE	(1)		/* size of breakpoint inst */
644Srgrimes#define	BKPT_SET(inst)	(BKPT_INST)
654Srgrimes
664Srgrimes#define	FIXUP_PC_AFTER_BREAK	ddb_regs.tf_eip -= 1;
674Srgrimes
684Srgrimes#define	db_clear_single_step(regs)	((regs)->tf_eflags &= ~EFL_TF)
694Srgrimes#define	db_set_single_step(regs)	((regs)->tf_eflags |=  EFL_TF)
704Srgrimes
714Srgrimes/* #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_INT3) */
724Srgrimes/* #define IS_WATCHPOINT_TRAP(type, code)	((type) == T_WATCHPOINT) */
734Srgrimes/* using the 386bsd values, rather than the Mach ones: */
744Srgrimes#define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BPTFLT)
754Srgrimes#define IS_WATCHPOINT_TRAP(type, code)	((type) == T_KDBTRAP)
764Srgrimes
774Srgrimes#define	I_CALL		0xe8
784Srgrimes#define	I_CALLI		0xff
794Srgrimes#define	I_RET		0xc3
804Srgrimes#define	I_IRET		0xcf
814Srgrimes
824Srgrimes#define	inst_trap_return(ins)	(((ins)&0xff) == I_IRET)
834Srgrimes#define	inst_return(ins)	(((ins)&0xff) == I_RET)
844Srgrimes#define	inst_call(ins)		(((ins)&0xff) == I_CALL || \
854Srgrimes				 (((ins)&0xff) == I_CALLI && \
864Srgrimes				  ((ins)&0x3800) == 0x1000))
874Srgrimes#define inst_load(ins)		0
884Srgrimes#define inst_store(ins)		0
894Srgrimes
904Srgrimes/* access capability and access macros */
914Srgrimes
924Srgrimes#define DB_ACCESS_LEVEL		2	/* access any space */
934Srgrimes#define DB_CHECK_ACCESS(addr,size,task)				\
944Srgrimes	db_check_access(addr,size,task)
954Srgrimes#define DB_PHYS_EQ(task1,addr1,task2,addr2)			\
964Srgrimes	db_phys_eq(task1,addr1,task2,addr2)
974Srgrimes#define DB_VALID_KERN_ADDR(addr)				\
984Srgrimes	((addr) >= VM_MIN_KERNEL_ADDRESS && 			\
994Srgrimes	 (addr) < VM_MAX_KERNEL_ADDRESS)
1004Srgrimes#define DB_VALID_ADDRESS(addr,user)				\
1014Srgrimes	((!(user) && DB_VALID_KERN_ADDR(addr)) ||		\
1024Srgrimes	 ((user) && (addr) < VM_MIN_KERNEL_ADDRESS))
1034Srgrimes
1044Srgrimesboolean_t 	db_check_access(/* vm_offset_t, int, task_t */);
1054Srgrimesboolean_t	db_phys_eq(/* task_t, vm_offset_t, task_t, vm_offset_t */);
1064Srgrimes
1074Srgrimes/* macros for printing OS server dependent task name */
1084Srgrimes
1094Srgrimes#define DB_TASK_NAME(task)	db_task_name(task)
1104Srgrimes#define DB_TASK_NAME_TITLE	"COMMAND                "
1114Srgrimes#define DB_TASK_NAME_LEN	23
1124Srgrimes#define DB_NULL_TASK_NAME	"?                      "
1134Srgrimes
1144Srgrimesvoid		db_task_name(/* task_t */);
1154Srgrimes
1164Srgrimes/* macro for checking if a thread has used floating-point */
1174Srgrimes
1184Srgrimes#define db_thread_fp_used(thread)	((thread)->pcb->ims.ifps != 0)
1194Srgrimes
1204Srgrimes#endif	/* _I386_DB_MACHDEP_H_ */
121