db_machdep.h revision 1.2 1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990 Carnegie Mellon University
4 * All Rights Reserved.
5 *
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.
11 *
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.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 *
26 * $Id: db_machdep.h,v 1.2 1993/05/22 08:00:12 cgd Exp $
27 */
28 /*
29 * HISTORY
30 * $Log: db_machdep.h,v $
31 * Revision 1.2 1993/05/22 08:00:12 cgd
32 * add rcsids to everything and clean up headers
33 *
34 * Revision 1.1.1.1 1993/03/21 09:45:47 cgd
35 * initial import of 386bsd-0.1 sources
36 *
37 * Revision 2.8 92/02/19 15:07:56 elf
38 * Added db_thread_fp_used.
39 * [92/02/19 rpd]
40 *
41 * Revision 2.7 91/10/09 16:06:28 af
42 * Revision 2.6.3.1 91/10/05 13:10:32 jeffreyh
43 * Added access and task name macros.
44 * [91/08/29 tak]
45 *
46 * Revision 2.6.3.1 91/10/05 13:10:32 jeffreyh
47 * Added access and task name macros.
48 * [91/08/29 tak]
49 *
50 * Revision 2.6 91/05/14 16:05:58 mrt
51 * Correcting copyright
52 *
53 * Revision 2.5 91/02/05 17:11:17 mrt
54 * Changed to new Mach copyright
55 * [91/02/01 17:31:24 mrt]
56 *
57 * Revision 2.4 91/01/08 15:10:16 rpd
58 * Added dummy inst_load/inst_store macros.
59 * [90/12/11 rpd]
60 *
61 * Revision 2.3 90/10/25 14:44:49 rwd
62 * Added watchpoint support.
63 * [90/10/18 rpd]
64 *
65 * Revision 2.2 90/08/27 21:56:15 dbg
66 * Created.
67 * [90/07/25 dbg]
68 *
69 */
70
71 #ifndef _I386_DB_MACHDEP_H_
72 #define _I386_DB_MACHDEP_H_
73
74 /*
75 * Machine-dependent defines for new kernel debugger.
76 */
77
78
79 /* #include <mach/i386/vm_types.h> */
80 /* #include <mach/i386/vm_param.h> */
81 #include <vm/vm_prot.h>
82 #include <vm/vm_param.h>
83 #include <vm/vm_inherit.h>
84 #include <vm/lock.h>
85 /* #include <i386/thread.h> */ /* for thread_status */
86 #include <machine/frame.h> /* for struct trapframe */
87 /* #include <i386/eflags.h> */
88 #include <machine/eflags.h> /* from Mach... */
89 /* #include <i386/trap.h> */
90 #include <machine/trap.h>
91
92 #define i386_saved_state trapframe
93 /* end of mangling */
94
95 typedef vm_offset_t db_addr_t; /* address - unsigned */
96 typedef int db_expr_t; /* expression - signed */
97
98 typedef struct i386_saved_state db_regs_t;
99 db_regs_t ddb_regs; /* register state */
100 #define DDB_REGS (&ddb_regs)
101
102 #define PC_REGS(regs) ((db_addr_t)(regs)->tf_eip)
103
104 #define BKPT_INST 0xcc /* breakpoint instruction */
105 #define BKPT_SIZE (1) /* size of breakpoint inst */
106 #define BKPT_SET(inst) (BKPT_INST)
107
108 #define FIXUP_PC_AFTER_BREAK ddb_regs.tf_eip -= 1;
109
110 #define db_clear_single_step(regs) ((regs)->tf_eflags &= ~EFL_TF)
111 #define db_set_single_step(regs) ((regs)->tf_eflags |= EFL_TF)
112
113 /* #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_INT3) */
114 /* #define IS_WATCHPOINT_TRAP(type, code) ((type) == T_WATCHPOINT) */
115 /* using the 386bsd values, rather than the Mach ones: */
116 #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT)
117 #define IS_WATCHPOINT_TRAP(type, code) ((type) == T_KDBTRAP)
118
119 #define I_CALL 0xe8
120 #define I_CALLI 0xff
121 #define I_RET 0xc3
122 #define I_IRET 0xcf
123
124 #define inst_trap_return(ins) (((ins)&0xff) == I_IRET)
125 #define inst_return(ins) (((ins)&0xff) == I_RET)
126 #define inst_call(ins) (((ins)&0xff) == I_CALL || \
127 (((ins)&0xff) == I_CALLI && \
128 ((ins)&0x3800) == 0x1000))
129 #define inst_load(ins) 0
130 #define inst_store(ins) 0
131
132 /* access capability and access macros */
133
134 #define DB_ACCESS_LEVEL 2 /* access any space */
135 #define DB_CHECK_ACCESS(addr,size,task) \
136 db_check_access(addr,size,task)
137 #define DB_PHYS_EQ(task1,addr1,task2,addr2) \
138 db_phys_eq(task1,addr1,task2,addr2)
139 #define DB_VALID_KERN_ADDR(addr) \
140 ((addr) >= VM_MIN_KERNEL_ADDRESS && \
141 (addr) < VM_MAX_KERNEL_ADDRESS)
142 #define DB_VALID_ADDRESS(addr,user) \
143 ((!(user) && DB_VALID_KERN_ADDR(addr)) || \
144 ((user) && (addr) < VM_MIN_KERNEL_ADDRESS))
145
146 boolean_t db_check_access(/* vm_offset_t, int, task_t */);
147 boolean_t db_phys_eq(/* task_t, vm_offset_t, task_t, vm_offset_t */);
148
149 /* macros for printing OS server dependent task name */
150
151 #define DB_TASK_NAME(task) db_task_name(task)
152 #define DB_TASK_NAME_TITLE "COMMAND "
153 #define DB_TASK_NAME_LEN 23
154 #define DB_NULL_TASK_NAME "? "
155
156 void db_task_name(/* task_t */);
157
158 /* macro for checking if a thread has used floating-point */
159
160 #define db_thread_fp_used(thread) ((thread)->pcb->ims.ifps != 0)
161
162 #endif /* _I386_DB_MACHDEP_H_ */
163