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