]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Debugger fi command multiword support.
authorToni Wilen <twilen@winuae.net>
Sun, 19 Jul 2020 17:06:49 +0000 (20:06 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 19 Jul 2020 17:06:49 +0000 (20:06 +0300)
debug.cpp
include/debug.h
newcpu.cpp

index 581357de296202c996bd02840be9bf33ce162ce5..79d6f938d985e7a0984ccf3a4afe62d2c71cf945 100644 (file)
--- 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 <address> [<start>] [<end>]\n")
        _T("                        Find effective address <address>.\n")
        _T("  fi                    Step forward until PC points to RTS, RTD or RTE.\n")
-       _T("  fi <opcode>           Step forward until PC points to <opcode>.\n")
+       _T("  fi <opcode> [<w2>] [<w3>] Step forward until PC points to <opcode>.\n")
        _T("  fp \"<name>\"/<addr>    Step forward until process <name> or <addr> 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
index 36c800890f94789b6b59fc6f8e30a1a4b5ce4a66..92515ce3e2c561fde5e1571fd8a2319e0a636fa3 100644 (file)
@@ -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);
index 65a2617c41cebfbb113d9860123dc52c50eaf5d7..20e26e4a6187259f3dccd4dd9a71cf8f2b87301a 100644 (file)
@@ -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) {