db_machdep.h revision 4
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@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/* 27 * HISTORY 28 * $Log: db_machdep.h,v $ 29 * Revision 2.8 92/02/19 15:07:56 elf 30 * Added db_thread_fp_used. 31 * [92/02/19 rpd] 32 * 33 * Revision 2.7 91/10/09 16:06:28 af 34 * Revision 2.6.3.1 91/10/05 13:10:32 jeffreyh 35 * Added access and task name macros. 36 * [91/08/29 tak] 37 * 38 * Revision 2.6.3.1 91/10/05 13:10:32 jeffreyh 39 * Added access and task name macros. 40 * [91/08/29 tak] 41 * 42 * Revision 2.6 91/05/14 16:05:58 mrt 43 * Correcting copyright 44 * 45 * Revision 2.5 91/02/05 17:11:17 mrt 46 * Changed to new Mach copyright 47 * [91/02/01 17:31:24 mrt] 48 * 49 * Revision 2.4 91/01/08 15:10:16 rpd 50 * Added dummy inst_load/inst_store macros. 51 * [90/12/11 rpd] 52 * 53 * Revision 2.3 90/10/25 14:44:49 rwd 54 * Added watchpoint support. 55 * [90/10/18 rpd] 56 * 57 * Revision 2.2 90/08/27 21:56:15 dbg 58 * Created. 59 * [90/07/25 dbg] 60 * 61 */ 62 63#ifndef _I386_DB_MACHDEP_H_ 64#define _I386_DB_MACHDEP_H_ 65 66/* 67 * Machine-dependent defines for new kernel debugger. 68 */ 69 70 71/* #include <mach/i386/vm_types.h> */ 72/* #include <mach/i386/vm_param.h> */ 73#include <vm/vm_prot.h> 74#include <vm/vm_param.h> 75#include <vm/vm_inherit.h> 76#include <vm/lock.h> 77/* #include <i386/thread.h> */ /* for thread_status */ 78#include <machine/frame.h> /* for struct trapframe */ 79/* #include <i386/eflags.h> */ 80#include <machine/eflags.h> /* from Mach... */ 81/* #include <i386/trap.h> */ 82#include <machine/trap.h> 83 84#define i386_saved_state trapframe 85/* end of mangling */ 86 87typedef vm_offset_t db_addr_t; /* address - unsigned */ 88typedef int db_expr_t; /* expression - signed */ 89 90typedef struct i386_saved_state db_regs_t; 91db_regs_t ddb_regs; /* register state */ 92#define DDB_REGS (&ddb_regs) 93 94#define PC_REGS(regs) ((db_addr_t)(regs)->tf_eip) 95 96#define BKPT_INST 0xcc /* breakpoint instruction */ 97#define BKPT_SIZE (1) /* size of breakpoint inst */ 98#define BKPT_SET(inst) (BKPT_INST) 99 100#define FIXUP_PC_AFTER_BREAK ddb_regs.tf_eip -= 1; 101 102#define db_clear_single_step(regs) ((regs)->tf_eflags &= ~EFL_TF) 103#define db_set_single_step(regs) ((regs)->tf_eflags |= EFL_TF) 104 105/* #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_INT3) */ 106/* #define IS_WATCHPOINT_TRAP(type, code) ((type) == T_WATCHPOINT) */ 107/* using the 386bsd values, rather than the Mach ones: */ 108#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT) 109#define IS_WATCHPOINT_TRAP(type, code) ((type) == T_KDBTRAP) 110 111#define I_CALL 0xe8 112#define I_CALLI 0xff 113#define I_RET 0xc3 114#define I_IRET 0xcf 115 116#define inst_trap_return(ins) (((ins)&0xff) == I_IRET) 117#define inst_return(ins) (((ins)&0xff) == I_RET) 118#define inst_call(ins) (((ins)&0xff) == I_CALL || \ 119 (((ins)&0xff) == I_CALLI && \ 120 ((ins)&0x3800) == 0x1000)) 121#define inst_load(ins) 0 122#define inst_store(ins) 0 123 124/* access capability and access macros */ 125 126#define DB_ACCESS_LEVEL 2 /* access any space */ 127#define DB_CHECK_ACCESS(addr,size,task) \ 128 db_check_access(addr,size,task) 129#define DB_PHYS_EQ(task1,addr1,task2,addr2) \ 130 db_phys_eq(task1,addr1,task2,addr2) 131#define DB_VALID_KERN_ADDR(addr) \ 132 ((addr) >= VM_MIN_KERNEL_ADDRESS && \ 133 (addr) < VM_MAX_KERNEL_ADDRESS) 134#define DB_VALID_ADDRESS(addr,user) \ 135 ((!(user) && DB_VALID_KERN_ADDR(addr)) || \ 136 ((user) && (addr) < VM_MIN_KERNEL_ADDRESS)) 137 138boolean_t db_check_access(/* vm_offset_t, int, task_t */); 139boolean_t db_phys_eq(/* task_t, vm_offset_t, task_t, vm_offset_t */); 140 141/* macros for printing OS server dependent task name */ 142 143#define DB_TASK_NAME(task) db_task_name(task) 144#define DB_TASK_NAME_TITLE "COMMAND " 145#define DB_TASK_NAME_LEN 23 146#define DB_NULL_TASK_NAME "? " 147 148void db_task_name(/* task_t */); 149 150/* macro for checking if a thread has used floating-point */ 151 152#define db_thread_fp_used(thread) ((thread)->pcb->ims.ifps != 0) 153 154#endif /* _I386_DB_MACHDEP_H_ */ 155