From e9fcc51b9323de2f300bed35bd02c0046833b387 Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Sun, 26 Sep 2021 14:21:31 +0200 Subject: [PATCH] Debugger fixes for PDM. --- debugger/debugger.cpp | 25 +++++++++++++++---------- devices/memctrlbase.cpp | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/debugger/debugger.cpp b/debugger/debugger.cpp index 00b3fa9..7ee6ff4 100644 --- a/debugger/debugger.cpp +++ b/debugger/debugger.cpp @@ -23,14 +23,15 @@ along with this program. If not, see . #include #include #include +#include #include #include #include #include -#include #include "../cpu/ppc/ppcdisasm.h" #include "../cpu/ppc/ppcemu.h" #include "../cpu/ppc/ppcmmu.h" +#include "memaccess.h" #include "utils/profiler.h" #ifdef ENABLE_68K_DEBUGGER // optionally defined in CMakeLists.txt @@ -330,7 +331,7 @@ static void disasm(uint32_t count, uint32_t address) { ctx.simplified = true; for (int i = 0; i < count; i++) { - ctx.instr_code = mem_read_dbg(ctx.instr_addr, 4); + ctx.instr_code = READ_DWORD_BE_A(mmu_translate_imem(ctx.instr_addr)); cout << uppercase << hex << ctx.instr_addr; cout << " " << disassemble_single(&ctx) << endl; } @@ -541,16 +542,20 @@ void enter_debugger() { } } else { /* disas without arguments defaults to disas 1,pc */ - if (context == 2) { + try { + if (context == 2) { #ifdef ENABLE_68K_DEBUGGER - addr_str = "R24"; - addr = get_reg(addr_str); - disasm_68k(1, addr - 2); + addr_str = "R24"; + addr = get_reg(addr_str); + disasm_68k(1, addr - 2); #endif - } else { - addr_str = "PC"; - addr = get_reg(addr_str); - disasm(1, addr); + } else { + addr_str = "PC"; + addr = get_reg(addr_str); + disasm(1, addr); + } + } catch (invalid_argument& exc) { + cout << exc.what() << endl; } } } else if (cmd == "dump") { diff --git a/devices/memctrlbase.cpp b/devices/memctrlbase.cpp index dc21ca4..86820ac 100644 --- a/devices/memctrlbase.cpp +++ b/devices/memctrlbase.cpp @@ -99,7 +99,7 @@ bool MemCtrlBase::add_mem_mirror(uint32_t start_addr, uint32_t dest_addr) { entry = new AddressMapEntry; entry->start = start_addr; - entry->end = start_addr + (ref_entry->end - ref_entry->start) + 1; + entry->end = start_addr + (ref_entry->end - ref_entry->start); entry->mirror = dest_addr; entry->type = ref_entry->type | RT_MIRROR; entry->devobj = 0;