db_machdep.h revision 5592
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 * 265592Sbde * $Id: db_machdep.h,v 1.6 1994/10/19 21:13:51 bde Exp $ 274Srgrimes */ 284Srgrimes 295592Sbde#ifndef _MACHINE_DB_MACHDEP_H_ 305592Sbde#define _MACHINE_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_BPTFLT) 715592Sbde/* 725592Sbde * Watchpoints are not supported. The debug exception type is in %dr6 735592Sbde * and not yet in the args to this macro. 745592Sbde */ 755592Sbde#define IS_WATCHPOINT_TRAP(type, code) 0 764Srgrimes 774Srgrimes#define I_CALL 0xe8 784Srgrimes#define I_CALLI 0xff 794Srgrimes#define I_RET 0xc3 804Srgrimes#define I_IRET 0xcf 814Srgrimes 824Srgrimes#define inst_trap_return(ins) (((ins)&0xff) == I_IRET) 834Srgrimes#define inst_return(ins) (((ins)&0xff) == I_RET) 844Srgrimes#define inst_call(ins) (((ins)&0xff) == I_CALL || \ 854Srgrimes (((ins)&0xff) == I_CALLI && \ 864Srgrimes ((ins)&0x3800) == 0x1000)) 874Srgrimes#define inst_load(ins) 0 884Srgrimes#define inst_store(ins) 0 894Srgrimes 904Srgrimes/* access capability and access macros */ 914Srgrimes 924Srgrimes#define DB_ACCESS_LEVEL 2 /* access any space */ 934Srgrimes#define DB_CHECK_ACCESS(addr,size,task) \ 944Srgrimes db_check_access(addr,size,task) 954Srgrimes#define DB_PHYS_EQ(task1,addr1,task2,addr2) \ 964Srgrimes db_phys_eq(task1,addr1,task2,addr2) 974Srgrimes#define DB_VALID_KERN_ADDR(addr) \ 984Srgrimes ((addr) >= VM_MIN_KERNEL_ADDRESS && \ 994Srgrimes (addr) < VM_MAX_KERNEL_ADDRESS) 1004Srgrimes#define DB_VALID_ADDRESS(addr,user) \ 1014Srgrimes ((!(user) && DB_VALID_KERN_ADDR(addr)) || \ 1024Srgrimes ((user) && (addr) < VM_MIN_KERNEL_ADDRESS)) 1034Srgrimes 1044Srgrimesboolean_t db_check_access(/* vm_offset_t, int, task_t */); 1054Srgrimesboolean_t db_phys_eq(/* task_t, vm_offset_t, task_t, vm_offset_t */); 1064Srgrimes 1074Srgrimes/* macros for printing OS server dependent task name */ 1084Srgrimes 1094Srgrimes#define DB_TASK_NAME(task) db_task_name(task) 1104Srgrimes#define DB_TASK_NAME_TITLE "COMMAND " 1114Srgrimes#define DB_TASK_NAME_LEN 23 1124Srgrimes#define DB_NULL_TASK_NAME "? " 1134Srgrimes 1144Srgrimesvoid db_task_name(/* task_t */); 1154Srgrimes 1164Srgrimes/* macro for checking if a thread has used floating-point */ 1174Srgrimes 1184Srgrimes#define db_thread_fp_used(thread) ((thread)->pcb->ims.ifps != 0) 1194Srgrimes 1205592Sbde#endif /* !_MACHINE_DB_MACHDEP_H_ */ 121