From ccc5cfe1e5afb64d25cc3963270898993dc70e81 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Tue, 1 May 2018 16:27:54 +0300 Subject: [PATCH] ex debugger command that shows last PC (cpu/copper) write access and value written. --- custom.cpp | 10 ++++++++-- debug.cpp | 42 ++++++++++++++++++++++++++++++------------ include/custom.h | 7 +++++++ 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/custom.cpp b/custom.cpp index a4b7ea55..a2e80ab6 100644 --- a/custom.cpp +++ b/custom.cpp @@ -415,6 +415,8 @@ static bool ddfstop_matched; static int bitplane_overrun, bitplane_overrun_hpos; static int bitplane_overrun_fetch_cycle, bitplane_overrun_cycle_diagram_shift; +struct custom_store custom_storage[256]; + enum plfstate { plf_idle, @@ -9102,6 +9104,7 @@ void custom_reset (bool hardreset, bool keyboardreset) lightpen_x[1] = -1; lightpen_y[1] = -1; nr_armed = 0; + memset(custom_storage, 0, sizeof(custom_storage)); if (!savestate_state) { cia_hsync = 0; @@ -9581,12 +9584,15 @@ static int REGPARAM2 custom_wput_1 (int hpos, uaecptr addr, uae_u32 value, int n { addr &= 0x1FE; value &= 0xffff; + custom_storage[addr >> 1].value = (uae_u16)value; + custom_storage[addr >> 1].pc = copper_access ? cop_state.ip | 1 : M68K_GETPC; #ifdef ACTION_REPLAY #ifdef ACTION_REPLAY_COMMON - ar_custom[addr+0]=(uae_u8)(value>>8); - ar_custom[addr+1]=(uae_u8)(value); + ar_custom[addr + 0]=(uae_u8)(value >> 8); + ar_custom[addr + 1]=(uae_u8)(value); #endif #endif + switch (addr) { case 0x00E: CLXDAT (); break; diff --git a/debug.cpp b/debug.cpp index d6f40cc3..5ac73ff3 100644 --- a/debug.cpp +++ b/debug.cpp @@ -162,7 +162,7 @@ static const TCHAR help[] = { _T(" fo [ ] Conditional register breakpoint.\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[x] Dump contents of all custom registers, ea = AGA colors.\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") @@ -1186,11 +1186,14 @@ static void dumpmem (uaecptr addr, uaecptr *nxmem, int lines) *nxmem = addr; } -static void dump_custom_regs (int aga) +static void dump_custom_regs(bool aga, bool ext) { - int len, i, j, end; + int len, end; uae_u8 *p1, *p2, *p3, *p4; + TCHAR extra1[256], extra2[256]; + extra1[0] = 0; + extra2[0] = 0; if (aga) { dump_aga_custom(); return; @@ -1198,7 +1201,7 @@ static void dump_custom_regs (int aga) p1 = p2 = save_custom (&len, 0, 1); p1 += 4; // skip chipset type - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { p4 = p1 + 0xa0 + i * 16; p3 = save_audio (i, &len, 0); p4[0] = p3[12]; @@ -1220,19 +1223,26 @@ static void dump_custom_regs (int aga) end++; end++; end /= 2; - for (i = 0; i < end; i++) { + for (int i = 0; i < end; i++) { uae_u16 v1, v2; int addr1, addr2; - j = end + i; + int j = end + i; addr1 = custd[i].adr & 0x1ff; addr2 = custd[j].adr & 0x1ff; v1 = (p1[addr1 + 0] << 8) | p1[addr1 + 1]; v2 = (p1[addr2 + 0] << 8) | p1[addr2 + 1]; - console_out_f (_T("%03X %s\t%04X\t%03X %s\t%04X\n"), - addr1, custd[i].name, v1, - addr2, custd[j].name, v2); + if (ext) { + struct custom_store *cs; + cs = &custom_storage[addr1 >> 1]; + _stprintf(extra1, _T("\t%04X %08X %s"), cs->value, cs->pc & ~1, (cs->pc & 1) ? _T("COP") : _T("CPU")); + cs = &custom_storage[addr2 >> 1]; + _stprintf(extra2, _T("\t%04X %08X %s"), cs->value, cs->pc & ~1, (cs->pc & 1) ? _T("COP") : _T("CPU")); + } + console_out_f (_T("%03X %s\t%04X%s\t%03X %s\t%04X%s\n"), + addr1, custd[i].name, v1, extra1, + addr2, custd[j].name, v2, extra2); } - free (p2); + xfree(p2); } static void dump_vectors (uaecptr addr) @@ -5256,7 +5266,15 @@ static bool debug_line (TCHAR *input) } break; } - case 'e': dump_custom_regs (tolower(*inptr) == 'a'); break; + case 'e': + { + bool aga = tolower(*inptr) == 'a'; + if (aga) + next_char(&inptr); + bool ext = tolower(*inptr) == 'x'; + dump_custom_regs(aga, ext); + } + break; case 'r': { if (*inptr == 'c') { @@ -5294,7 +5312,7 @@ static bool debug_line (TCHAR *input) debugmem_list_segment(0, addr); } } else if (*inptr == 'c') { - screenshot(0, 1, 1); + screenshot(-1, 1, 1); } else if (*inptr == 'p') { inptr++; debug_sprite (&inptr); diff --git a/include/custom.h b/include/custom.h index 28373ea5..2e2243b7 100644 --- a/include/custom.h +++ b/include/custom.h @@ -243,4 +243,11 @@ extern void getsyncregisters(uae_u16 *phsstrt, uae_u16 *phsstop, uae_u16 *pvsstr int is_bitplane_dma (int hpos); void custom_cpuchange(void); +struct custom_store +{ + uae_u16 value; + uae_u32 pc; +}; +extern struct custom_store custom_storage[256]; + #endif /* UAE_CUSTOM_H */ -- 2.47.3