]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 A |
6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
7 | * | |
8 | * This file contains Original Code and/or Modifications of Original Code | |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * @OSF_COPYRIGHT@ | |
27 | */ | |
28 | /* | |
29 | * Mach Operating System | |
30 | * Copyright (c) 1991,1990 Carnegie Mellon University | |
31 | * All Rights Reserved. | |
32 | * | |
33 | * Permission to use, copy, modify and distribute this software and its | |
34 | * documentation is hereby granted, provided that both the copyright | |
35 | * notice and this permission notice appear in all copies of the | |
36 | * software, derivative works or modified versions, and any portions | |
37 | * thereof, and that both notices appear in supporting documentation. | |
38 | * | |
39 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
40 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
41 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
42 | * | |
43 | * Carnegie Mellon requests users of this software to return to | |
44 | * | |
45 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
46 | * School of Computer Science | |
47 | * Carnegie Mellon University | |
48 | * Pittsburgh PA 15213-3890 | |
49 | * | |
50 | * any improvements or extensions that they make and grant Carnegie Mellon | |
51 | * the rights to redistribute these changes. | |
52 | */ | |
53 | /* | |
54 | */ | |
55 | ||
56 | #ifndef _I386_DB_MACHDEP_H_ | |
57 | #define _I386_DB_MACHDEP_H_ | |
58 | ||
59 | /* | |
60 | * Machine-dependent defines for new kernel debugger. | |
61 | */ | |
62 | ||
63 | #include <kern/kern_types.h> | |
64 | #include <mach/i386/vm_types.h> | |
65 | #include <mach/i386/vm_param.h> | |
66 | #include <i386/thread.h> /* for thread_status */ | |
67 | #include <i386/eflags.h> | |
68 | #include <i386/trap.h> | |
69 | ||
70 | typedef vm_offset_t db_addr_t; /* address - unsigned */ | |
71 | typedef int db_expr_t; /* expression - signed */ | |
72 | ||
73 | typedef struct i386_saved_state db_regs_t; | |
74 | db_regs_t ddb_regs; /* register state */ | |
75 | #define DDB_REGS (&ddb_regs) | |
76 | extern int db_active; /* ddb is active */ | |
77 | ||
78 | #define PC_REGS(regs) ((db_addr_t)(regs)->eip) | |
79 | ||
80 | #define BKPT_INST 0xcc /* breakpoint instruction */ | |
81 | #define BKPT_SIZE (1) /* size of breakpoint inst */ | |
82 | #define BKPT_SET(inst) (BKPT_INST) | |
83 | ||
84 | #define FIXUP_PC_AFTER_BREAK ddb_regs.eip -= 1; | |
85 | ||
86 | #define db_clear_single_step(regs) ((regs)->efl &= ~EFL_TF) | |
87 | #define db_set_single_step(regs) ((regs)->efl |= EFL_TF) | |
88 | ||
89 | #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_INT3) | |
90 | #define IS_WATCHPOINT_TRAP(type, code) ((type) == T_WATCHPOINT) | |
91 | ||
92 | #define I_CALL 0xe8 | |
93 | #define I_CALLI 0xff | |
94 | #define I_RET 0xc3 | |
95 | #define I_IRET 0xcf | |
96 | ||
97 | #define inst_trap_return(ins) (((ins)&0xff) == I_IRET) | |
98 | #define inst_return(ins) (((ins)&0xff) == I_RET) | |
99 | #define inst_call(ins) (((ins)&0xff) == I_CALL || \ | |
100 | (((ins)&0xff) == I_CALLI && \ | |
101 | ((ins)&0x3800) == 0x1000)) | |
102 | ||
103 | int db_inst_load(unsigned long); | |
104 | int db_inst_store(unsigned long); | |
105 | ||
106 | /* access capability and access macros */ | |
107 | ||
108 | #define DB_ACCESS_LEVEL 2 /* access any space */ | |
109 | #define DB_CHECK_ACCESS(addr,size,task) \ | |
110 | db_check_access(addr,size,task) | |
111 | #define DB_PHYS_EQ(task1,addr1,task2,addr2) \ | |
112 | db_phys_eq(task1,addr1,task2,addr2) | |
113 | #define DB_VALID_KERN_ADDR(addr) \ | |
114 | ((addr) >= VM_MIN_KERNEL_ADDRESS && \ | |
115 | (addr) < VM_MAX_KERNEL_ADDRESS) | |
116 | #define DB_VALID_ADDRESS(addr,user) \ | |
117 | ((!(user) && DB_VALID_KERN_ADDR(addr)) || \ | |
118 | ((user) && (addr) < VM_MAX_ADDRESS)) | |
119 | ||
120 | /* | |
121 | * Given pointer to i386_saved_state, determine if it represents | |
55e303ae | 122 | * a thread executing in user space. |
1c79356b | 123 | */ |
55e303ae | 124 | #define IS_USER_TRAP(regs, etext) (((regs)->cs & 3) != 0) |
1c79356b A |
125 | |
126 | extern boolean_t db_check_access( | |
127 | vm_offset_t addr, | |
128 | int size, | |
129 | task_t task); | |
130 | extern boolean_t db_phys_eq( | |
131 | task_t task1, | |
132 | vm_offset_t addr1, | |
133 | task_t task2, | |
134 | vm_offset_t addr2); | |
135 | extern db_addr_t db_disasm( | |
136 | db_addr_t loc, | |
137 | boolean_t altfmt, | |
138 | task_t task); | |
139 | extern void db_read_bytes( | |
140 | vm_offset_t addr, | |
141 | int size, | |
142 | char *data, | |
143 | task_t task); | |
144 | extern void db_write_bytes( | |
145 | vm_offset_t addr, | |
146 | int size, | |
147 | char *data, | |
148 | task_t task); | |
149 | extern void db_stack_trace_cmd( | |
150 | db_expr_t addr, | |
151 | boolean_t have_addr, | |
152 | db_expr_t count, | |
153 | char *modif); | |
154 | extern void db_reboot( | |
155 | db_expr_t addr, | |
156 | boolean_t have_addr, | |
157 | db_expr_t count, | |
158 | char *modif); | |
159 | ||
160 | /* macros for printing OS server dependent task name */ | |
161 | ||
162 | #define DB_TASK_NAME(task) db_task_name(task) | |
163 | #define DB_TASK_NAME_TITLE "COMMAND " | |
164 | #define DB_TASK_NAME_LEN 23 | |
165 | #define DB_NULL_TASK_NAME "? " | |
166 | ||
167 | extern void db_task_name( | |
168 | task_t task); | |
169 | ||
170 | /* macro for checking if a thread has used floating-point */ | |
171 | ||
172 | #define db_act_fp_used(act) (act && act->mact.pcb->ims.ifps) | |
173 | ||
174 | extern void db_tss_to_frame( | |
175 | int tss_sel, | |
176 | struct i386_saved_state *regs); | |
177 | extern int kdb_trap( | |
178 | int type, | |
179 | int code, | |
180 | struct i386_saved_state *regs); | |
181 | extern boolean_t db_trap_from_asm( | |
182 | struct i386_saved_state *regs); | |
183 | extern int dr6(void); | |
184 | extern void kdb_on( | |
185 | int cpu); | |
186 | extern void cnpollc( | |
187 | boolean_t on); | |
188 | ||
189 | #endif /* _I386_DB_MACHDEP_H_ */ |