Home | History | Annotate | Line # | Download | only in include
db_machdep.h revision 1.2.4.1
      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.1 1993/10/16 02:32:06 mycroft Exp $
     27  */
     28 /*
     29  * HISTORY
     30  * $Log: db_machdep.h,v $
     31  * Revision 1.2.4.1  1993/10/16 02:32:06  mycroft
     32  * VM_MIN_KERNEL_ADDRESS --> VM_MAX_ADDRESS
     33  *
     34  * Revision 1.2  1993/05/22  08:00:12  cgd
     35  * add rcsids to everything and clean up headers
     36  *
     37  * Revision 1.1.1.1  1993/03/21  09:45:47  cgd
     38  * initial import of 386bsd-0.1 sources
     39  *
     40  * Revision 2.8  92/02/19  15:07:56  elf
     41  * 	Added db_thread_fp_used.
     42  * 	[92/02/19            rpd]
     43  *
     44  * Revision 2.7  91/10/09  16:06:28  af
     45  * 	 Revision 2.6.3.1  91/10/05  13:10:32  jeffreyh
     46  * 	 	Added access and task name macros.
     47  * 	 	[91/08/29            tak]
     48  *
     49  * Revision 2.6.3.1  91/10/05  13:10:32  jeffreyh
     50  * 	Added access and task name macros.
     51  * 	[91/08/29            tak]
     52  *
     53  * Revision 2.6  91/05/14  16:05:58  mrt
     54  * 	Correcting copyright
     55  *
     56  * Revision 2.5  91/02/05  17:11:17  mrt
     57  * 	Changed to new Mach copyright
     58  * 	[91/02/01  17:31:24  mrt]
     59  *
     60  * Revision 2.4  91/01/08  15:10:16  rpd
     61  * 	Added dummy inst_load/inst_store macros.
     62  * 	[90/12/11            rpd]
     63  *
     64  * Revision 2.3  90/10/25  14:44:49  rwd
     65  * 	Added watchpoint support.
     66  * 	[90/10/18            rpd]
     67  *
     68  * Revision 2.2  90/08/27  21:56:15  dbg
     69  * 	Created.
     70  * 	[90/07/25            dbg]
     71  *
     72  */
     73 
     74 #ifndef	_I386_DB_MACHDEP_H_
     75 #define	_I386_DB_MACHDEP_H_
     76 
     77 /*
     78  * Machine-dependent defines for new kernel debugger.
     79  */
     80 
     81 
     82 /* #include <mach/i386/vm_types.h> */
     83 /* #include <mach/i386/vm_param.h> */
     84 #include <vm/vm_prot.h>
     85 #include <vm/vm_param.h>
     86 #include <vm/vm_inherit.h>
     87 #include <vm/lock.h>
     88 /* #include <i386/thread.h> */		/* for thread_status */
     89 #include <machine/frame.h>	/* for struct trapframe */
     90 /* #include <i386/eflags.h> */
     91 #include <machine/eflags.h>		/* from Mach... */
     92 /* #include <i386/trap.h> */
     93 #include <machine/trap.h>
     94 
     95 #define i386_saved_state trapframe
     96 /* end of mangling */
     97 
     98 typedef	vm_offset_t	db_addr_t;	/* address - unsigned */
     99 typedef	int		db_expr_t;	/* expression - signed */
    100 
    101 typedef struct i386_saved_state db_regs_t;
    102 db_regs_t	ddb_regs;	/* register state */
    103 #define	DDB_REGS	(&ddb_regs)
    104 
    105 #define	PC_REGS(regs)	((db_addr_t)(regs)->tf_eip)
    106 
    107 #define	BKPT_INST	0xcc		/* breakpoint instruction */
    108 #define	BKPT_SIZE	(1)		/* size of breakpoint inst */
    109 #define	BKPT_SET(inst)	(BKPT_INST)
    110 
    111 #define	FIXUP_PC_AFTER_BREAK	ddb_regs.tf_eip -= 1;
    112 
    113 #define	db_clear_single_step(regs)	((regs)->tf_eflags &= ~EFL_TF)
    114 #define	db_set_single_step(regs)	((regs)->tf_eflags |=  EFL_TF)
    115 
    116 /* #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_INT3) */
    117 /* #define IS_WATCHPOINT_TRAP(type, code)	((type) == T_WATCHPOINT) */
    118 /* using the 386bsd values, rather than the Mach ones: */
    119 #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BPTFLT)
    120 #define IS_WATCHPOINT_TRAP(type, code)	((type) == T_KDBTRAP)
    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