Home | History | Annotate | Line # | Download | only in include
db_machdep.h revision 1.2.4.2
      1 /*
      2  * Mach Operating System
      3  * Copyright (c) 1991,1990 Carnegie Mellon University
      4  * All Rights Reserved.
      5  *
      6  * Permission to use, copy, modify and distribute this software and its
      7  * documentation is hereby granted, provided that both the copyright
      8  * notice and this permission notice appear in all copies of the
      9  * software, derivative works or modified versions, and any portions
     10  * thereof, and that both notices appear in supporting documentation.
     11  *
     12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
     14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     15  *
     16  * Carnegie Mellon requests users of this software to return to
     17  *
     18  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     19  *  School of Computer Science
     20  *  Carnegie Mellon University
     21  *  Pittsburgh PA 15213-3890
     22  *
     23  * any improvements or extensions that they make and grant Carnegie Mellon
     24  * the rights to redistribute these changes.
     25  *
     26  *	$Id: db_machdep.h,v 1.2.4.2 1993/11/13 06:16:20 mycroft Exp $
     27  */
     28 /*
     29  * HISTORY
     30  * $Log: db_machdep.h,v $
     31  * Revision 1.2.4.2  1993/11/13 06:16:20  mycroft
     32  * Test for watchpoint trap by inspecting the saved image of %dr6.
     33  *
     34  * Revision 1.2.4.1  1993/10/16  02:32:06  mycroft
     35  * VM_MIN_KERNEL_ADDRESS --> VM_MAX_ADDRESS
     36  *
     37  * Revision 1.2  1993/05/22  08:00:12  cgd
     38  * add rcsids to everything and clean up headers
     39  *
     40  * Revision 1.1.1.1  1993/03/21  09:45:47  cgd
     41  * initial import of 386bsd-0.1 sources
     42  *
     43  * Revision 2.8  92/02/19  15:07:56  elf
     44  * 	Added db_thread_fp_used.
     45  * 	[92/02/19            rpd]
     46  *
     47  * Revision 2.7  91/10/09  16:06:28  af
     48  * 	 Revision 2.6.3.1  91/10/05  13:10:32  jeffreyh
     49  * 	 	Added access and task name macros.
     50  * 	 	[91/08/29            tak]
     51  *
     52  * Revision 2.6.3.1  91/10/05  13:10:32  jeffreyh
     53  * 	Added access and task name macros.
     54  * 	[91/08/29            tak]
     55  *
     56  * Revision 2.6  91/05/14  16:05:58  mrt
     57  * 	Correcting copyright
     58  *
     59  * Revision 2.5  91/02/05  17:11:17  mrt
     60  * 	Changed to new Mach copyright
     61  * 	[91/02/01  17:31:24  mrt]
     62  *
     63  * Revision 2.4  91/01/08  15:10:16  rpd
     64  * 	Added dummy inst_load/inst_store macros.
     65  * 	[90/12/11            rpd]
     66  *
     67  * Revision 2.3  90/10/25  14:44:49  rwd
     68  * 	Added watchpoint support.
     69  * 	[90/10/18            rpd]
     70  *
     71  * Revision 2.2  90/08/27  21:56:15  dbg
     72  * 	Created.
     73  * 	[90/07/25            dbg]
     74  *
     75  */
     76 
     77 #ifndef	_I386_DB_MACHDEP_H_
     78 #define	_I386_DB_MACHDEP_H_
     79 
     80 /*
     81  * Machine-dependent defines for new kernel debugger.
     82  */
     83 
     84 
     85 /* #include <mach/i386/vm_types.h> */
     86 /* #include <mach/i386/vm_param.h> */
     87 #include <vm/vm_prot.h>
     88 #include <vm/vm_param.h>
     89 #include <vm/vm_inherit.h>
     90 #include <vm/lock.h>
     91 /* #include <i386/thread.h> */		/* for thread_status */
     92 #include <machine/frame.h>	/* for struct trapframe */
     93 /* #include <i386/eflags.h> */
     94 #include <machine/eflags.h>		/* from Mach... */
     95 /* #include <i386/trap.h> */
     96 #include <machine/trap.h>
     97 
     98 #define i386_saved_state trapframe
     99 /* end of mangling */
    100 
    101 typedef	vm_offset_t	db_addr_t;	/* address - unsigned */
    102 typedef	int		db_expr_t;	/* expression - signed */
    103 
    104 typedef struct i386_saved_state db_regs_t;
    105 db_regs_t	ddb_regs;	/* register state */
    106 #define	DDB_REGS	(&ddb_regs)
    107 
    108 #define	PC_REGS(regs)	((db_addr_t)(regs)->tf_eip)
    109 
    110 #define	BKPT_INST	0xcc		/* breakpoint instruction */
    111 #define	BKPT_SIZE	(1)		/* size of breakpoint inst */
    112 #define	BKPT_SET(inst)	(BKPT_INST)
    113 
    114 #define	FIXUP_PC_AFTER_BREAK	ddb_regs.tf_eip -= 1;
    115 
    116 #define	db_clear_single_step(regs)	((regs)->tf_eflags &= ~EFL_TF)
    117 #define	db_set_single_step(regs)	((regs)->tf_eflags |=  EFL_TF)
    118 
    119 #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BPTFLT)
    120 #define IS_WATCHPOINT_TRAP(type, code)	((code) & 15)	/* image of %dr6 */
    121 
    122 #define	I_CALL		0xe8
    123 #define	I_CALLI		0xff
    124 #define	I_RET		0xc3
    125 #define	I_IRET		0xcf
    126 
    127 #define	inst_trap_return(ins)	(((ins)&0xff) == I_IRET)
    128 #define	inst_return(ins)	(((ins)&0xff) == I_RET)
    129 #define	inst_call(ins)		(((ins)&0xff) == I_CALL || \
    130 				 (((ins)&0xff) == I_CALLI && \
    131 				  ((ins)&0x3800) == 0x1000))
    132 #define inst_load(ins)		0
    133 #define inst_store(ins)		0
    134 
    135 /* access capability and access macros */
    136 
    137 #define DB_ACCESS_LEVEL		2	/* access any space */
    138 #define DB_CHECK_ACCESS(addr,size,task)				\
    139 	db_check_access(addr,size,task)
    140 #define DB_PHYS_EQ(task1,addr1,task2,addr2)			\
    141 	db_phys_eq(task1,addr1,task2,addr2)
    142 #define DB_VALID_KERN_ADDR(addr)				\
    143 	((addr) >= VM_MIN_KERNEL_ADDRESS && 			\
    144 	 (addr) < VM_MAX_KERNEL_ADDRESS)
    145 #define DB_VALID_ADDRESS(addr,user)				\
    146 	((!(user) && DB_VALID_KERN_ADDR(addr)) ||		\
    147 	 ((user) && (addr) < VM_MAX_ADDRESS))
    148 
    149 boolean_t 	db_check_access(/* vm_offset_t, int, task_t */);
    150 boolean_t	db_phys_eq(/* task_t, vm_offset_t, task_t, vm_offset_t */);
    151 
    152 /* macros for printing OS server dependent task name */
    153 
    154 #define DB_TASK_NAME(task)	db_task_name(task)
    155 #define DB_TASK_NAME_TITLE	"COMMAND                "
    156 #define DB_TASK_NAME_LEN	23
    157 #define DB_NULL_TASK_NAME	"?                      "
    158 
    159 void		db_task_name(/* task_t */);
    160 
    161 /* macro for checking if a thread has used floating-point */
    162 
    163 #define db_thread_fp_used(thread)	((thread)->pcb->ims.ifps != 0)
    164 
    165 #endif	/* _I386_DB_MACHDEP_H_ */
    166