--- uae/src/debug.c 2018/04/24 17:10:43 1.1.1.11 +++ uae/src/debug.c 2018/04/24 17:18:21 1.1.1.14 @@ -13,7 +13,6 @@ #include #include -#include "config.h" #include "options.h" #include "threaddep/thread.h" #include "uae.h" @@ -29,10 +28,6 @@ #include "disk.h" #include "autoconf.h" -#define console_out printf -#define console_flush() fflush (stdout) -#define console_get(BUF, COUNT) fgets (BUF, COUNT, stdin) - static int debugger_active; static uaecptr skipaddr_start, skipaddr_end; static int skipaddr_doskip; @@ -113,7 +108,7 @@ static void debug_help (void) static void ignore_ws (char **c) { - while (**c && isspace(**c)) (*c)++; + while (**c && isspace (**c)) (*c)++; } static uae_u32 readint (char **c); @@ -127,11 +122,11 @@ static uae_u32 readhex (char **c) (*c)++; return readint (c); } - while (isxdigit(nc = **c)) { + while (isxdigit (nc = **c)) { (*c)++; val *= 16; - nc = toupper(nc); - if (isdigit(nc)) { + nc = toupper (nc); + if (isdigit (nc)) { val += nc - '0'; } else { val += nc - 'A' + 10; @@ -151,13 +146,13 @@ static uae_u32 readint (char **c) (*c)++; return readhex (c); } - if (**c == '0' && toupper((*c)[1]) == 'X') { - (*c)+= 2; + if (**c == '0' && toupper ((*c)[1]) == 'X') { + (*c)+= 2; return readhex (c); } if (**c == '-') negative = 1, (*c)++; - while (isdigit(nc = **c)) { + while (isdigit (nc = **c)) { (*c)++; val *= 10; val += nc - '0'; @@ -165,7 +160,7 @@ static uae_u32 readint (char **c) return val * (negative ? -1 : 1); } -static char next_char( char **c) +static char next_char ( char **c) { ignore_ws (c); return *(*c)++; @@ -248,7 +243,7 @@ static void foundmod (uae_u32 ptr, char ptr2 += 0x2A; for (i = 0; i < 31; i++, ptr2 += 30) length += 2*((ptr2[0]<<8)+ptr2[1]); - + console_out ("Name \"%s\", Length 0x%lx bytes.\n", name, length); } @@ -308,7 +303,7 @@ static void dump_vectors (void) console_out ("\t\t\t\t"); } if (trap_labels[j].name) { - console_out("$%08X: %s \t $%08X", trap_labels[j].adr + regs.vbr, + console_out ("$%08X: %s \t $%08X", trap_labels[j].adr + regs.vbr, trap_labels[j].name, get_long (trap_labels[j].adr + regs.vbr)); j++; } @@ -414,7 +409,7 @@ static uaecptr decode_copperlist (FILE* } return address; /* You may wonder why I don't stop this at the end of the copperlist? - * Well, often nice things are hidden at the end and it is debatable the actual + * Well, often nice things are hidden at the end and it is debatable the actual * values that mean the end of the copperlist */ } @@ -458,7 +453,7 @@ static void cheatsearch (char **c) } else { for (count = 0; count<255; count++) { if (p[vlist[count]+3] == (val & 0xff) - && p[vlist[count]+2] == (val>>8 & 0xff) + && p[vlist[count]+2] == (val>>8 & 0xff) && p[vlist[count]+1] == (val>>16 & 0xff) && p[vlist[count]] == (val>>24 & 0xff)) { @@ -563,15 +558,15 @@ static void illg_debug_do (uaecptr addr, else write_log ("RW: %08.8X %c PC=%08.8X\n", ad, rws, pc); if (illgdebug_break) - activate_debugger (); + activate_debugger (); } else if ((mask & 1) && rw) { write_log ("RO: %08.8X=%02.2X %c PC=%08.8X\n", ad, v, rws, pc); if (illgdebug_break) - activate_debugger (); + activate_debugger (); } else if ((mask & 2) && !rw) { write_log ("WO: %08.8X %c PC=%08.8X\n", ad, rws, pc); if (illgdebug_break) - activate_debugger (); + activate_debugger (); } } } @@ -608,7 +603,7 @@ static void memwatch_func (uaecptr addr, brk = 1; if (brk && mwnodes[i].modval_written) { if (!rw) { - brk = 0; + brk = 0; } else if (mwnodes[i].modval_written == 1) { mwnodes[i].modval_written = 2; mwnodes[i].modval = val; @@ -636,7 +631,7 @@ static uae_u32 REGPARAM2 debug_lget (uae { int off = debug_mem_off (addr); uae_u32 v; - v = debug_mem_banks[off]->lget(addr); + v = debug_mem_banks[off]->lget (addr); memwatch_func (addr, 0, 4, v); return v; } @@ -644,7 +639,7 @@ static uae_u32 REGPARAM2 debug_wget (uae { int off = debug_mem_off (addr); uae_u32 v; - v = debug_mem_banks[off]->wget(addr); + v = debug_mem_banks[off]->wget (addr); memwatch_func (addr, 0, 2, v); return v; } @@ -652,7 +647,7 @@ static uae_u32 REGPARAM2 debug_bget (uae { int off = debug_mem_off (addr); uae_u32 v; - v = debug_mem_banks[off]->bget(addr); + v = debug_mem_banks[off]->bget (addr); memwatch_func (addr, 0, 1, v); return v; } @@ -660,20 +655,20 @@ static void REGPARAM2 debug_lput (uaecpt { int off = debug_mem_off (addr); memwatch_func (addr, 1, 4, v); - debug_mem_banks[off]->lput(addr, v); -} + debug_mem_banks[off]->lput (addr, v); +} static void REGPARAM2 debug_wput (uaecptr addr, uae_u32 v) { int off = debug_mem_off (addr); memwatch_func (addr, 1, 2, v); - debug_mem_banks[off]->wput(addr, v); -} + debug_mem_banks[off]->wput (addr, v); +} static void REGPARAM2 debug_bput (uaecptr addr, uae_u32 v) { int off = debug_mem_off (addr); memwatch_func (addr, 1, 1, v); - debug_mem_banks[off]->bput(addr, v); -} + debug_mem_banks[off]->bput (addr, v); +} static int REGPARAM2 debug_check (uaecptr addr, uae_u32 size) { return debug_mem_banks[munge24 (addr) >> 16]->check (addr, size); @@ -747,7 +742,7 @@ static void memwatch_dump (int num) console_out (" =%X", mwn->val); if (mwn->modval_written) console_out (" =M"); - console_out("\n"); + console_out ("\n"); } } } @@ -826,13 +821,13 @@ static void memwatch (char **c) char nc = toupper (next_char (c)); if (nc == 'W') mwn->rw = 1; - else if (nc == 'R' && toupper(**c) != 'W') + else if (nc == 'R' && toupper (**c) != 'W') mwn->rw = 0; - else if (nc == 'R' && toupper(**c) == 'W') + else if (nc == 'R' && toupper (**c) == 'W') next_char (c); ignore_ws (c); if (more_params (c)) { - if (toupper(**c) == 'M') { + if (toupper (**c) == 'M') { mwn->modval_written = 1; } else { mwn->val = readhex (c); @@ -850,9 +845,9 @@ static void writeintomem (char **c) uae_u32 val = 0; char cc; - ignore_ws(c); + ignore_ws (c); addr = readhex (c); - ignore_ws(c); + ignore_ws (c); val = readhex (c); if (val > 0xffff) { put_long (addr, val); @@ -904,7 +899,7 @@ static int instruction_breakpoint (char int i; if (more_params (c)) { - char nc = toupper((*c)[0]); + char nc = toupper ((*c)[0]); if (nc == 'I') { next_char (c); if (more_params (c)) @@ -932,7 +927,7 @@ static int instruction_breakpoint (char console_out ("No breakpoints\n"); else console_out ("\n"); - return 0; + return 0; } skipaddr_doskip = 1; skipaddr_start = readhex (c); @@ -956,15 +951,15 @@ static int instruction_breakpoint (char bpn->addr = skipaddr_start; bpn->enabled = 1; console_out ("Breakpoint added\n"); - skipaddr_start = 0xffffffff; - skipaddr_doskip = 0; + skipaddr_start = 0xffffffff; + skipaddr_doskip = 0; break; } return 0; } } if (skipaddr_start == 0xC0DEDBAD) { - trace_same_insn_count = 0; + trace_same_insn_count = 0; logfile = fopen ("uae.trace", "w"); memcpy (trace_insn_copy, regs.pc_p, 10); memcpy (&trace_prev_regs, ®s, sizeof regs); @@ -1048,7 +1043,7 @@ static void searchmem (char **cc) nc = toupper (next_char (cc)); if (isspace (nc)) break; - if (isdigit(nc)) + if (isdigit (nc)) val = nc - '0'; else val = nc - 'A' + 10; @@ -1060,7 +1055,7 @@ static void searchmem (char **cc) nc = toupper (next_char (cc)); if (isspace (nc)) break; - if (isdigit(nc)) + if (isdigit (nc)) val += nc - '0'; else val += nc - 'A' + 10; @@ -1104,13 +1099,13 @@ static void searchmem (char **cc) if (!got) console_out ("nothing found"); console_out ("\n"); -} +} static void m68k_modify (char **inptr) { char c1, c2; uae_u32 v; - + c1 = toupper (next_char (inptr)); if (!more_params (inptr)) return; @@ -1142,20 +1137,20 @@ static void debug_1 (void) console_out (">"); console_flush (); - if (!console_get (input, 80)) + if (!console_get (input, 80)) continue; inptr = input; cmd = next_char (&inptr); switch (cmd) { case 'c': dumpcia (); dumpdisk (); dumpcustom (); break; case 'i': dump_vectors (); break; - case 'r': if (more_params(&inptr)) + case 'r': if (more_params (&inptr)) m68k_modify (&inptr); else m68k_dumpstate (stdout, &nextpc); break; case 'M': modulesearch (); break; - case 'C': cheatsearch (&inptr); break; + case 'C': cheatsearch (&inptr); break; case 'W': writeintomem (&inptr); break; case 'w': memwatch (&inptr); break; case 'S': savemem (&inptr); break; @@ -1165,12 +1160,12 @@ static void debug_1 (void) uae_u32 daddr; int count; - if (more_params(&inptr)) - daddr = readhex(&inptr); + if (more_params (&inptr)) + daddr = readhex (&inptr); else daddr = nxdis; - if (more_params(&inptr)) - count = readhex(&inptr); + if (more_params (&inptr)) + count = readhex (&inptr); else count = 10; m68k_disasm (stdout, daddr, &nxdis, count); @@ -1197,7 +1192,7 @@ static void debug_1 (void) return; break; - case 'q': uae_quit(); + case 'q': uae_quit (); debugger_active = 0; debugging = 0; return; @@ -1221,8 +1216,8 @@ static void debug_1 (void) union flagu save_flags = regflags; #endif - if (more_params(&inptr)) - count = readhex(&inptr); + if (more_params (&inptr)) + count = readhex (&inptr); else count = 10; if (count < 0) @@ -1250,26 +1245,26 @@ static void debug_1 (void) case 'm': { uae_u32 maddr; int lines; - if (more_params(&inptr)) - maddr = readhex(&inptr); + if (more_params (&inptr)) + maddr = readhex (&inptr); else maddr = nxmem; - if (more_params(&inptr)) - lines = readhex(&inptr); + if (more_params (&inptr)) + lines = readhex (&inptr); else lines = 20; - dumpmem(maddr, &nxmem, lines); + dumpmem (maddr, &nxmem, lines); } break; case 'o': { uae_u32 maddr; int lines; - - if (more_params(&inptr)) { - maddr = readhex(&inptr); + + if (more_params (&inptr)) { + maddr = readhex (&inptr); if (maddr == 1 || maddr == 2) - maddr = get_copper_address (maddr); + maddr = get_copper_address (maddr); } else maddr = nxcopper; @@ -1329,12 +1324,12 @@ void debug (void) if (!memwatch_triggered) { if (do_skip) { - uae_u32 pc = munge24 (m68k_getpc()); - uae_u16 opcode = currprefs.cpu_compatible ? regs.ir : get_word (pc); + uae_u32 pc = munge24 (m68k_getpc ()); + uae_u16 opcode = currprefs.cpu_model == 68000 ? regs.ir : get_word (pc); int bp = 0; for (i = 0; i < BREAKPOINT_TOTAL; i++) { - if (!bpnodes[i].enabled) + if (!bpnodes[i].enabled) continue; if (bpnodes[i].addr == pc) { bp = 1; @@ -1362,12 +1357,12 @@ void debug (void) } } if (!bp) { - set_special (SPCFLAG_BRK); + set_special (SPCFLAG_BRK); return; } } } else { - write_log ("Memwatch %d: break at %08.8X.%c %c %08.8X\n", memwatch_triggered - 1, mwhit.addr, + write_log ("Memwatch %d: break at %08.8X.%c %c %08.8X\n", memwatch_triggered - 1, mwhit.addr, mwhit.size == 1 ? 'B' : (mwhit.size == 2 ? 'W' : 'L'), mwhit.rw ? 'W' : 'R', mwhit.val); memwatch_triggered = 0; } @@ -1383,7 +1378,7 @@ void debug (void) history[lasthist] = regs; historyf[lasthist] = regflags; #else - history[lasthist] = m68k_getpc(); + history[lasthist] = m68k_getpc (); #endif if (++lasthist == MAX_HIST) lasthist = 0; if (lasthist == firsthist) { @@ -1405,7 +1400,7 @@ void debug (void) do_skip = 1; } if (do_skip) { - set_special (SPCFLAG_BRK); + set_special (SPCFLAG_BRK); debugging = 1; } #if 0 @@ -1416,7 +1411,7 @@ void debug (void) int notinrom (void) { - if (munge24 (m68k_getpc()) < 0xe0000) + if (munge24 (m68k_getpc ()) < 0xe0000) return 1; return 0; } @@ -1424,8 +1419,8 @@ int notinrom (void) const char *debuginfo (int mode) { static char txt[100]; - uae_u32 pc = m68k_getpc(); + uae_u32 pc = m68k_getpc (); sprintf (txt, "PC=%08.8X INS=%04.4X %04.4X %04.4X", - pc, get_word(pc), get_word(pc+2), get_word(pc+4)); + pc, get_word (pc), get_word (pc+2), get_word (pc+4)); return txt; }