/*-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 long db_expr_t; /* expression - signed */3435#define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_rip)3637#define BKPT_INST 0xcc /* breakpoint instruction */38#define BKPT_SIZE (1) /* size of breakpoint inst */39#define BKPT_SET(inst) (BKPT_INST)4041#define BKPT_SKIP \42do { \43kdb_frame->tf_rip += 1; \44kdb_thrctx->pcb_rip += 1; \45} while(0)4647#define FIXUP_PC_AFTER_BREAK \48do { \49kdb_frame->tf_rip -= 1; \50kdb_thrctx->pcb_rip -= 1; \51} while(0);5253#define db_clear_single_step kdb_cpu_clear_singlestep54#define db_set_single_step kdb_cpu_set_singlestep5556/*57* The debug exception type is copied from %dr6 to 'code' and used to58* disambiguate single step traps. Watchpoints have no special support.59* Our hardware breakpoints are not well integrated with ddb and are too60* different from watchpoints. ddb treats them as unknown traps with61* unknown addresses and doesn't turn them off while it is running.62*/63#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT)64#define IS_SSTEP_TRAP(type, code) \65((type) == T_TRCTRAP && (code) & DBREG_DR6_BS)66#define IS_WATCHPOINT_TRAP(type, code) 06768#define I_CALL 0xe869#define I_CALLI 0xff70#define i_calli(ins) (((ins)&0xff) == I_CALLI && ((ins)&0x3800) == 0x1000)71#define I_RET 0xc372#define I_IRET 0xcf73#define i_rex(ins) (((ins) & 0xff) == 0x41 || ((ins) & 0xff) == 0x43)7475#define inst_trap_return(ins) (((ins)&0xff) == I_IRET)76#define inst_return(ins) (((ins)&0xff) == I_RET)77#define inst_call(ins) (((ins)&0xff) == I_CALL || i_calli(ins) || \78(i_calli((ins) >> 8) && i_rex(ins)))79#define inst_load(ins) 080#define inst_store(ins) 08182#endif /* !_MACHINE_DB_MACHDEP_H_ */838485