db_machdep.h revision 1.13 1 1.13 thorpej /* $NetBSD: db_machdep.h,v 1.13 1998/08/13 21:36:05 thorpej Exp $ */
2 1.8 cgd
3 1.1 cgd /*
4 1.1 cgd * Mach Operating System
5 1.1 cgd * Copyright (c) 1991,1990 Carnegie Mellon University
6 1.1 cgd * All Rights Reserved.
7 1.1 cgd *
8 1.1 cgd * Permission to use, copy, modify and distribute this software and its
9 1.1 cgd * documentation is hereby granted, provided that both the copyright
10 1.1 cgd * notice and this permission notice appear in all copies of the
11 1.1 cgd * software, derivative works or modified versions, and any portions
12 1.1 cgd * thereof, and that both notices appear in supporting documentation.
13 1.1 cgd *
14 1.1 cgd * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 1.1 cgd * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
16 1.1 cgd * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 1.1 cgd *
18 1.1 cgd * Carnegie Mellon requests users of this software to return to
19 1.1 cgd *
20 1.1 cgd * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
21 1.1 cgd * School of Computer Science
22 1.1 cgd * Carnegie Mellon University
23 1.1 cgd * Pittsburgh PA 15213-3890
24 1.1 cgd *
25 1.1 cgd * any improvements or extensions that they make and grant Carnegie Mellon
26 1.1 cgd * the rights to redistribute these changes.
27 1.1 cgd */
28 1.1 cgd
29 1.1 cgd #ifndef _I386_DB_MACHDEP_H_
30 1.1 cgd #define _I386_DB_MACHDEP_H_
31 1.1 cgd
32 1.1 cgd /*
33 1.1 cgd * Machine-dependent defines for new kernel debugger.
34 1.1 cgd */
35 1.1 cgd
36 1.5 mycroft #include <sys/param.h>
37 1.5 mycroft #include <vm/vm.h>
38 1.1 cgd #include <machine/trap.h>
39 1.1 cgd
40 1.13 thorpej typedef vaddr_t db_addr_t; /* address - unsigned */
41 1.10 mycroft typedef long db_expr_t; /* expression - signed */
42 1.1 cgd
43 1.6 mycroft typedef struct trapframe db_regs_t;
44 1.1 cgd db_regs_t ddb_regs; /* register state */
45 1.1 cgd #define DDB_REGS (&ddb_regs)
46 1.1 cgd
47 1.1 cgd #define PC_REGS(regs) ((db_addr_t)(regs)->tf_eip)
48 1.1 cgd
49 1.1 cgd #define BKPT_INST 0xcc /* breakpoint instruction */
50 1.1 cgd #define BKPT_SIZE (1) /* size of breakpoint inst */
51 1.1 cgd #define BKPT_SET(inst) (BKPT_INST)
52 1.1 cgd
53 1.11 gwr #define FIXUP_PC_AFTER_BREAK(regs) ((regs)->tf_eip -= BKPT_SIZE)
54 1.1 cgd
55 1.3 mycroft #define db_clear_single_step(regs) ((regs)->tf_eflags &= ~PSL_T)
56 1.3 mycroft #define db_set_single_step(regs) ((regs)->tf_eflags |= PSL_T)
57 1.1 cgd
58 1.1 cgd #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT)
59 1.3 mycroft #define IS_WATCHPOINT_TRAP(type, code) ((type) == T_TRCTRAP && (code) & 15)
60 1.1 cgd
61 1.1 cgd #define I_CALL 0xe8
62 1.1 cgd #define I_CALLI 0xff
63 1.1 cgd #define I_RET 0xc3
64 1.1 cgd #define I_IRET 0xcf
65 1.1 cgd
66 1.1 cgd #define inst_trap_return(ins) (((ins)&0xff) == I_IRET)
67 1.1 cgd #define inst_return(ins) (((ins)&0xff) == I_RET)
68 1.1 cgd #define inst_call(ins) (((ins)&0xff) == I_CALL || \
69 1.1 cgd (((ins)&0xff) == I_CALLI && \
70 1.1 cgd ((ins)&0x3800) == 0x1000))
71 1.1 cgd #define inst_load(ins) 0
72 1.1 cgd #define inst_store(ins) 0
73 1.1 cgd
74 1.1 cgd /* access capability and access macros */
75 1.1 cgd
76 1.1 cgd #define DB_ACCESS_LEVEL 2 /* access any space */
77 1.1 cgd #define DB_CHECK_ACCESS(addr,size,task) \
78 1.1 cgd db_check_access(addr,size,task)
79 1.1 cgd #define DB_PHYS_EQ(task1,addr1,task2,addr2) \
80 1.1 cgd db_phys_eq(task1,addr1,task2,addr2)
81 1.1 cgd #define DB_VALID_KERN_ADDR(addr) \
82 1.1 cgd ((addr) >= VM_MIN_KERNEL_ADDRESS && \
83 1.1 cgd (addr) < VM_MAX_KERNEL_ADDRESS)
84 1.1 cgd #define DB_VALID_ADDRESS(addr,user) \
85 1.1 cgd ((!(user) && DB_VALID_KERN_ADDR(addr)) || \
86 1.3 mycroft ((user) && (addr) < VM_MAX_ADDRESS))
87 1.1 cgd
88 1.9 christos #if 0
89 1.13 thorpej boolean_t db_check_access __P((vaddr_t, int, task_t));
90 1.13 thorpej boolean_t db_phys_eq __P((task_t, vaddr_t, task_t, vaddr_t));
91 1.9 christos #endif
92 1.1 cgd
93 1.1 cgd /* macros for printing OS server dependent task name */
94 1.1 cgd
95 1.1 cgd #define DB_TASK_NAME(task) db_task_name(task)
96 1.1 cgd #define DB_TASK_NAME_TITLE "COMMAND "
97 1.1 cgd #define DB_TASK_NAME_LEN 23
98 1.1 cgd #define DB_NULL_TASK_NAME "? "
99 1.1 cgd
100 1.12 thorpej /*
101 1.12 thorpej * Constants for KGDB.
102 1.12 thorpej */
103 1.12 thorpej typedef long kgdb_reg_t;
104 1.12 thorpej #define KGDB_NUMREGS 14
105 1.12 thorpej #define KGDB_BUFLEN 512
106 1.12 thorpej
107 1.9 christos #if 0
108 1.1 cgd void db_task_name(/* task_t */);
109 1.9 christos #endif
110 1.1 cgd
111 1.1 cgd /* macro for checking if a thread has used floating-point */
112 1.1 cgd
113 1.1 cgd #define db_thread_fp_used(thread) ((thread)->pcb->ims.ifps != 0)
114 1.9 christos
115 1.9 christos int kdb_trap __P((int, int, db_regs_t *));
116 1.12 thorpej
117 1.12 thorpej /*
118 1.12 thorpej * We use a.out symbols in DDB.
119 1.12 thorpej */
120 1.12 thorpej #define DB_AOUT_SYMBOLS
121 1.1 cgd
122 1.1 cgd #endif /* _I386_DB_MACHDEP_H_ */
123