From 2e3e8f01b3a052246a0a3d7b3825b3f35b113e19 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Thu, 7 May 2026 17:22:13 +0300 Subject: [PATCH] Debugger updates --- debug.cpp | 112 ++++++++++++++++++++++++++++++++---------------- include/debug.h | 8 ++-- 2 files changed, 80 insertions(+), 40 deletions(-) diff --git a/debug.cpp b/debug.cpp index b51fbf38..1e6f78fc 100644 --- a/debug.cpp +++ b/debug.cpp @@ -198,15 +198,15 @@ static const TCHAR help[] = { _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(" fp \"\"/ Step forward until process or is active.\n") + _T(" fp \"\"/ Step forward until process or is active.\n") _T(" fl List breakpoints.\n") _T(" fd Remove all breakpoints.\n") _T(" fs | Wait n scanlines/position.\n") _T(" fc Wait n color clocks.\n") - _T(" fo [ ] Conditional register breakpoint [Nx] [Hx].\n") - _T(" reg=Dx,Ax,PC,USP,ISP,VBR,SR. oper:!=,==,<,>,>=,<=,-,!- (-=val to val2 range).\n") + _T(" fo [ ] Conditional register breakpoint [Nx] [Hx].\n") + _T(" reg=Dx,Ax,PC,USP,ISP,VBR,SR. oper:!=,==,<,>,>=,<=,-,!- (-/!-=val to val2 range).\n") _T(" f Step forward until <= PC <= .\n") - _T(" e Dump contents of all custom registers, ea = AGA colors.\n") + _T(" e[a/x] Dump contents of all custom registers, ea = AGA colors, ex = register accesses.\n") _T(" i [] Dump contents of interrupt and trap vectors.\n") _T(" il [] Exception breakpoint.\n") _T(" o <0-2|addr> []View memory as Copper instructions.\n") @@ -578,6 +578,16 @@ static const TCHAR *debugoper[] = { _T("!-"), NULL }; +static bool debugoper2[] = { + false, + false, + false, + false, + false, + false, + true, + true +}; static int getoperidx(TCHAR **c, bool *opersigned) { @@ -6187,28 +6197,38 @@ int instruction_breakpoint(TCHAR **c) next_char(c); if (more_params(c)) { int bpidx = readint(c, NULL); - if (more_params(c) && bpidx >= 0 && bpidx < BREAKPOINT_TOTAL) { + if (bpidx >= 0 && bpidx < BREAKPOINT_TOTAL) { bpn = &bpnodes[bpidx]; - int regid = getregidx(c); - if (regid >= 0) { - bpn->type = regid; - bpn->mask = 0xffffffff; - if (more_params(c)) { - int operid = getoperidx(c, &bpn->opersigned); - if (more_params(c) && operid >= 0) { - bpn->oper = operid; - bpn->value1 = readhex(c, NULL); - bpn->enabled = 1; - if (more_params(c)) { - bpn->mask = readhex(c, NULL); - if (more_params(c)) { - bpn->value2 = readhex(c, NULL); + if (more_params(c)) { + int regid = getregidx(c); + if (regid >= 0) { + bpn->type = regid; + bpn->mask = 0xffffffff; + if (more_params(c)) { + int operid = getoperidx(c, &bpn->opersigned); + if (more_params(c) && operid >= 0) { + bpn->oper = operid; + bpn->value1 = readhex(c, NULL); + bpn->enabled = 1; + if (debugoper2[operid]) { + if (more_params(c)) { + bpn->value2 = readhex(c, NULL); + } + } + if (more_params(c)) { + uae_u32 v = readhex(c, &err); + if (!err) { + bpn->mask = v; + } } + check_breakpoint_extra(c, bpn); + console_out(_T("Breakpoint added.\n")); } - check_breakpoint_extra(c, bpn); - console_out(_T("Breakpoint added.\n")); } } + } else { + bpn->enabled = false; + console_out_f(_T("Breakpoint %d removed.\n"), bpidx); } } } @@ -6267,8 +6287,11 @@ int instruction_breakpoint(TCHAR **c) continue; } console_out_f(_T("%d: %s %s %08x"), i, debugregs[bpn->type], debugoper[bpn->oper], bpn->value1); - if (bpn->mask || bpn->value2) { - console_out_f (_T(" [%08x %08x]"), bpn->mask, bpn->value2); + if (bpn->oper == BREAKPOINT_CMP_RANGE || bpn->oper == BREAKPOINT_CMP_NRANGE) { + console_out_f(_T(" - %08x"), bpn->value2); + } + if (bpn->mask != 0xffffffff) { + console_out_f(_T(" [%08x]"), bpn->mask); } if (bpn->cnt > 0) { console_out_f(_T(" N=%d"), bpn->cnt); @@ -6279,10 +6302,9 @@ int instruction_breakpoint(TCHAR **c) console_out_f(_T("\n")); got = 1; } - if (!got) + if (!got) { console_out (_T("No breakpoints.\n")); - else - console_out (_T("\n")); + } return 0; } trace_mode = TRACE_RANGE_PC; @@ -7963,29 +7985,47 @@ static bool check_breakpoint(struct breakpoint_node *bpn, uaecptr pc) case BREAKPOINT_CMP_EQUAL: if (cval == value1) return true; - break; + break; case BREAKPOINT_CMP_NEQUAL: if (cval != value1) return true; - break; + break; case BREAKPOINT_CMP_SMALLER: if (opersigned) { - if (cvals <= value1s) + if (cvals < value1s) return true; } else { - if (cval <= value1) + if (cval < value1) return true; } - break; + break; case BREAKPOINT_CMP_LARGER: if (opersigned) { - if (cvals >= value1s) + if (cvals > value1s) return true; } else { - if (cval >= value1) + if (cval > value1) return true; } - break; + break; + case BREAKPOINT_CMP_SMALLER_EQUAL: + if (opersigned) { + if (cvals <= value1s) + return true; + } else { + if (cval <= value1) + return true; + } + break; + case BREAKPOINT_CMP_LARGER_EQUAL: + if (opersigned) { + if (cvals >= value1s) + return true; + } else { + if (cval >= value1) + return true; + } + break; case BREAKPOINT_CMP_RANGE: if (opersigned) { if (cvals >= value1s && cvals <= value2s) @@ -7994,7 +8034,7 @@ static bool check_breakpoint(struct breakpoint_node *bpn, uaecptr pc) if (cval >= value1 && cval <= value2) return true; } - break; + break; case BREAKPOINT_CMP_NRANGE: if (opersigned) { if (cvals <= value1s || cvals >= value2s) @@ -8003,7 +8043,7 @@ static bool check_breakpoint(struct breakpoint_node *bpn, uaecptr pc) if (cval <= value1 || cval >= value2) return true; } - break; + break; } } return false; diff --git a/include/debug.h b/include/debug.h index d29ad6fe..ff3d4564 100644 --- a/include/debug.h +++ b/include/debug.h @@ -116,10 +116,10 @@ extern void debug_smc_clear(uaecptr addr, int size); #define BREAKPOINT_CMP_NEQUAL 1 #define BREAKPOINT_CMP_SMALLER_EQUAL 2 #define BREAKPOINT_CMP_LARGER_EQUAL 3 -#define BREAKPOINT_CMP_SMALLER 2 -#define BREAKPOINT_CMP_LARGER 3 -#define BREAKPOINT_CMP_RANGE 4 -#define BREAKPOINT_CMP_NRANGE 5 +#define BREAKPOINT_CMP_SMALLER 4 +#define BREAKPOINT_CMP_LARGER 5 +#define BREAKPOINT_CMP_RANGE 6 +#define BREAKPOINT_CMP_NRANGE 7 struct breakpoint_node { uae_u32 value1; -- 2.47.3