db_machdep.h revision 1.22 1 /* $NetBSD: db_machdep.h,v 1.22 2023/11/21 21:23:56 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1995 Carnegie-Mellon University.
5 * All rights reserved.
6 *
7 * Author: Chris G. Demetriou
8 *
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
14 *
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 *
19 * Carnegie Mellon requests users of this software to return to
20 *
21 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
25 *
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
28 */
29
30 #ifndef _ALPHA_DB_MACHDEP_H_
31 #define _ALPHA_DB_MACHDEP_H_
32
33 /*
34 * Machine-dependent defines for new kernel debugger.
35 */
36
37 #include <sys/param.h>
38 #include <uvm/uvm_extern.h>
39 #include <machine/frame.h>
40
41 typedef vaddr_t db_addr_t; /* address - unsigned */
42 #define DDB_EXPR_FMT "l" /* expression is long */
43 typedef long db_expr_t; /* expression - signed */
44
45 typedef struct trapframe db_regs_t;
46 extern db_regs_t *ddb_regp; /* pointer to current register state */
47 #define DDB_REGS (ddb_regp)
48
49 #define PC_REGS(regs) ((regs)->tf_regs[FRAME_PC])
50
51 #define BKPT_ADDR(addr) (addr) /* breakpoint address */
52 #define BKPT_INST 0x00000080 /* breakpoint instruction */
53 #define BKPT_SIZE (4) /* size of breakpoint inst */
54 #define BKPT_SET(inst, addr) (BKPT_INST)
55
56 #define FIXUP_PC_AFTER_BREAK(regs) \
57 ((regs)->tf_regs[FRAME_PC] -= BKPT_SIZE)
58
59 #define SOFTWARE_SSTEP 1 /* no hardware support */
60 #define IS_BREAKPOINT_TRAP(type, code) ((type) == ALPHA_KENTRY_IF && \
61 (code) == ALPHA_IF_CODE_BPT)
62 #define IS_WATCHPOINT_TRAP(type, code) 0
63
64 /*
65 * Functions needed for software single-stepping.
66 */
67
68 bool db_inst_trap_return(int inst);
69 bool db_inst_return(int inst);
70 bool db_inst_call(int inst);
71 bool db_inst_branch(int inst);
72 bool db_inst_load(int inst);
73 bool db_inst_store(int inst);
74 bool db_inst_unconditional_flow_transfer(int inst);
75 db_addr_t db_branch_taken(int inst, db_addr_t pc, db_regs_t *regs);
76
77 #define inst_trap_return(ins) db_inst_trap_return(ins)
78 #define inst_return(ins) db_inst_return(ins)
79 #define inst_call(ins) db_inst_call(ins)
80 #define inst_branch(ins) db_inst_branch(ins)
81 #define inst_load(ins) db_inst_load(ins)
82 #define inst_store(ins) db_inst_store(ins)
83 #define inst_unconditional_flow_transfer(ins) \
84 db_inst_unconditional_flow_transfer(ins)
85 #define branch_taken(ins, pc, regs) \
86 db_branch_taken((ins), (pc), (regs))
87
88 /* No delay slots on Alpha. */
89 #define next_instr_address(v, b) ((db_addr_t) ((b) ? (v) : ((v) + 4)))
90
91 u_long db_register_value(db_regs_t *, int);
92 int ddb_trap(unsigned long, unsigned long, unsigned long,
93 unsigned long, struct trapframe *);
94
95 int alpha_debug(unsigned long, unsigned long, unsigned long,
96 unsigned long, struct trapframe *);
97
98 struct alpha_bus_space;
99 void alpha_kgdb_init(const char **, struct alpha_bus_space *);
100
101 /*
102 * We define some of our own commands.
103 */
104 #define DB_MACHINE_COMMANDS
105
106 /*
107 * We use Elf64 symbols in DDB.
108 */
109 #define DB_ELF_SYMBOLS
110
111 /*
112 * Stuff for KGDB.
113 */
114 typedef long kgdb_reg_t;
115 #define KGDB_NUMREGS 66 /* from tm-alpha.h, NUM_REGS */
116 #define KGDB_REG_V0 0
117 #define KGDB_REG_T0 1
118 #define KGDB_REG_T1 2
119 #define KGDB_REG_T2 3
120 #define KGDB_REG_T3 4
121 #define KGDB_REG_T4 5
122 #define KGDB_REG_T5 6
123 #define KGDB_REG_T6 7
124 #define KGDB_REG_T7 8
125 #define KGDB_REG_S0 9
126 #define KGDB_REG_S1 10
127 #define KGDB_REG_S2 11
128 #define KGDB_REG_S3 12
129 #define KGDB_REG_S4 13
130 #define KGDB_REG_S5 14
131 #define KGDB_REG_S6 15 /* FP */
132 #define KGDB_REG_A0 16
133 #define KGDB_REG_A1 17
134 #define KGDB_REG_A2 18
135 #define KGDB_REG_A3 19
136 #define KGDB_REG_A4 20
137 #define KGDB_REG_A5 21
138 #define KGDB_REG_T8 22
139 #define KGDB_REG_T9 23
140 #define KGDB_REG_T10 24
141 #define KGDB_REG_T11 25
142 #define KGDB_REG_RA 26
143 #define KGDB_REG_T12 27
144 #define KGDB_REG_AT 28
145 #define KGDB_REG_GP 29
146 #define KGDB_REG_SP 30
147 #define KGDB_REG_ZERO 31
148 #define KGDB_REG_F0 32
149 #define KGDB_REG_F1 33
150 #define KGDB_REG_F2 34
151 #define KGDB_REG_F3 35
152 #define KGDB_REG_F4 36
153 #define KGDB_REG_F5 37
154 #define KGDB_REG_F6 38
155 #define KGDB_REG_F7 39
156 #define KGDB_REG_F8 40
157 #define KGDB_REG_F9 41
158 #define KGDB_REG_F10 42
159 #define KGDB_REG_F11 43
160 #define KGDB_REG_F12 44
161 #define KGDB_REG_F13 45
162 #define KGDB_REG_F14 46
163 #define KGDB_REG_F15 47
164 #define KGDB_REG_F16 48
165 #define KGDB_REG_F17 49
166 #define KGDB_REG_F18 50
167 #define KGDB_REG_F19 51
168 #define KGDB_REG_F20 52
169 #define KGDB_REG_F21 53
170 #define KGDB_REG_F22 54
171 #define KGDB_REG_F23 55
172 #define KGDB_REG_F24 56
173 #define KGDB_REG_F25 57
174 #define KGDB_REG_F26 58
175 #define KGDB_REG_F27 59
176 #define KGDB_REG_F28 60
177 #define KGDB_REG_F29 61
178 #define KGDB_REG_F30 62
179 #define KGDB_REG_F31 63
180 #define KGDB_REG_PC 64
181 #define KGDB_REG_VFP 65
182
183 /* Too much? Must be large enough for register transfer. */
184 #define KGDB_BUFLEN 1024
185
186 /*
187 * Private alpha ddb internals.
188 */
189 #define SYM_XentArith 0
190 #define SYM_XentIF 1
191 #define SYM_XentInt 2
192 #define SYM_XentMM 3
193 #define SYM_XentSys 4
194 #define SYM_XentUna 5
195 #define SYM_XentRestart 6
196 #define SYM_exception_return 7
197 #define SYM_alpha_kthread_backstop 8
198 #define SYM___eol (SYM_alpha_kthread_backstop + 1)
199
200 struct db_alpha_nlist {
201 vaddr_t n_value;
202 };
203
204 typedef struct db_alpha_nlist db_alpha_nlist;
205
206 #define DB_ALPHA_SYM(i, x) [(i)] = { .n_value = (vaddr_t)&(x) }
207 #define DB_ALPHA_SYM_EOL [SYM___eol] = { .n_value = 0 }
208
209 bool db_alpha_sym_is_trap(db_addr_t);
210 bool db_alpha_sym_is_backstop(db_addr_t);
211 bool db_alpha_sym_is_syscall(db_addr_t);
212 const char * db_alpha_trapsym_description(db_addr_t);
213
214 unsigned long db_alpha_read_saved_reg(unsigned long *);
215 unsigned long db_alpha_tf_reg(struct trapframe *, unsigned int);
216
217 /*
218 * Extra ddb options.
219 */
220 #define __HAVE_DB_STACK_TRACE_PRINT_RA
221 void db_stack_trace_print_ra(db_expr_t, bool, db_expr_t, bool,
222 db_expr_t, const char *, void (*)(const char *, ...));
223
224 #endif /* _ALPHA_DB_MACHDEP_H_ */
225