db_machdep.h revision 3722
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 * 263722Sbde * $Id: db_machdep.h,v 1.5 1994/10/02 19:36:30 phk 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 583722Sbde#define PC_REGS(regs) (((regs)->tf_cs & 0xfffc) == 0x08 \ 593722Sbde ? (db_addr_t)(regs)->tf_eip : 0) 604Srgrimes 614Srgrimes#define BKPT_INST 0xcc /* breakpoint instruction */ 624Srgrimes#define BKPT_SIZE (1) /* size of breakpoint inst */ 634Srgrimes#define BKPT_SET(inst) (BKPT_INST) 644Srgrimes 654Srgrimes#define FIXUP_PC_AFTER_BREAK ddb_regs.tf_eip -= 1; 664Srgrimes 672578Sbde#define db_clear_single_step(regs) ((regs)->tf_eflags &= ~PSL_T) 682578Sbde#define db_set_single_step(regs) ((regs)->tf_eflags |= PSL_T) 694Srgrimes 704Srgrimes/* #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_INT3) */ 714Srgrimes/* #define IS_WATCHPOINT_TRAP(type, code) ((type) == T_WATCHPOINT) */ 722578Sbde/* using the FreeBSD values, rather than the Mach ones: */ 734Srgrimes#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT) 744Srgrimes#define IS_WATCHPOINT_TRAP(type, code) ((type) == T_KDBTRAP) 754Srgrimes 764Srgrimes#define I_CALL 0xe8 774Srgrimes#define I_CALLI 0xff 784Srgrimes#define I_RET 0xc3 794Srgrimes#define I_IRET 0xcf 804Srgrimes 814Srgrimes#define inst_trap_return(ins) (((ins)&0xff) == I_IRET) 824Srgrimes#define inst_return(ins) (((ins)&0xff) == I_RET) 834Srgrimes#define inst_call(ins) (((ins)&0xff) == I_CALL || \ 844Srgrimes (((ins)&0xff) == I_CALLI && \ 854Srgrimes ((ins)&0x3800) == 0x1000)) 864Srgrimes#define inst_load(ins) 0 874Srgrimes#define inst_store(ins) 0 884Srgrimes 894Srgrimes/* access capability and access macros */ 904Srgrimes 914Srgrimes#define DB_ACCESS_LEVEL 2 /* access any space */ 924Srgrimes#define DB_CHECK_ACCESS(addr,size,task) \ 934Srgrimes db_check_access(addr,size,task) 944Srgrimes#define DB_PHYS_EQ(task1,addr1,task2,addr2) \ 954Srgrimes db_phys_eq(task1,addr1,task2,addr2) 964Srgrimes#define DB_VALID_KERN_ADDR(addr) \ 974Srgrimes ((addr) >= VM_MIN_KERNEL_ADDRESS && \ 984Srgrimes (addr) < VM_MAX_KERNEL_ADDRESS) 994Srgrimes#define DB_VALID_ADDRESS(addr,user) \ 1004Srgrimes ((!(user) && DB_VALID_KERN_ADDR(addr)) || \ 1014Srgrimes ((user) && (addr) < VM_MIN_KERNEL_ADDRESS)) 1024Srgrimes 1034Srgrimesboolean_t db_check_access(/* vm_offset_t, int, task_t */); 1044Srgrimesboolean_t db_phys_eq(/* task_t, vm_offset_t, task_t, vm_offset_t */); 1054Srgrimes 1064Srgrimes/* macros for printing OS server dependent task name */ 1074Srgrimes 1084Srgrimes#define DB_TASK_NAME(task) db_task_name(task) 1094Srgrimes#define DB_TASK_NAME_TITLE "COMMAND " 1104Srgrimes#define DB_TASK_NAME_LEN 23 1114Srgrimes#define DB_NULL_TASK_NAME "? " 1124Srgrimes 1134Srgrimesvoid db_task_name(/* task_t */); 1144Srgrimes 1154Srgrimes/* macro for checking if a thread has used floating-point */ 1164Srgrimes 1174Srgrimes#define db_thread_fp_used(thread) ((thread)->pcb->ims.ifps != 0) 1184Srgrimes 1194Srgrimes#endif /* _I386_DB_MACHDEP_H_ */ 120