Mercurial > repos > blastem
comparison debug.c @ 799:0b692b5d154b
Merge
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 26 Jul 2015 13:25:31 -0700 |
parents | 792be135d3af |
children | cc05444a4a4e |
comparison
equal
deleted
inserted
replaced
798:062a2199daf6 | 799:0b692b5d154b |
---|---|
5 #include <string.h> | 5 #include <string.h> |
6 #ifndef _WIN32 | 6 #ifndef _WIN32 |
7 #include <sys/select.h> | 7 #include <sys/select.h> |
8 #endif | 8 #endif |
9 #include "render.h" | 9 #include "render.h" |
10 #include "util.h" | |
11 #include "terminal.h" | |
10 | 12 |
11 static bp_def * breakpoints = NULL; | 13 static bp_def * breakpoints = NULL; |
12 static bp_def * zbreakpoints = NULL; | 14 static bp_def * zbreakpoints = NULL; |
13 static uint32_t bp_index = 0; | 15 static uint32_t bp_index = 0; |
14 static uint32_t zbp_index = 0; | 16 static uint32_t zbp_index = 0; |
284 static char last_cmd[1024]; | 286 static char last_cmd[1024]; |
285 char input_buf[1024]; | 287 char input_buf[1024]; |
286 static uint16_t branch_t; | 288 static uint16_t branch_t; |
287 static uint16_t branch_f; | 289 static uint16_t branch_f; |
288 z80inst inst; | 290 z80inst inst; |
291 init_terminal(); | |
289 //Check if this is a user set breakpoint, or just a temporary one | 292 //Check if this is a user set breakpoint, or just a temporary one |
290 bp_def ** this_bp = find_breakpoint(&zbreakpoints, address); | 293 bp_def ** this_bp = find_breakpoint(&zbreakpoints, address); |
291 if (*this_bp) { | 294 if (*this_bp) { |
292 printf("Z80 Breakpoint %d hit\n", (*this_bp)->index); | 295 printf("Z80 Breakpoint %d hit\n", (*this_bp)->index); |
293 } else { | 296 } else { |
296 uint8_t * pc; | 299 uint8_t * pc; |
297 if (address < 0x4000) { | 300 if (address < 0x4000) { |
298 pc = z80_ram + (address & 0x1FFF); | 301 pc = z80_ram + (address & 0x1FFF); |
299 } else if (address >= 0x8000) { | 302 } else if (address >= 0x8000) { |
300 if (context->bank_reg < (0x400000 >> 15)) { | 303 if (context->bank_reg < (0x400000 >> 15)) { |
301 fprintf(stderr, "Entered Z80 debugger in banked memory address %X, which is not yet supported\n", address); | 304 fatal_error("Entered Z80 debugger in banked memory address %X, which is not yet supported\n", address); |
302 exit(1); | 305 } else { |
303 } else { | 306 fatal_error("Entered Z80 debugger in banked memory address %X, but the bank is not pointed to a cartridge address\n", address); |
304 fprintf(stderr, "Entered Z80 debugger in banked memory address %X, but the bank is not pointed to a cartridge address\n", address); | |
305 exit(1); | |
306 } | 307 } |
307 } else { | 308 } else { |
308 fprintf(stderr, "Entered Z80 debugger at address %X\n", address); | 309 fatal_error("Entered Z80 debugger at address %X\n", address); |
309 exit(1); | |
310 } | 310 } |
311 for (disp_def * cur = zdisplays; cur; cur = cur->next) { | 311 for (disp_def * cur = zdisplays; cur; cur = cur->next) { |
312 zdebugger_print(context, cur->format_char, cur->param); | 312 zdebugger_print(context, cur->format_char, cur->param); |
313 } | 313 } |
314 uint8_t * after_pc = z80_decode(pc, &inst); | 314 uint8_t * after_pc = z80_decode(pc, &inst); |
473 static char last_cmd[1024]; | 473 static char last_cmd[1024]; |
474 char input_buf[1024]; | 474 char input_buf[1024]; |
475 static uint32_t branch_t; | 475 static uint32_t branch_t; |
476 static uint32_t branch_f; | 476 static uint32_t branch_f; |
477 m68kinst inst; | 477 m68kinst inst; |
478 | |
479 init_terminal(); | |
480 | |
478 sync_components(context, 0); | 481 sync_components(context, 0); |
479 //probably not necessary, but let's play it safe | 482 //probably not necessary, but let's play it safe |
480 address &= 0xFFFFFF; | 483 address &= 0xFFFFFF; |
481 if (address == branch_t) { | 484 if (address == branch_t) { |
482 bp_def ** f_bp = find_breakpoint(&breakpoints, branch_f); | 485 bp_def ** f_bp = find_breakpoint(&breakpoints, branch_f); |
502 if (address < 0x400000) { | 505 if (address < 0x400000) { |
503 pc = cart + address/2; | 506 pc = cart + address/2; |
504 } else if(address > 0xE00000) { | 507 } else if(address > 0xE00000) { |
505 pc = ram + (address & 0xFFFF)/2; | 508 pc = ram + (address & 0xFFFF)/2; |
506 } else { | 509 } else { |
507 fprintf(stderr, "Entered 68K debugger at address %X\n", address); | 510 fatal_error("Entered 68K debugger at address %X\n", address); |
508 exit(1); | |
509 } | 511 } |
510 uint16_t * after_pc = m68k_decode(pc, &inst, address); | 512 uint16_t * after_pc = m68k_decode(pc, &inst, address); |
511 m68k_disasm(&inst, input_buf); | 513 m68k_disasm(&inst, input_buf); |
512 printf("%X: %s\n", address, input_buf); | 514 printf("%X: %s\n", address, input_buf); |
513 uint32_t after = address + (after_pc-pc)*2; | 515 uint32_t after = address + (after_pc-pc)*2; |