186cb007fSWarner Losh /*- 25b81b6b3SRodney W. Grimes * Mach Operating System 35b81b6b3SRodney W. Grimes * Copyright (c) 1991,1990 Carnegie Mellon University 45b81b6b3SRodney W. Grimes * All Rights Reserved. 55b81b6b3SRodney W. Grimes * 65b81b6b3SRodney W. Grimes * Permission to use, copy, modify and distribute this software and its 75b81b6b3SRodney W. Grimes * documentation is hereby granted, provided that both the copyright 85b81b6b3SRodney W. Grimes * notice and this permission notice appear in all copies of the 95b81b6b3SRodney W. Grimes * software, derivative works or modified versions, and any portions 105b81b6b3SRodney W. Grimes * thereof, and that both notices appear in supporting documentation. 115b81b6b3SRodney W. Grimes * 125b81b6b3SRodney W. Grimes * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 135b81b6b3SRodney W. Grimes * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 145b81b6b3SRodney W. Grimes * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 155b81b6b3SRodney W. Grimes * 165b81b6b3SRodney W. Grimes * Carnegie Mellon requests users of this software to return to 175b81b6b3SRodney W. Grimes * 185b81b6b3SRodney W. Grimes * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 195b81b6b3SRodney W. Grimes * School of Computer Science 205b81b6b3SRodney W. Grimes * Carnegie Mellon University 215b81b6b3SRodney W. Grimes * Pittsburgh PA 15213-3890 225b81b6b3SRodney W. Grimes * 235b81b6b3SRodney W. Grimes * any improvements or extensions that they make and grant Carnegie Mellon 245b81b6b3SRodney W. Grimes * the rights to redistribute these changes. 255b81b6b3SRodney W. Grimes */ 265b81b6b3SRodney W. Grimes 271e1a3d01SBruce Evans #ifndef _MACHINE_DB_MACHDEP_H_ 281e1a3d01SBruce Evans #define _MACHINE_DB_MACHDEP_H_ 295b81b6b3SRodney W. Grimes 30b667af1dSBruce Evans #include <machine/frame.h> 31576642efSMarcel Moolenaar #include <machine/trap.h> 325b81b6b3SRodney W. Grimes 335b81b6b3SRodney W. Grimes typedef vm_offset_t db_addr_t; /* address - unsigned */ 345b81b6b3SRodney W. Grimes typedef int db_expr_t; /* expression - signed */ 355b81b6b3SRodney W. Grimes 36258b53d1SBruce Evans #define PC_REGS() ((db_addr_t)(kdb_frame->tf_eflags & PSL_VM ? \ 37258b53d1SBruce Evans (kdb_frame->tf_eip & 0xffff) + \ 38258b53d1SBruce Evans ((kdb_frame->tf_cs & 0xffff) << 4) : \ 39258b53d1SBruce Evans kdb_frame->tf_eip)) 405b81b6b3SRodney W. Grimes 415b81b6b3SRodney W. Grimes #define BKPT_INST 0xcc /* breakpoint instruction */ 425b81b6b3SRodney W. Grimes #define BKPT_SIZE (1) /* size of breakpoint inst */ 435b81b6b3SRodney W. Grimes #define BKPT_SET(inst) (BKPT_INST) 445b81b6b3SRodney W. Grimes 45def46d58SJulian Elischer #define BKPT_SKIP \ 46def46d58SJulian Elischer do { \ 47def46d58SJulian Elischer kdb_frame->tf_eip += 1; \ 48def46d58SJulian Elischer kdb_thrctx->pcb_eip += 1; \ 49def46d58SJulian Elischer } while(0) 503a0b4f25SDoug Rabson 51def46d58SJulian Elischer #define FIXUP_PC_AFTER_BREAK \ 52def46d58SJulian Elischer do { \ 53def46d58SJulian Elischer kdb_frame->tf_eip -= 1; \ 54def46d58SJulian Elischer kdb_thrctx->pcb_eip -= 1; \ 55def46d58SJulian Elischer } while(0); 565b81b6b3SRodney W. Grimes 5737224cd3SMarcel Moolenaar #define db_clear_single_step kdb_cpu_clear_singlestep 5837224cd3SMarcel Moolenaar #define db_set_single_step kdb_cpu_set_singlestep 595b81b6b3SRodney W. Grimes 601e1a3d01SBruce Evans /* 61bd20334cSBruce Evans * The debug exception type is copied from %dr6 to 'code' and used to 62bd20334cSBruce Evans * disambiguate single step traps. Watchpoints have no special support. 63bd20334cSBruce Evans * Our hardware breakpoints are not well integrated with ddb and are too 64bd20334cSBruce Evans * different from watchpoints. ddb treats them as unknown traps with 65bd20334cSBruce Evans * unknown addresses and doesn't turn them off while it is running. 661e1a3d01SBruce Evans */ 67bd20334cSBruce Evans #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT) 689e2154ffSJohn Baldwin #define IS_SSTEP_TRAP(type, code) \ 699e2154ffSJohn Baldwin ((type) == T_TRCTRAP && (code) & DBREG_DR6_BS) 701e1a3d01SBruce Evans #define IS_WATCHPOINT_TRAP(type, code) 0 715b81b6b3SRodney W. Grimes 725b81b6b3SRodney W. Grimes #define I_CALL 0xe8 735b81b6b3SRodney W. Grimes #define I_CALLI 0xff 745b81b6b3SRodney W. Grimes #define I_RET 0xc3 755b81b6b3SRodney W. Grimes #define I_IRET 0xcf 765b81b6b3SRodney W. Grimes 775b81b6b3SRodney W. Grimes #define inst_trap_return(ins) (((ins)&0xff) == I_IRET) 785b81b6b3SRodney W. Grimes #define inst_return(ins) (((ins)&0xff) == I_RET) 795b81b6b3SRodney W. Grimes #define inst_call(ins) (((ins)&0xff) == I_CALL || \ 805b81b6b3SRodney W. Grimes (((ins)&0xff) == I_CALLI && \ 815b81b6b3SRodney W. Grimes ((ins)&0x3800) == 0x1000)) 825b81b6b3SRodney W. Grimes #define inst_load(ins) 0 835b81b6b3SRodney W. Grimes #define inst_store(ins) 0 845b81b6b3SRodney W. Grimes 85808cf02cSBruce Evans int db_segsize(struct trapframe *tfp); 86808cf02cSBruce Evans 871e1a3d01SBruce Evans #endif /* !_MACHINE_DB_MACHDEP_H_ */ 88