Mercurial > repos > blastem
comparison debug.c @ 792:724bbec47f86
Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 25 Jul 2015 18:22:07 -0700 |
parents | 85c98a222fea |
children | 792be135d3af |
comparison
equal
deleted
inserted
replaced
791:60686f8d5e48 | 792:724bbec47f86 |
---|---|
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" | |
10 | 11 |
11 static bp_def * breakpoints = NULL; | 12 static bp_def * breakpoints = NULL; |
12 static bp_def * zbreakpoints = NULL; | 13 static bp_def * zbreakpoints = NULL; |
13 static uint32_t bp_index = 0; | 14 static uint32_t bp_index = 0; |
14 static uint32_t zbp_index = 0; | 15 static uint32_t zbp_index = 0; |
296 uint8_t * pc; | 297 uint8_t * pc; |
297 if (address < 0x4000) { | 298 if (address < 0x4000) { |
298 pc = z80_ram + (address & 0x1FFF); | 299 pc = z80_ram + (address & 0x1FFF); |
299 } else if (address >= 0x8000) { | 300 } else if (address >= 0x8000) { |
300 if (context->bank_reg < (0x400000 >> 15)) { | 301 if (context->bank_reg < (0x400000 >> 15)) { |
301 fprintf(stderr, "Entered Z80 debugger in banked memory address %X, which is not yet supported\n", address); | 302 fatal_error("Entered Z80 debugger in banked memory address %X, which is not yet supported\n", address); |
302 exit(1); | 303 } else { |
303 } else { | 304 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 } | 305 } |
307 } else { | 306 } else { |
308 fprintf(stderr, "Entered Z80 debugger at address %X\n", address); | 307 fatal_error("Entered Z80 debugger at address %X\n", address); |
309 exit(1); | |
310 } | 308 } |
311 for (disp_def * cur = zdisplays; cur; cur = cur->next) { | 309 for (disp_def * cur = zdisplays; cur; cur = cur->next) { |
312 zdebugger_print(context, cur->format_char, cur->param); | 310 zdebugger_print(context, cur->format_char, cur->param); |
313 } | 311 } |
314 uint8_t * after_pc = z80_decode(pc, &inst); | 312 uint8_t * after_pc = z80_decode(pc, &inst); |
502 if (address < 0x400000) { | 500 if (address < 0x400000) { |
503 pc = cart + address/2; | 501 pc = cart + address/2; |
504 } else if(address > 0xE00000) { | 502 } else if(address > 0xE00000) { |
505 pc = ram + (address & 0xFFFF)/2; | 503 pc = ram + (address & 0xFFFF)/2; |
506 } else { | 504 } else { |
507 fprintf(stderr, "Entered 68K debugger at address %X\n", address); | 505 fatal_error("Entered 68K debugger at address %X\n", address); |
508 exit(1); | |
509 } | 506 } |
510 uint16_t * after_pc = m68k_decode(pc, &inst, address); | 507 uint16_t * after_pc = m68k_decode(pc, &inst, address); |
511 m68k_disasm(&inst, input_buf); | 508 m68k_disasm(&inst, input_buf); |
512 printf("%X: %s\n", address, input_buf); | 509 printf("%X: %s\n", address, input_buf); |
513 uint32_t after = address + (after_pc-pc)*2; | 510 uint32_t after = address + (after_pc-pc)*2; |