| 9120e874 Andy McCall |
1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#ifndef _DEBUG_CORE_H_ |
| 16 |
#define _DEBUG_CORE_H_ |
| 17 |
|
| 18 |
#include <stdint.h> |
| 19 |
#include <stdbool.h> |
| 20 |
|
| 21 |
#ifdef __cplusplus |
| 22 |
extern "C" { |
| 23 |
#endif |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
#define DEBUG_BANK_ANY (-1) |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
typedef enum { |
| 51 |
DEBUG_OWNER_CLI = 0, |
| 52 |
DEBUG_OWNER_UI, |
| 53 |
DEBUG_OWNER_DAP_SOURCE, |
| 54 |
DEBUG_OWNER_DAP_FUNCTION, |
| 55 |
DEBUG_OWNER_DAP_INSTRUCTION, |
| 56 |
DEBUG_OWNER_DAP_CONSOLE, |
| 57 |
DEBUG_OWNER_STEP, |
| 58 |
DEBUG_OWNER_COUNT |
| 59 |
} debug_owner_t; |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
struct breakpoint { |
| 68 |
int pc; |
| 69 |
uint8_t bank; |
| 70 |
int x16Bank; |
| 71 |
uint16_t owners; |
| 72 |
bool enabled; |
| 73 |
}; |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
extern struct breakpoint *breakPoints; |
| 79 |
extern int numBreakpoints; |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
enum { |
| 84 |
BPOPERAND_A = 0, |
| 85 |
BPOPERAND_X, |
| 86 |
BPOPERAND_Y, |
| 87 |
BPOPERAND_SP, |
| 88 |
BPOPERAND_P, |
| 89 |
BPOPERAND_BYTE, |
| 90 |
BPOPERAND_WORD, |
| 91 |
}; |
| 92 |
|
| 93 |
|
| 94 |
enum { |
| 95 |
BPCMP_EQ = 0, |
| 96 |
BPCMP_NE, |
| 97 |
BPCMP_LT, |
| 98 |
BPCMP_LE, |
| 99 |
BPCMP_GT, |
| 100 |
BPCMP_GE, |
| 101 |
}; |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
bool debug_bank_selector_matches(int selector, int addr, uint8_t pbank); |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
int debug_normalise_bank(int selector, int addr, uint8_t pbank); |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
int debug_current_x16_bank(int pc, uint8_t pbank); |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
bool debug_bp_from_ref(long ref, int explicit_bank, long offset, struct breakpoint *out); |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
typedef enum { |
| 152 |
DEBUG_ADD_CREATED = 0, |
| 153 |
DEBUG_ADD_EXISTED, |
| 154 |
DEBUG_ADD_FULL |
| 155 |
} debug_add_result_t; |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
debug_add_result_t debug_bp_add_for(struct breakpoint bp, debug_owner_t owner); |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
bool debug_bp_remove_for(int pc, uint8_t bank, int x16Bank, debug_owner_t owner); |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
int debug_bp_clear_owner(debug_owner_t owner); |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
bool debug_bp_delete(int pc, uint8_t bank, int x16Bank); |
| 184 |
|
| 185 |
|
| 186 |
bool debug_bp_has_owner(int pc, uint8_t bank, int x16Bank, debug_owner_t owner); |
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
void debug_bp_toggle_for(int pc, uint8_t bank, int x16Bank, debug_owner_t owner); |
| 191 |
|
| 192 |
int debug_bp_find(int pc, uint8_t bank, int x16Bank); |
| 193 |
void debug_bp_clear_all(void); |
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
bool debug_bp_set_enabled(int pc, uint8_t bank, int x16Bank, bool enabled); |
| 204 |
bool debug_bp_is_enabled(int pc, uint8_t bank, int x16Bank); |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
int debug_bp_count(void); |
| 211 |
const struct breakpoint *debug_bp_at(int index); |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
bool debug_bp_on_arrival(int pc, uint8_t bank); |
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
bool debug_bp_is_set(int pc, uint8_t bank); |
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
void debug_bp_set_condition(int pc, uint8_t bank, int x16Bank, int operand, |
| 253 |
uint16_t operand_addr, int op, uint32_t value); |
| 254 |
void debug_bp_clear_condition(int pc, uint8_t bank, int x16Bank); |
| 255 |
void debug_bp_forget(int pc, uint8_t bank, int x16Bank); |
| 256 |
void debug_bp_set_ignore(int pc, uint8_t bank, int x16Bank, uint32_t ignore); |
| 257 |
uint32_t debug_bp_get_hits(int pc, uint8_t bank, int x16Bank); |
| 258 |
void debug_bp_reset_hits(int pc, uint8_t bank, int x16Bank); |
| 259 |
bool debug_bp_get_condition(int pc, uint8_t bank, int x16Bank, int *has_cond, int *operand, |
| 260 |
uint16_t *operand_addr, int *op, uint32_t *value, |
| 261 |
uint32_t *ignore); |
| 262 |
|
| 263 |
|
| 264 |
void debug_core_free(void); |
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
#define MAX_WATCHPOINTS 64 |
| 276 |
|
| 277 |
struct watchpoint { |
| 278 |
uint16_t addr; |
| 279 |
uint16_t len; |
| 280 |
int x16Bank; |
| 281 |
bool active; |
| 282 |
bool has_value; |
| 283 |
uint8_t value; |
| 284 |
int op; |
| 285 |
uint16_t owners; |
| 286 |
}; |
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
debug_add_result_t debug_wp_add_for(uint16_t addr, uint16_t len, int x16Bank, debug_owner_t owner); |
| 298 |
bool debug_wp_remove_for(uint16_t addr, int x16Bank, debug_owner_t owner); |
| 299 |
int debug_wp_clear_owner(debug_owner_t owner); |
| 300 |
bool debug_wp_delete(uint16_t addr, int x16Bank); |
| 301 |
bool debug_wp_has_owner(uint16_t addr, int x16Bank, debug_owner_t owner); |
| 302 |
void debug_wp_clear_all(void); |
| 303 |
int debug_wp_count(void); |
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
const struct watchpoint *debug_wp_at(int index); |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
bool debug_wp_exists(uint16_t addr, int x16Bank); |
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
bool debug_wp_set_value(uint16_t addr, int x16Bank, int op, uint8_t value); |
| 317 |
|
| 318 |
|
| 319 |
bool debug_wp_clear_value(uint16_t addr, int x16Bank); |
| 320 |
|
| 321 |
|
| 322 |
bool debug_wp_set_active(uint16_t addr, int x16Bank, bool active); |
| 323 |
|
| 324 |
|
| 325 |
bool debug_wp_covers(uint16_t addr); |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
const struct watchpoint *debug_wp_at(int index); |
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
bool debug_wp_check_write(uint16_t addr, uint8_t value); |
| 336 |
|
| 337 |
#ifdef __cplusplus |
| 338 |
} |
| 339 |
#endif |
| 340 |
|
| 341 |
#endif |