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