2 * Mach Operating System
3 * Copyright (c) 1991,1990 Carnegie Mellon University
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16 * Carnegie Mellon requests users of this software to return to
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
29 #ifndef _MACHINE_DB_MACHDEP_H_
30 #define _MACHINE_DB_MACHDEP_H_
32 #include <machine/frame.h>
33 #include <machine/reg.h>
34 #include <machine/trap.h>
36 typedef vm_offset_t db_addr_t; /* address - unsigned */
37 typedef int db_expr_t; /* expression - signed */
39 #define PC_REGS() ((db_addr_t)(kdb_frame->tf_eflags & PSL_VM ? \
40 (kdb_frame->tf_eip & 0xffff) + \
41 ((kdb_frame->tf_cs & 0xffff) << 4) : \
44 #define BKPT_INST 0xcc /* breakpoint instruction */
45 #define BKPT_SIZE (1) /* size of breakpoint inst */
46 #define BKPT_SET(inst) (BKPT_INST)
50 kdb_frame->tf_eip += 1; \
51 kdb_thrctx->pcb_eip += 1; \
54 #define FIXUP_PC_AFTER_BREAK \
56 kdb_frame->tf_eip -= 1; \
57 kdb_thrctx->pcb_eip -= 1; \
60 #define db_clear_single_step kdb_cpu_clear_singlestep
61 #define db_set_single_step kdb_cpu_set_singlestep
64 * The debug exception type is copied from %dr6 to 'code' and used to
65 * disambiguate single step traps. Watchpoints have no special support.
66 * Our hardware breakpoints are not well integrated with ddb and are too
67 * different from watchpoints. ddb treats them as unknown traps with
68 * unknown addresses and doesn't turn them off while it is running.
70 #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT)
71 #define IS_SSTEP_TRAP(type, code) \
72 ((type) == T_TRCTRAP && (code) & DBREG_DR6_BS)
73 #define IS_WATCHPOINT_TRAP(type, code) 0
80 #define inst_trap_return(ins) (((ins)&0xff) == I_IRET)
81 #define inst_return(ins) (((ins)&0xff) == I_RET)
82 #define inst_call(ins) (((ins)&0xff) == I_CALL || \
83 (((ins)&0xff) == I_CALLI && \
84 ((ins)&0x3800) == 0x1000))
85 #define inst_load(ins) 0
86 #define inst_store(ins) 0
88 int db_segsize(struct trapframe *tfp);
90 #endif /* !_MACHINE_DB_MACHDEP_H_ */