/*-1* Mach Operating System2* Copyright (c) 1991,1990 Carnegie Mellon University3* All Rights Reserved.4*5* Permission to use, copy, modify and distribute this software and its6* documentation is hereby granted, provided that both the copyright7* notice and this permission notice appear in all copies of the8* software, derivative works or modified versions, and any portions9* thereof, and that both notices appear in supporting documentation.10*11* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"12* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR13* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.14*15* Carnegie Mellon requests users of this software to return to16*17* Software Distribution Coordinator or [email protected]18* School of Computer Science19* Carnegie Mellon University20* Pittsburgh PA 15213-389021*22* any improvements or extensions that they make and grant Carnegie Mellon23* the rights to redistribute these changes.24*/2526#ifndef _MACHINE_DB_MACHDEP_H_27#define _MACHINE_DB_MACHDEP_H_2829#include <machine/frame.h>30#include <machine/trap.h>3132typedef vm_offset_t db_addr_t; /* address - unsigned */33typedef int db_expr_t; /* expression - signed */3435#define PC_REGS() ((db_addr_t)(kdb_frame->tf_eflags & PSL_VM ? \36(kdb_frame->tf_eip & 0xffff) + \37((kdb_frame->tf_cs & 0xffff) << 4) : \38kdb_frame->tf_eip))3940#define BKPT_INST 0xcc /* breakpoint instruction */41#define BKPT_SIZE (1) /* size of breakpoint inst */42#define BKPT_SET(inst) (BKPT_INST)4344#define BKPT_SKIP \45do { \46kdb_frame->tf_eip += 1; \47kdb_thrctx->pcb_eip += 1; \48} while(0)4950#define FIXUP_PC_AFTER_BREAK \51do { \52kdb_frame->tf_eip -= 1; \53kdb_thrctx->pcb_eip -= 1; \54} while(0);5556#define db_clear_single_step kdb_cpu_clear_singlestep57#define db_set_single_step kdb_cpu_set_singlestep5859/*60* The debug exception type is copied from %dr6 to 'code' and used to61* disambiguate single step traps. Watchpoints have no special support.62* Our hardware breakpoints are not well integrated with ddb and are too63* different from watchpoints. ddb treats them as unknown traps with64* unknown addresses and doesn't turn them off while it is running.65*/66#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT)67#define IS_SSTEP_TRAP(type, code) \68((type) == T_TRCTRAP && (code) & DBREG_DR6_BS)69#define IS_WATCHPOINT_TRAP(type, code) 07071#define I_CALL 0xe872#define I_CALLI 0xff73#define I_RET 0xc374#define I_IRET 0xcf7576#define inst_trap_return(ins) (((ins)&0xff) == I_IRET)77#define inst_return(ins) (((ins)&0xff) == I_RET)78#define inst_call(ins) (((ins)&0xff) == I_CALL || \79(((ins)&0xff) == I_CALLI && \80((ins)&0x3800) == 0x1000))81#define inst_load(ins) 082#define inst_store(ins) 08384int db_segsize(struct trapframe *tfp);8586#endif /* !_MACHINE_DB_MACHDEP_H_ */878889