db_machdep.h revision 2578
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 *
262578Sbde *	$Id: db_machdep.h,v 1.3 1993/11/07 17:42:50 wollman 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/* #include <mach/i386/vm_types.h> */
374Srgrimes/* #include <mach/i386/vm_param.h> */
384Srgrimes#include <vm/vm_prot.h>
394Srgrimes#include <vm/vm_param.h>
404Srgrimes#include <vm/vm_inherit.h>
414Srgrimes#include <vm/lock.h>
424Srgrimes/* #include <i386/thread.h> */		/* for thread_status */
432578Sbde#include <machine/frame.h>		/* for struct trapframe */
444Srgrimes/* #include <i386/eflags.h> */
452578Sbde#include <machine/psl.h>
464Srgrimes/* #include <i386/trap.h> */
474Srgrimes#include <machine/trap.h>
484Srgrimes
494Srgrimes#define i386_saved_state trapframe
504Srgrimes
514Srgrimestypedef	vm_offset_t	db_addr_t;	/* address - unsigned */
524Srgrimestypedef	int		db_expr_t;	/* expression - signed */
534Srgrimes
544Srgrimestypedef struct i386_saved_state db_regs_t;
55719Swollmanextern db_regs_t	ddb_regs;	/* register state */
564Srgrimes#define	DDB_REGS	(&ddb_regs)
574Srgrimes
584Srgrimes#define	PC_REGS(regs)	((db_addr_t)(regs)->tf_eip)
594Srgrimes
604Srgrimes#define	BKPT_INST	0xcc		/* breakpoint instruction */
614Srgrimes#define	BKPT_SIZE	(1)		/* size of breakpoint inst */
624Srgrimes#define	BKPT_SET(inst)	(BKPT_INST)
634Srgrimes
644Srgrimes#define	FIXUP_PC_AFTER_BREAK	ddb_regs.tf_eip -= 1;
654Srgrimes
662578Sbde#define	db_clear_single_step(regs)	((regs)->tf_eflags &= ~PSL_T)
672578Sbde#define	db_set_single_step(regs)	((regs)->tf_eflags |=  PSL_T)
684Srgrimes
694Srgrimes/* #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_INT3) */
704Srgrimes/* #define IS_WATCHPOINT_TRAP(type, code)	((type) == T_WATCHPOINT) */
712578Sbde/* using the FreeBSD values, rather than the Mach ones: */
724Srgrimes#define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BPTFLT)
734Srgrimes#define IS_WATCHPOINT_TRAP(type, code)	((type) == T_KDBTRAP)
744Srgrimes
754Srgrimes#define	I_CALL		0xe8
764Srgrimes#define	I_CALLI		0xff
774Srgrimes#define	I_RET		0xc3
784Srgrimes#define	I_IRET		0xcf
794Srgrimes
804Srgrimes#define	inst_trap_return(ins)	(((ins)&0xff) == I_IRET)
814Srgrimes#define	inst_return(ins)	(((ins)&0xff) == I_RET)
824Srgrimes#define	inst_call(ins)		(((ins)&0xff) == I_CALL || \
834Srgrimes				 (((ins)&0xff) == I_CALLI && \
844Srgrimes				  ((ins)&0x3800) == 0x1000))
854Srgrimes#define inst_load(ins)		0
864Srgrimes#define inst_store(ins)		0
874Srgrimes
884Srgrimes/* access capability and access macros */
894Srgrimes
904Srgrimes#define DB_ACCESS_LEVEL		2	/* access any space */
914Srgrimes#define DB_CHECK_ACCESS(addr,size,task)				\
924Srgrimes	db_check_access(addr,size,task)
934Srgrimes#define DB_PHYS_EQ(task1,addr1,task2,addr2)			\
944Srgrimes	db_phys_eq(task1,addr1,task2,addr2)
954Srgrimes#define DB_VALID_KERN_ADDR(addr)				\
964Srgrimes	((addr) >= VM_MIN_KERNEL_ADDRESS && 			\
974Srgrimes	 (addr) < VM_MAX_KERNEL_ADDRESS)
984Srgrimes#define DB_VALID_ADDRESS(addr,user)				\
994Srgrimes	((!(user) && DB_VALID_KERN_ADDR(addr)) ||		\
1004Srgrimes	 ((user) && (addr) < VM_MIN_KERNEL_ADDRESS))
1014Srgrimes
1024Srgrimesboolean_t 	db_check_access(/* vm_offset_t, int, task_t */);
1034Srgrimesboolean_t	db_phys_eq(/* task_t, vm_offset_t, task_t, vm_offset_t */);
1044Srgrimes
1054Srgrimes/* macros for printing OS server dependent task name */
1064Srgrimes
1074Srgrimes#define DB_TASK_NAME(task)	db_task_name(task)
1084Srgrimes#define DB_TASK_NAME_TITLE	"COMMAND                "
1094Srgrimes#define DB_TASK_NAME_LEN	23
1104Srgrimes#define DB_NULL_TASK_NAME	"?                      "
1114Srgrimes
1124Srgrimesvoid		db_task_name(/* task_t */);
1134Srgrimes
1144Srgrimes/* macro for checking if a thread has used floating-point */
1154Srgrimes
1164Srgrimes#define db_thread_fp_used(thread)	((thread)->pcb->ims.ifps != 0)
1174Srgrimes
1184Srgrimes#endif	/* _I386_DB_MACHDEP_H_ */
119