From: Toni Wilen Date: Sun, 19 Jul 2020 17:06:49 +0000 (+0300) Subject: Debugger fi command multiword support. X-Git-Tag: 4900~343 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=b732c21df689f005054023ada6161f53778506ee;p=francis%2Fwinuae.git Debugger fi command multiword support. --- diff --git a/debug.cpp b/debug.cpp index 581357de..79d6f938 100644 --- a/debug.cpp +++ b/debug.cpp @@ -61,8 +61,7 @@ #define TRACE_CHECKONLY 10 static int trace_mode; -static uae_u32 trace_param1; -static uae_u32 trace_param2; +static uae_u32 trace_param[3]; int debugger_active; static int debug_rewind; @@ -150,8 +149,8 @@ void activate_debugger_new_pc(uaecptr pc, int len) { activate_debugger(); trace_mode = TRACE_RANGE_PC; - trace_param1 = pc; - trace_param2 = pc + len; + trace_param[0] = pc; + trace_param[1] = pc + len; } bool debug_enforcer(void) @@ -189,7 +188,7 @@ static const TCHAR help[] = { _T(" fa
[] []\n") _T(" Find effective address
.\n") _T(" fi Step forward until PC points to RTS, RTD or RTE.\n") - _T(" fi Step forward until PC points to .\n") + _T(" fi [] [] Step forward until PC points to .\n") _T(" fp \"\"/ Step forward until process or is active.\n") _T(" fl List breakpoints.\n") _T(" fd Remove all breakpoints.\n") @@ -4703,10 +4702,19 @@ int instruction_breakpoint (TCHAR **c) return 0; } else if (nc == 'I') { next_char (c); - if (more_params (c)) - trace_param1 = readhex (c); - else - trace_param1 = 0x10000; + trace_param[1] = 0x10000; + trace_param[2] = 0x10000; + if (more_params(c)) { + trace_param[0] = readhex(c); + if (more_params(c)) { + trace_param[1] = readhex(c); + } + if (more_params(c)) { + trace_param[2] = readhex(c); + } + } else { + trace_param[0] = 0x10000; + } trace_mode = TRACE_MATCH_INS; return 1; } else if (nc == 'D' && (*c)[1] == 0) { @@ -4739,14 +4747,14 @@ int instruction_breakpoint (TCHAR **c) return 0; } trace_mode = TRACE_RANGE_PC; - trace_param1 = readhex (c); + trace_param[0] = readhex (c); if (more_params (c)) { - trace_param2 = readhex (c); + trace_param[1] = readhex (c); return 1; } else { for (i = 0; i < BREAKPOINT_TOTAL; i++) { bpn = &bpnodes[i]; - if (bpn->enabled && bpn->value1 == trace_param1) { + if (bpn->enabled && bpn->value1 == trace_param[0]) { bpn->enabled = 0; console_out (_T("Breakpoint removed.\n")); trace_mode = 0; @@ -4757,7 +4765,7 @@ int instruction_breakpoint (TCHAR **c) bpn = &bpnodes[i]; if (bpn->enabled) continue; - bpn->value1 = trace_param1; + bpn->value1 = trace_param[0]; bpn->type = BREAKPOINT_REG_PC; bpn->oper = BREAKPOINT_CMP_EQUAL; bpn->enabled = 1; @@ -5620,14 +5628,14 @@ static bool debug_line (TCHAR *input) case 't': no_trace_exceptions = 0; debug_cycles(); - trace_param1 = trace_param2 = 0; + trace_param[0] = trace_param[1] = 0; if (*inptr == 't') { no_trace_exceptions = 1; inptr++; } if (*inptr == 'r') { // break when PC in debugmem - if (debugmem_get_range(&trace_param1, &trace_param2)) { + if (debugmem_get_range(&trace_param[0], &trace_param[1])) { trace_mode = TRACE_RANGE_PC; return true; } @@ -5651,15 +5659,15 @@ static bool debug_line (TCHAR *input) // skip next source line if (debugmem_isactive()) { trace_mode = TRACE_SKIP_LINE; - trace_param1 = 1; - trace_param2 = debugmem_get_sourceline(M68K_GETPC, NULL, 0); + trace_param[0] = 1; + trace_param[1] = debugmem_get_sourceline(M68K_GETPC, NULL, 0); return true; } } else { if (more_params(&inptr)) - trace_param1 = readint(&inptr); - if (trace_param1 <= 0 || trace_param1 > 10000) - trace_param1 = 1; + trace_param[0] = readint(&inptr); + if (trace_param[0] <= 0 || trace_param[0] > 10000) + trace_param[0] = 1; trace_mode = TRACE_SKIP_INS; exception_debugging = 1; return true; @@ -5667,7 +5675,7 @@ static bool debug_line (TCHAR *input) break; case 'z': trace_mode = TRACE_MATCH_PC; - trace_param1 = nextpc; + trace_param[0] = nextpc; exception_debugging = 1; debug_cycles(); return true; @@ -6165,7 +6173,7 @@ void debug (void) } if (trace_mode) { - if (trace_mode == TRACE_MATCH_PC && trace_param1 == pc) + if (trace_mode == TRACE_MATCH_PC && trace_param[0] == pc) bp = -1; if (trace_mode == TRACE_RAM_PC) { addrbank *ab = &get_mem_bank(pc); @@ -6207,16 +6215,24 @@ void debug (void) } } } else if (trace_mode == TRACE_MATCH_INS) { - if (trace_param1 == 0x10000) { + if (trace_param[0] == 0x10000) { if (opcode == 0x4e75 || opcode == 0x4e73 || opcode == 0x4e77) bp = -1; - } else if (opcode == trace_param1) { + } else if (opcode == trace_param[0]) { bp = -1; + for (int op = 1; op < 3; op++) { + if (trace_param[op] != 0x10000) { + uae_u16 w = 0xffff; + debug_get_prefetch(op, &w); + if (w != trace_param[op]) + bp = 0; + } + } } } else if (trace_mode == TRACE_SKIP_INS) { - if (trace_param1 != 0) - trace_param1--; - if (trace_param1 == 0) { + if (trace_param[0] != 0) + trace_param[0]--; + if (trace_param[0] == 0) { bp = -1; } #if 0 @@ -6224,14 +6240,14 @@ void debug (void) bp = -1; #endif } else if (trace_mode == TRACE_RANGE_PC) { - if (pc >= trace_param1 && pc < trace_param2) + if (pc >= trace_param[0] && pc < trace_param[1]) bp = -1; } else if (trace_mode == TRACE_SKIP_LINE) { - if (trace_param1 != 0) - trace_param1--; - if (trace_param1 == 0) { + if (trace_param[0] != 0) + trace_param[0]--; + if (trace_param[0] == 0) { int line = debugmem_get_sourceline(pc, NULL, 0); - if (line > 0 && line != trace_param2) + if (line > 0 && line != trace_param[1]) bp = -1; } } @@ -7224,6 +7240,35 @@ bool debug_trainer_event(int evt, int state) return false; } +bool debug_get_prefetch(int idx, uae_u16 *opword) +{ + if (currprefs.cpu_compatible) { + if (currprefs.cpu_model < 68020) { + if (idx == 0) { + *opword = regs.ir; + return true; + } + if (idx == 1) { + *opword = regs.irc; + return true; + } + *opword = get_word_debug(m68k_getpc() + idx * 2); + return false; + } else { + if (regs.prefetch020_valid[idx]) { + *opword = regs.prefetch020[idx]; + return true; + } + *opword = get_word_debug(m68k_getpc() + idx * 2); + return false; + } + + } else { + *opword = get_word_debug(m68k_getpc() + idx * 2); + return false; + } +} + #define DEBUGSPRINTF_SIZE 32 static int debugsprintf_cnt; struct dsprintfstack diff --git a/include/debug.h b/include/debug.h index 36c80089..92515ce3 100644 --- a/include/debug.h +++ b/include/debug.h @@ -63,6 +63,7 @@ extern void debug_check_reg(uae_u32 addr, int write, uae_u16 v); extern int memwatch_access_validator; #define DEBUG_SPRINTF_ADDRESS 0xbfff00 extern bool debug_sprintf(uaecptr, uae_u32, int); +extern bool debug_get_prefetch(int idx, uae_u16 *opword); extern void debug_init_trainer(const TCHAR*); extern void debug_trainer_match(void); diff --git a/newcpu.cpp b/newcpu.cpp index 65a2617c..20e26e4a 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -6447,23 +6447,23 @@ void m68k_dumpstate(uaecptr *nextpc, uaecptr prevpc) console_out_f (_T("TT0: %08X TT1: %08X TC: %08X\n"), tt0_030, tt1_030, tc_030); } if (currprefs.cpu_compatible) { - if (currprefs.cpu_model == 68000) { + console_out_f(_T("Prefetch")); + if (currprefs.cpu_model == 68020 || currprefs.cpu_model == 68030) { + console_out_f(_T(" %08x %08x (%d)"), + regs.cacheholdingaddr020, regs.cacheholdingdata020, regs.cacheholdingdata_valid); + } + for (int i = 0; i < 3; i++) { + uae_u16 w; + if (!debug_get_prefetch(i, &w)) + break; struct instr *dp; - struct mnemolookup *lookup1, *lookup2; - dp = table68k + regs.irc; - for (lookup1 = lookuptab; lookup1->mnemo != dp->mnemo; lookup1++) - ; - dp = table68k + regs.ir; - for (lookup2 = lookuptab; lookup2->mnemo != dp->mnemo; lookup2++) + struct mnemolookup *lookup; + dp = table68k + w; + for (lookup = lookuptab; lookup->mnemo != dp->mnemo; lookup++) ; - console_out_f (_T("Prefetch %04x (%s) %04x (%s) Chip latch %08X\n"), regs.irc, lookup1->name, regs.ir, lookup2->name, regs.chipset_latch_rw); - } else if (currprefs.cpu_model == 68020 || currprefs.cpu_model == 68030) { - console_out_f (_T("Prefetch %08x %08x (%d) %04x (%d) %04x (%d) %04x (%d)\n"), - regs.cacheholdingaddr020, regs.cacheholdingdata020, regs.cacheholdingdata_valid, - regs.prefetch020[0], regs.prefetch020_valid[0], - regs.prefetch020[1], regs.prefetch020_valid[1], - regs.prefetch020[2], regs.prefetch020_valid[2]); + console_out_f(_T(" %04x (%s)"), w, lookup->name); } + console_out_f (_T(" Chip latch %08X\n"), regs.chipset_latch_rw); } if (prevpc != 0xffffffff && pc - prevpc < 100) { while (prevpc < pc) {