1 /* $NetBSD: db_machdep.h,v 1.13 2001/11/09 06:52:25 thorpej Exp $ */ 2 3 /* 4 * Mach Operating System 5 * Copyright (c) 1991,1990 Carnegie Mellon University 6 * All Rights Reserved. 7 * 8 * Permission to use, copy, modify and distribute this software and its 9 * documentation is hereby granted, provided that both the copyright 10 * notice and this permission notice appear in all copies of the 11 * software, derivative works or modified versions, and any portions 12 * thereof, and that both notices appear in supporting documentation. 13 * 14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 15 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 16 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 17 * 18 * Carnegie Mellon requests users of this software to return to 19 * 20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 21 * School of Computer Science 22 * Carnegie Mellon University 23 * Pittsburgh PA 15213-3890 24 * 25 * any improvements or extensions that they make and grant Carnegie Mellon 26 * the rights to redistribute these changes. 27 */ 28 29 #ifndef _SPARC_DB_MACHDEP_H_ 30 #define _SPARC_DB_MACHDEP_H_ 31 32 /* 33 * Machine-dependent defines for new kernel debugger. 34 */ 35 36 #include <uvm/uvm_extern.h> 37 38 #include <machine/frame.h> 39 #include <machine/psl.h> 40 #include <machine/trap.h> 41 #include <machine/reg.h> 42 43 /* end of mangling */ 44 45 typedef vaddr_t db_addr_t; /* address - unsigned */ 46 typedef long db_expr_t; /* expression - signed */ 47 48 struct trapstate { 49 int64_t tstate; 50 int64_t tpc; 51 int64_t tnpc; 52 int64_t tt; 53 }; 54 #if 1 55 typedef struct { 56 struct trapframe64 ddb_tf; 57 struct frame64 ddb_fr; 58 struct trapstate ddb_ts[5]; 59 int ddb_tl; 60 struct fpstate64 ddb_fpstate; 61 } db_regs_t; 62 #else 63 typedef struct db_regs { 64 struct trapregs dbr_traps[4]; 65 int dbr_y; 66 char dbr_tl; 67 char dbr_canrestore; 68 char dbr_cansave; 69 char dbr_cleanwin; 70 char dbr_cwp; 71 char dbr_wstate; 72 int64_t dbr_g[8]; 73 int64_t dbr_ag[8]; 74 int64_t dbr_ig[8]; 75 int64_t dbr_mg[8]; 76 int64_t dbr_out[8]; 77 int64_t dbr_local[8]; 78 int64_t dbr_in[8]; 79 } db_regs_t; 80 #endif 81 82 db_regs_t ddb_regs; /* register state */ 83 #define DDB_REGS (&ddb_regs) 84 #define DDB_TF (&ddb_regs.ddb_tf) 85 #define DDB_FR (&ddb_regs.ddb_fr) 86 #define DDB_FP (&ddb_regs.ddb_fpstate) 87 88 #if defined(lint) 89 #define PC_REGS(regs) ((regs)->ddb_tf.tf_pc) 90 #else 91 #define PC_REGS(regs) ((db_addr_t)(regs)->ddb_tf.tf_pc) 92 #endif 93 #define PC_ADVANCE(regs) do { \ 94 vaddr_t n = (regs)->ddb_tf.tf_npc; \ 95 (regs)->ddb_tf.tf_pc = n; \ 96 (regs)->ddb_tf.tf_npc = n + 4; \ 97 } while(0) 98 99 #define BKPT_INST 0x91d02001 /* breakpoint instruction */ 100 #define BKPT_SIZE (4) /* size of breakpoint inst */ 101 #define BKPT_SET(inst) (BKPT_INST) 102 103 #define IS_BREAKPOINT_TRAP(type, code) \ 104 ((type) == T_BREAKPOINT || (type) == T_KGDB_EXEC) 105 #define IS_WATCHPOINT_TRAP(type, code) \ 106 ((type) ==T_PA_WATCHPT || (type) == T_VA_WATCHPT) 107 108 /* 109 * Sparc cpus have no hardware single-step. 110 */ 111 #define SOFTWARE_SSTEP 112 113 boolean_t db_inst_trap_return __P((int inst)); 114 boolean_t db_inst_return __P((int inst)); 115 boolean_t db_inst_call __P((int inst)); 116 boolean_t db_inst_branch __P((int inst)); 117 int db_inst_load __P((int inst)); 118 int db_inst_store __P((int inst)); 119 boolean_t db_inst_unconditional_flow_transfer __P((int inst)); 120 db_addr_t db_branch_taken __P((int inst, db_addr_t pc, db_regs_t *regs)); 121 122 #define inst_trap_return(ins) db_inst_trap_return(ins) 123 #define inst_return(ins) db_inst_return(ins) 124 #define inst_call(ins) db_inst_call(ins) 125 #define inst_branch(ins) db_inst_branch(ins) 126 #define inst_load(ins) db_inst_load(ins) 127 #define inst_store(ins) db_inst_store(ins) 128 #define inst_unconditional_flow_transfer(ins) \ 129 db_inst_unconditional_flow_transfer(ins) 130 #define branch_taken(ins, pc, regs) \ 131 db_branch_taken((ins), (pc), (regs)) 132 133 /* see note in db_interface.c about reversed breakpoint addrs */ 134 #define next_instr_address(pc, bd) \ 135 ((bd) ? (pc) : ddb_regs.ddb_tf.tf_npc) 136 137 #define DB_MACHINE_COMMANDS 138 139 int kdb_trap __P((int, struct trapframe64 *)); 140 141 /* 142 * We will use elf symbols in DDB when they work. 143 */ 144 #if 1 145 #define DB_ELF_SYMBOLS 146 #ifdef __arch64__ 147 #define DB_ELFSIZE 64 148 #else 149 #define DB_ELFSIZE 32 150 #endif 151 #else 152 #define DB_AOUT_SYMBOLS 153 #endif 154 /* 155 * KGDB definitions 156 */ 157 typedef u_long kgdb_reg_t; 158 #define KGDB_NUMREGS 72 159 #define KGDB_BUFLEN 1024 160 161 #endif /* _SPARC_DB_MACHDEP_H_ */ 162