From f7740edc6db3fbc2ff54ef7e1005227398a01d94 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 2 Feb 2021 00:08:05 -0800 Subject: [PATCH] Debugger: Add more metadata for memory usage. --- CMakeLists.txt | 2 + Core/Core.vcxproj | 2 + Core/Core.vcxproj.filters | 6 + Core/Debugger/MemBlockInfo.cpp | 34 ++++++ Core/Debugger/MemBlockInfo.h | 36 ++++++ Core/ELF/ElfReader.cpp | 4 +- Core/HLE/ReplaceTables.cpp | 141 ++++++++++++------------ Core/HLE/sceAtrac.cpp | 8 +- Core/HLE/sceCcc.cpp | 26 ++--- Core/HLE/sceHeap.cpp | 2 +- Core/HLE/sceIo.cpp | 6 +- Core/HLE/sceKernelHeap.cpp | 2 +- Core/HLE/sceKernelInterrupt.cpp | 12 +- Core/HLE/sceKernelMemory.cpp | 26 +++-- Core/HLE/sceKernelThread.cpp | 7 +- Core/HLE/sceMp3.cpp | 8 +- Core/HLE/sceNet.cpp | 13 +-- Core/HW/MediaEngine.cpp | 11 +- Core/HW/SimpleAudioDec.cpp | 2 + Core/MemMap.cpp | 4 +- Core/MemMapHelpers.h | 9 +- Core/Util/BlockAllocator.cpp | 23 ++-- Core/Util/BlockAllocator.h | 5 +- GPU/Common/FramebufferManagerCommon.cpp | 12 +- GPU/GPUCommon.cpp | 11 +- GPU/Software/SoftGpu.cpp | 6 +- UWP/CoreUWP/CoreUWP.vcxproj | 2 + UWP/CoreUWP/CoreUWP.vcxproj.filters | 6 + android/jni/Android.mk | 1 + 29 files changed, 276 insertions(+), 151 deletions(-) create mode 100644 Core/Debugger/MemBlockInfo.cpp create mode 100644 Core/Debugger/MemBlockInfo.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 56f617ae1f..2f2a9cd8d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1482,6 +1482,8 @@ add_library(${CoreLibName} ${CoreLinkType} Core/Debugger/Breakpoints.cpp Core/Debugger/Breakpoints.h Core/Debugger/DebugInterface.h + Core/Debugger/MemBlockInfo.cpp + Core/Debugger/MemBlockInfo.h Core/Debugger/SymbolMap.cpp Core/Debugger/SymbolMap.h Core/Debugger/DisassemblyManager.cpp diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 065a61aff3..c0c9051d7f 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -429,6 +429,7 @@ + @@ -977,6 +978,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 51d07653fd..f66273cddd 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -977,6 +977,9 @@ MIPS\fake + + Debugger + @@ -1670,6 +1673,9 @@ MIPS\fake + + Debugger + diff --git a/Core/Debugger/MemBlockInfo.cpp b/Core/Debugger/MemBlockInfo.cpp new file mode 100644 index 0000000000..1cb51ae949 --- /dev/null +++ b/Core/Debugger/MemBlockInfo.cpp @@ -0,0 +1,34 @@ +// Copyright (c) 2021- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +#include "Core/Debugger/Breakpoints.h" +#include "Core/Debugger/MemBlockInfo.h" +#include "Core/MIPS/MIPS.h" + +void NotifyMemInfo(MemBlockFlags flags, uint32_t start, uint32_t size, const std::string &tag) { + NotifyMemInfoPC(flags, start, size, currentMIPS->pc, tag); +} + +void NotifyMemInfoPC(MemBlockFlags flags, uint32_t start, uint32_t size, uint32_t pc, const std::string &tag) { + // TODO + + if (flags & MemBlockFlags::WRITE) { + CBreakPoints::ExecMemCheck(start, true, size, pc); + } else if (flags & MemBlockFlags::READ) { + CBreakPoints::ExecMemCheck(start, false, size, pc); + } +} diff --git a/Core/Debugger/MemBlockInfo.h b/Core/Debugger/MemBlockInfo.h new file mode 100644 index 0000000000..a150b2f272 --- /dev/null +++ b/Core/Debugger/MemBlockInfo.h @@ -0,0 +1,36 @@ +// Copyright (c) 2021- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +#pragma once + +#include +#include +#include "Common/Common.h" + +enum class MemBlockFlags { + FREE = 0, + ALLOC = 1, + SUB_ALLOC = 2, + WRITE = 4, + // Not actually logged. + READ = 8, + SUB_FREE = 16, +}; +ENUM_CLASS_BITOPS(MemBlockFlags); + +void NotifyMemInfo(MemBlockFlags flags, uint32_t start, uint32_t size, const std::string &tag); +void NotifyMemInfoPC(MemBlockFlags flags, uint32_t start, uint32_t size, uint32_t pc, const std::string &tag); diff --git a/Core/ELF/ElfReader.cpp b/Core/ELF/ElfReader.cpp index eec53a3c2f..17bf1f4263 100644 --- a/Core/ELF/ElfReader.cpp +++ b/Core/ELF/ElfReader.cpp @@ -19,7 +19,7 @@ #include "Core/Reporting.h" #include "Core/MIPS/MIPSTables.h" #include "Core/ELF/ElfReader.h" -#include "Core/Debugger/Breakpoints.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/Debugger/SymbolMap.h" #include "Core/HLE/sceKernelMemory.h" #include "Core/HLE/sceKernelModule.h" @@ -478,7 +478,7 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) } memcpy(dst, src, srcSize); - CBreakPoints::ExecMemCheck(writeAddr, true, dstSize, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, writeAddr, dstSize, "ELFLoad"); DEBUG_LOG(LOADER,"Loadable Segment Copied to %08x, size %08x", writeAddr, (u32)p->p_memsz); } } diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index 86f696e994..9e30cad0dc 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -24,6 +24,7 @@ #include "Common/Log.h" #include "Core/Config.h" #include "Core/Debugger/Breakpoints.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/Debugger/SymbolMap.h" #include "Core/MemMap.h" #include "Core/MIPS/JitCommon/JitCommon.h" @@ -153,8 +154,8 @@ static int Replace_memcpy() { } RETURN(destPtr); - CBreakPoints::ExecMemCheck(srcPtr, false, bytes, currentMIPS->pc); - CBreakPoints::ExecMemCheck(destPtr, true, bytes, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, srcPtr, bytes, "ReplaceMemcpy"); + NotifyMemInfo(MemBlockFlags::WRITE, destPtr, bytes, "ReplaceMemcpy"); return 10 + bytes / 4; // approximation } @@ -195,8 +196,8 @@ static int Replace_memcpy_jak() { currentMIPS->r[MIPS_REG_A3] = destPtr + bytes; RETURN(destPtr); - CBreakPoints::ExecMemCheck(srcPtr, false, bytes, currentMIPS->pc); - CBreakPoints::ExecMemCheck(destPtr, true, bytes, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, srcPtr, bytes, "ReplaceMemcpy"); + NotifyMemInfo(MemBlockFlags::WRITE, destPtr, bytes, "ReplaceMemcpy"); return 5 + bytes * 8 + 2; // approximation. This is a slow memcpy - a byte copy loop.. } @@ -223,8 +224,8 @@ static int Replace_memcpy16() { } RETURN(destPtr); - CBreakPoints::ExecMemCheck(srcPtr, false, bytes, currentMIPS->pc); - CBreakPoints::ExecMemCheck(destPtr, true, bytes, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, srcPtr, bytes, "ReplaceMemcpy16"); + NotifyMemInfo(MemBlockFlags::WRITE, destPtr, bytes, "ReplaceMemcpy16"); return 10 + bytes / 4; // approximation } @@ -261,8 +262,8 @@ static int Replace_memcpy_swizzled() { RETURN(0); - CBreakPoints::ExecMemCheck(srcPtr, false, pitch * h, currentMIPS->pc); - CBreakPoints::ExecMemCheck(destPtr, true, pitch * h, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, srcPtr, pitch * h, "ReplaceMemcpySwizzle"); + NotifyMemInfo(MemBlockFlags::WRITE, destPtr, pitch * h, "ReplaceMemcpySwizzle"); return 10 + (pitch * h) / 4; // approximation } @@ -289,8 +290,8 @@ static int Replace_memmove() { } RETURN(destPtr); - CBreakPoints::ExecMemCheck(srcPtr, false, bytes, currentMIPS->pc); - CBreakPoints::ExecMemCheck(destPtr, true, bytes, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, srcPtr, bytes, "ReplaceMemmove"); + NotifyMemInfo(MemBlockFlags::WRITE, destPtr, bytes, "ReplaceMemmove"); return 10 + bytes / 4; // approximation } @@ -311,7 +312,7 @@ static int Replace_memset() { } RETURN(destPtr); - CBreakPoints::ExecMemCheck(destPtr, true, bytes, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, destPtr, bytes, "ReplaceMemset"); return 10 + bytes / 4; // approximation } @@ -342,7 +343,7 @@ static int Replace_memset_jak() { currentMIPS->r[MIPS_REG_A3] = -1; RETURN(destPtr); - CBreakPoints::ExecMemCheck(destPtr, true, bytes, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, destPtr, bytes, "ReplaceMemset"); return 5 + bytes * 6 + 2; // approximation (hm, inspecting the disasm this should be 5 + 6 * bytes + 2, but this is what works..) } @@ -590,9 +591,9 @@ static int Replace_dl_write_matrix() { #endif } - CBreakPoints::ExecMemCheck(PARAM(2), false, count * sizeof(float), currentMIPS->pc); - CBreakPoints::ExecMemCheck(PARAM(0) + 2 * sizeof(u32), true, sizeof(u32), currentMIPS->pc); - CBreakPoints::ExecMemCheck(dlStruct[2], true, (count + 1) * sizeof(u32), currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, PARAM(2), count * sizeof(float), "ReplaceDLWriteMatrix"); + NotifyMemInfo(MemBlockFlags::WRITE, PARAM(0) + 2 * sizeof(u32), sizeof(u32), "ReplaceDLWriteMatrix"); + NotifyMemInfo(MemBlockFlags::WRITE, dlStruct[2], (count + 1) * sizeof(u32), "ReplaceDLWriteMatrix"); dlStruct[2] += (1 + count) * 4; RETURN(dlStruct[2]); @@ -640,7 +641,7 @@ static int Hook_godseaterburst_blit_texture() { const u32 fb_address = Memory::Read_U32(fb_info); if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00044000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "godseaterburst_blit_texture"); } return 0; } @@ -654,7 +655,7 @@ static int Hook_hexyzforce_monoclome_thread() { const u32 fb_address = Memory::Read_U32(fb_info); if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "hexyzforce_monoclome_thread"); } return 0; } @@ -671,7 +672,7 @@ static int Hook_topx_create_saveicon() { const u32 fb_address = currentMIPS->r[MIPS_REG_V0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00044000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "topx_create_saveicon"); } return 0; } @@ -680,7 +681,7 @@ static int Hook_ff1_battle_effect() { const u32 fb_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "ff1_battle_effect"); } return 0; } @@ -690,7 +691,7 @@ static int Hook_dissidia_recordframe_avi() { const u32 fb_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00044000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "dissidia_recordframe_avi"); } return 0; } @@ -711,7 +712,7 @@ static int Hook_brandish_download_frame() { const u32 dest_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsRAMAddress(dest_address)) { gpu->PerformMemoryDownload(fb_address, 0x00044000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "brandish_download_frame"); } return 0; } @@ -722,7 +723,7 @@ static int Hook_growlanser_create_saveicon() { const u32 sz = fmt == GE_FORMAT_8888 ? 0x00088000 : 0x00044000; if (Memory::IsVRAMAddress(fb_address) && fmt <= 3) { gpu->PerformMemoryDownload(fb_address, sz); - CBreakPoints::ExecMemCheck(fb_address, true, sz, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, sz, "growlanser_create_saveicon"); } return 0; } @@ -733,7 +734,7 @@ static int Hook_sd_gundam_g_generation_download_frame() { const u32 sz = fmt == GE_FORMAT_8888 ? 0x00088000 : 0x00044000; if (Memory::IsVRAMAddress(fb_address) && fmt <= 3) { gpu->PerformMemoryDownload(fb_address, sz); - CBreakPoints::ExecMemCheck(fb_address, true, sz, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, sz, "sd_gundam_g_generation_download_frame"); } return 0; } @@ -742,7 +743,7 @@ static int Hook_narisokonai_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_V0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00044000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "narisokonai_download_frame"); } return 0; } @@ -751,7 +752,7 @@ static int Hook_kirameki_school_life_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A2]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "kirameki_school_life_download_frame"); } return 0; } @@ -760,7 +761,7 @@ static int Hook_orenoimouto_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A4]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "orenoimouto_download_frame"); } return 0; } @@ -769,7 +770,7 @@ static int Hook_sakurasou_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_V0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "sakurasou_download_frame"); } return 0; } @@ -778,7 +779,7 @@ static int Hook_suikoden1_and_2_download_frame_1() { const u32 fb_address = currentMIPS->r[MIPS_REG_S4]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "suikoden1_and_2_download_frame_1"); } return 0; } @@ -787,7 +788,7 @@ static int Hook_suikoden1_and_2_download_frame_2() { const u32 fb_address = currentMIPS->r[MIPS_REG_S2]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "suikoden1_and_2_download_frame_2"); } return 0; } @@ -798,7 +799,7 @@ static int Hook_rezel_cross_download_frame() { const u32 sz = fmt == GE_FORMAT_8888 ? 0x00088000 : 0x00044000; if (Memory::IsVRAMAddress(fb_address) && fmt <= 3) { gpu->PerformMemoryDownload(fb_address, sz); - CBreakPoints::ExecMemCheck(fb_address, true, sz, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, sz, "rezel_cross_download_frame"); } return 0; } @@ -807,7 +808,7 @@ static int Hook_kagaku_no_ensemble_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_V0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "kagaku_no_ensemble_download_frame"); } return 0; } @@ -816,7 +817,7 @@ static int Hook_soranokiseki_fc_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A2]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00044000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "soranokiseki_fc_download_frame"); } return 0; } @@ -837,7 +838,7 @@ static int Hook_soranokiseki_sc_download_frame() { const u32 dest_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsRAMAddress(dest_address)) { gpu->PerformMemoryDownload(fb_address, 0x00044000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "soranokiseki_sc_download_frame"); } return 0; } @@ -846,7 +847,7 @@ static int Hook_bokunonatsuyasumi4_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A3]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00044000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "bokunonatsuyasumi4_download_frame"); } return 0; } @@ -858,7 +859,7 @@ static int Hook_danganronpa2_1_download_frame() { const u32 fb_address = fb_base + fb_offset_fix; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "danganronpa2_1_download_frame"); } return 0; } @@ -870,7 +871,7 @@ static int Hook_danganronpa2_2_download_frame() { const u32 fb_address = fb_base + fb_offset_fix; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "danganronpa2_2_download_frame"); } return 0; } @@ -882,7 +883,7 @@ static int Hook_danganronpa1_1_download_frame() { const u32 fb_address = fb_base + fb_offset_fix; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "danganronpa1_1_download_frame"); } return 0; } @@ -896,7 +897,7 @@ static int Hook_danganronpa1_2_download_frame() { const u32 fb_address = fb_base + fb_offset_fix; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "danganronpa1_2_download_frame"); } return 0; } @@ -905,7 +906,7 @@ static int Hook_kankabanchoutbr_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00044000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "kankabanchoutbr_download_frame"); } return 0; } @@ -914,7 +915,7 @@ static int Hook_orenoimouto_download_frame_2() { const u32 fb_address = currentMIPS->r[MIPS_REG_A4]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "orenoimouto_download_frame_2"); } return 0; } @@ -923,7 +924,7 @@ static int Hook_rewrite_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "rewrite_download_frame"); } return 0; } @@ -932,7 +933,7 @@ static int Hook_kudwafter_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "kudwafter_download_frame"); } return 0; } @@ -941,7 +942,7 @@ static int Hook_kumonohatateni_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "kumonohatateni_download_frame"); } return 0; } @@ -950,7 +951,7 @@ static int Hook_otomenoheihou_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "otomenoheihou_download_frame"); } return 0; } @@ -959,7 +960,7 @@ static int Hook_grisaianokajitsu_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "grisaianokajitsu_download_frame"); } return 0; } @@ -968,7 +969,7 @@ static int Hook_kokoroconnect_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A3]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "kokoroconnect_download_frame"); } return 0; } @@ -977,7 +978,7 @@ static int Hook_toheart2_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00044000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "toheart2_download_frame"); } return 0; } @@ -986,7 +987,7 @@ static int Hook_toheart2_download_frame_2() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "toheart2_download_frame_2"); } return 0; } @@ -995,7 +996,7 @@ static int Hook_flowers_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "flowers_download_frame"); } return 0; } @@ -1004,7 +1005,7 @@ static int Hook_motorstorm_download_frame() { const u32 fb_address = Memory::Read_U32(currentMIPS->r[MIPS_REG_A1] + 0x18); if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "motorstorm_download_frame"); } return 0; } @@ -1013,7 +1014,7 @@ static int Hook_utawarerumono_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "utawarerumono_download_frame"); } return 0; } @@ -1022,7 +1023,7 @@ static int Hook_photokano_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "photokano_download_frame"); } return 0; } @@ -1031,7 +1032,7 @@ static int Hook_photokano_download_frame_2() { const u32 fb_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "photokano_download_frame_2"); } return 0; } @@ -1040,7 +1041,7 @@ static int Hook_gakuenheaven_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "gakuenheaven_download_frame"); } return 0; } @@ -1049,7 +1050,7 @@ static int Hook_youkosohitsujimura_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_V0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "youkosohitsujimura_download_frame"); } return 0; } @@ -1080,7 +1081,7 @@ static int Hook_sdgundamggenerationportable_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A3]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "sdgundamggenerationportable_download_frame"); } return 0; } @@ -1090,7 +1091,7 @@ static int Hook_atvoffroadfurypro_download_frame() { const u32 fb_size = (currentMIPS->r[MIPS_REG_S4] >> 3) * currentMIPS->r[MIPS_REG_S3]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, fb_size); - CBreakPoints::ExecMemCheck(fb_address, true, fb_size, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, fb_size, "atvoffroadfurypro_download_frame"); } return 0; } @@ -1100,7 +1101,7 @@ static int Hook_atvoffroadfuryblazintrails_download_frame() { const u32 fb_size = (currentMIPS->r[MIPS_REG_S3] >> 3) * currentMIPS->r[MIPS_REG_S2]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, fb_size); - CBreakPoints::ExecMemCheck(fb_address, true, fb_size, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, fb_size, "atvoffroadfuryblazintrails_download_frame"); } return 0; } @@ -1109,7 +1110,7 @@ static int Hook_littlebustersce_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "littlebustersce_download_frame"); } return 0; } @@ -1118,7 +1119,7 @@ static int Hook_shinigamitoshoujo_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_S2]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "shinigamitoshoujo_download_frame"); } return 0; } @@ -1128,7 +1129,7 @@ static int Hook_atvoffroadfuryprodemo_download_frame() { const u32 fb_size = ((currentMIPS->r[MIPS_REG_A0] + currentMIPS->r[MIPS_REG_A1]) >> 3) * currentMIPS->r[MIPS_REG_S2]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, fb_size); - CBreakPoints::ExecMemCheck(fb_address, true, fb_size, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, fb_size, "atvoffroadfuryprodemo_download_frame"); } return 0; } @@ -1137,7 +1138,7 @@ static int Hook_unendingbloodycall_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_T3]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "unendingbloodycall_download_frame"); } return 0; } @@ -1146,7 +1147,7 @@ static int Hook_omertachinmokunookitethelegacy_download_frame() { const u32 fb_address = Memory::Read_U32(currentMIPS->r[MIPS_REG_SP] + 4); if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00044000); - CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "omertachinmokunookitethelegacy_download_frame"); } return 0; } @@ -1166,7 +1167,7 @@ static int Hook_katamari_render_check() { const u32 totalBytes = width * heightBlocks * heightBlockCount; gpu->PerformMemoryDownload(fb_address, totalBytes); - CBreakPoints::ExecMemCheck(fb_address, true, totalBytes, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, totalBytes, "katamari_render_check"); } return 0; } @@ -1175,7 +1176,7 @@ static int Hook_katamari_screenshot_to_565() { u32 fb_address; if (GetMIPSStaticAddress(fb_address, 0x0040, 0x0044)) { gpu->PerformMemoryDownload(0x04000000 | fb_address, 0x00088000); - CBreakPoints::ExecMemCheck(0x04000000 | fb_address, true, 0x00088000, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, 0x04000000 | fb_address, 0x00088000, "katamari_screenshot_to_565"); } return 0; } @@ -1198,7 +1199,7 @@ static int Hook_marvelalliance1_copy_a1_before() { marvelalliance1_copy_size = currentMIPS->r[MIPS_REG_V0] - currentMIPS->r[MIPS_REG_V1]; gpu->PerformMemoryDownload(marvelalliance1_copy_src, marvelalliance1_copy_size); - CBreakPoints::ExecMemCheck(marvelalliance1_copy_src, true, marvelalliance1_copy_size, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, marvelalliance1_copy_src, marvelalliance1_copy_size, "marvelalliance1_copy_a1_before"); return 0; } @@ -1209,14 +1210,14 @@ static int Hook_marvelalliance1_copy_a2_before() { marvelalliance1_copy_size = currentMIPS->r[MIPS_REG_A1] - currentMIPS->r[MIPS_REG_A2]; gpu->PerformMemoryDownload(marvelalliance1_copy_src, marvelalliance1_copy_size); - CBreakPoints::ExecMemCheck(marvelalliance1_copy_src, true, marvelalliance1_copy_size, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, marvelalliance1_copy_src, marvelalliance1_copy_size, "marvelalliance1_copy_a2_before"); return 0; } static int Hook_marvelalliance1_copy_after() { gpu->PerformMemoryUpload(marvelalliance1_copy_dst, marvelalliance1_copy_size); - CBreakPoints::ExecMemCheck(marvelalliance1_copy_dst, false, marvelalliance1_copy_size, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, marvelalliance1_copy_dst, marvelalliance1_copy_size, "marvelalliance1_copy_after"); return 0; } @@ -1249,7 +1250,7 @@ static int Hook_motorstorm_pixel_read() { u32 fb_height = Memory::Read_U16(currentMIPS->r[MIPS_REG_A0] + 0x26); u32 fb_stride = Memory::Read_U16(currentMIPS->r[MIPS_REG_A0] + 0x28); gpu->PerformMemoryDownload(fb_address, fb_height * fb_stride); - CBreakPoints::ExecMemCheck(fb_address, true, fb_height * fb_stride, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, fb_height * fb_stride, "motorstorm_pixel_read"); return 0; } @@ -1259,7 +1260,7 @@ static int Hook_worms_copy_normalize_alpha() { u32 fb_size = currentMIPS->r[MIPS_REG_A2]; if (Memory::IsVRAMAddress(fb_address) && Memory::IsValidRange(fb_address, fb_size)) { gpu->PerformMemoryDownload(fb_address, fb_size); - CBreakPoints::ExecMemCheck(fb_address, true, fb_size, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, fb_size, "worms_copy_normalize_alpha"); } return 0; } diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index bdaeea8b98..19861fc045 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -26,7 +26,7 @@ #include "Core/MemMapHelpers.h" #include "Core/Reporting.h" #include "Core/Config.h" -#include "Core/Debugger/Breakpoints.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/HW/MediaEngine.h" #include "Core/HW/BufferQueue.h" @@ -1222,7 +1222,7 @@ u32 _AtracDecodeData(int atracID, u8 *outbuf, u32 outbufPtr, u32 *SamplesNum, u3 int avret = swr_convert(atrac->swrCtx_, &out, numSamples, inbuf, numSamples); if (outbufPtr != 0) { u32 outBytes = numSamples * atrac->outputChannels_ * sizeof(s16); - CBreakPoints::ExecMemCheck(outbufPtr, true, outBytes, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, outbufPtr, outBytes, "AtracDecode"); } if (avret < 0) { ERROR_LOG(ME, "swr_convert: Error while converting %d", avret); @@ -1244,7 +1244,7 @@ u32 _AtracDecodeData(int atracID, u8 *outbuf, u32 outbufPtr, u32 *SamplesNum, u3 u32 outBytes = numSamples * atrac->outputChannels_ * sizeof(s16); if (outbuf != nullptr) { memset(outbuf, 0, outBytes); - CBreakPoints::ExecMemCheck(outbufPtr, true, outBytes, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, outbufPtr, outBytes, "AtracDecode"); } } } @@ -2447,7 +2447,7 @@ static int sceAtracLowLevelDecode(int atracID, u32 sourceAddr, u32 sourceBytesCo int avret = swr_convert(atrac->swrCtx_, &out, numSamples, (const u8**)atrac->frame_->extended_data, numSamples); u32 outBytes = numSamples * atrac->outputChannels_ * sizeof(s16); - CBreakPoints::ExecMemCheck(samplesAddr, true, outBytes, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, samplesAddr, outBytes, "AtracLowLevelDecode"); if (avret < 0) { ERROR_LOG(ME, "swr_convert: Error while converting %d", avret); } diff --git a/Core/HLE/sceCcc.cpp b/Core/HLE/sceCcc.cpp index 51da548291..b47d805573 100644 --- a/Core/HLE/sceCcc.cpp +++ b/Core/HLE/sceCcc.cpp @@ -21,7 +21,7 @@ #include "Common/Serialize/Serializer.h" #include "Common/Serialize/SerializeFuncs.h" -#include "Core/Debugger/Breakpoints.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/MemMap.h" #include "Core/HLE/HLE.h" #include "Core/HLE/FunctionWrappers.h" @@ -118,8 +118,8 @@ static int sceCccUTF8toUTF16(u32 dstAddr, u32 dstSize, u32 srcAddr) if (dst < dstEnd) *dst++ = 0; - CBreakPoints::ExecMemCheck(srcAddr, false, utf.byteIndex(), currentMIPS->pc); - CBreakPoints::ExecMemCheck(dstAddr, true, dst.ptr - dstAddr, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, srcAddr, utf.byteIndex(), "sceCcc"); + NotifyMemInfo(MemBlockFlags::WRITE, dstAddr, dst.ptr - dstAddr, "sceCcc"); return n; } @@ -154,8 +154,8 @@ static int sceCccUTF8toSJIS(u32 dstAddr, u32 dstSize, u32 srcAddr) if (dst < dstEnd) *dst++ = 0; - CBreakPoints::ExecMemCheck(srcAddr, false, utf.byteIndex(), currentMIPS->pc); - CBreakPoints::ExecMemCheck(dstAddr, true, dst.ptr - dstAddr, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, srcAddr, utf.byteIndex(), "sceCcc"); + NotifyMemInfo(MemBlockFlags::WRITE, dstAddr, dst.ptr - dstAddr, "sceCcc"); return n; } @@ -185,8 +185,8 @@ static int sceCccUTF16toUTF8(u32 dstAddr, u32 dstSize, u32 srcAddr) if (dst < dstEnd) *dst++ = 0; - CBreakPoints::ExecMemCheck(srcAddr, false, utf.shortIndex() * sizeof(uint16_t), currentMIPS->pc); - CBreakPoints::ExecMemCheck(dstAddr, true, dst.ptr - dstAddr, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, srcAddr, utf.shortIndex() * sizeof(uint16_t), "sceCcc"); + NotifyMemInfo(MemBlockFlags::WRITE, dstAddr, dst.ptr - dstAddr, "sceCcc"); return n; } @@ -221,8 +221,8 @@ static int sceCccUTF16toSJIS(u32 dstAddr, u32 dstSize, u32 srcAddr) if (dst < dstEnd) *dst++ = 0; - CBreakPoints::ExecMemCheck(srcAddr, false, utf.shortIndex() * sizeof(uint16_t), currentMIPS->pc); - CBreakPoints::ExecMemCheck(dstAddr, true, dst.ptr - dstAddr, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, srcAddr, utf.shortIndex() * sizeof(uint16_t), "sceCcc"); + NotifyMemInfo(MemBlockFlags::WRITE, dstAddr, dst.ptr - dstAddr, "sceCcc"); return n; } @@ -257,8 +257,8 @@ static int sceCccSJIStoUTF8(u32 dstAddr, u32 dstSize, u32 srcAddr) if (dst < dstEnd) *dst++ = 0; - CBreakPoints::ExecMemCheck(srcAddr, false, sjis.byteIndex(), currentMIPS->pc); - CBreakPoints::ExecMemCheck(dstAddr, true, dst.ptr - dstAddr, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, srcAddr, sjis.byteIndex(), "sceCcc"); + NotifyMemInfo(MemBlockFlags::WRITE, dstAddr, dst.ptr - dstAddr, "sceCcc"); return n; } @@ -293,8 +293,8 @@ static int sceCccSJIStoUTF16(u32 dstAddr, u32 dstSize, u32 srcAddr) if (dst < dstEnd) *dst++ = 0; - CBreakPoints::ExecMemCheck(srcAddr, false, sjis.byteIndex(), currentMIPS->pc); - CBreakPoints::ExecMemCheck(dstAddr, true, dst.ptr - dstAddr, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, srcAddr, sjis.byteIndex(), "sceCcc"); + NotifyMemInfo(MemBlockFlags::WRITE, dstAddr, dst.ptr - dstAddr, "sceCcc"); return n; } diff --git a/Core/HLE/sceHeap.cpp b/Core/HLE/sceHeap.cpp index e1c802b149..e51f6b1d83 100644 --- a/Core/HLE/sceHeap.cpp +++ b/Core/HLE/sceHeap.cpp @@ -202,7 +202,7 @@ static int sceHeapCreateHeap(const char* name, u32 heapSize, int attr, u32 param heap->address = addr; // Some of the heap is reserved by the implementation (the first 128 bytes, and 8 after each block.) - heap->alloc.Init(heap->address + 128, heap->size - 128); + heap->alloc.Init(heap->address + 128, heap->size - 128, true); heapList[heap->address] = heap; DEBUG_LOG(HLE, "%08x=sceHeapCreateHeap(%s, %08x, %08x, %08x)", heap->address, name, heapSize, attr, paramsPtr); return heap->address; diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 9abfd60f51..401c1e1a8f 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -29,7 +29,7 @@ #include "Core/Core.h" #include "Core/Config.h" #include "Core/ConfigValues.h" -#include "Core/Debugger/Breakpoints.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/ELF/ParamSFO.h" #include "Core/MemMapHelpers.h" #include "Core/System.h" @@ -1026,7 +1026,7 @@ static bool __IoRead(int &result, int id, u32 data_addr, int size, int &us) { result = SCE_KERNEL_ERROR_ILLEGAL_ADDR; return true; } else if (Memory::IsValidAddress(data_addr)) { - CBreakPoints::ExecMemCheck(data_addr, true, size, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, data_addr, size, "IoRead"); u8 *data = (u8 *)Memory::GetPointer(data_addr); u32 validSize = Memory::ValidSize(data_addr, size); if (f->npdrm) { @@ -1162,7 +1162,7 @@ static bool __IoWrite(int &result, int id, u32 data_addr, int size, int &us) { return true; } - CBreakPoints::ExecMemCheck(data_addr, false, size, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, data_addr, size, "IoWrite"); bool useThread = __KernelIsDispatchEnabled() && ioManagerThreadEnabled && size > IO_THREAD_MIN_DATA_SIZE; if (useThread) { diff --git a/Core/HLE/sceKernelHeap.cpp b/Core/HLE/sceKernelHeap.cpp index af2cbdff1d..f584684cbb 100644 --- a/Core/HLE/sceKernelHeap.cpp +++ b/Core/HLE/sceKernelHeap.cpp @@ -60,7 +60,7 @@ static int sceKernelCreateHeap(int partitionId, int size, int flags, const char heap->name = Name ? Name : ""; // Not sure if this needs validation. heap->size = allocSize; heap->address = addr; - heap->alloc.Init(heap->address + 128, heap->size - 128); + heap->alloc.Init(heap->address + 128, heap->size - 128, true); heap->uid = uid; return hleLogSuccessInfoX(SCEKERNEL, uid); } diff --git a/Core/HLE/sceKernelInterrupt.cpp b/Core/HLE/sceKernelInterrupt.cpp index 8d8e4124db..adaabd362f 100644 --- a/Core/HLE/sceKernelInterrupt.cpp +++ b/Core/HLE/sceKernelInterrupt.cpp @@ -29,7 +29,7 @@ #include "Core/HLE/FunctionWrappers.h" #include "Core/MIPS/MIPS.h" -#include "Core/Debugger/Breakpoints.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/HLE/sceKernel.h" #include "Core/HLE/sceKernelThread.h" #include "Core/HLE/sceKernelInterrupt.h" @@ -618,6 +618,7 @@ static u32 sceKernelMemset(u32 addr, u32 fillc, u32 n) Memory::Memset(addr, c, n); } } + NotifyMemInfo(MemBlockFlags::WRITE, addr, n, "KernelMemset"); return addr; } @@ -657,8 +658,8 @@ static u32 sceKernelMemcpy(u32 dst, u32 src, u32 size) } } - CBreakPoints::ExecMemCheck(src, false, size, currentMIPS->pc); - CBreakPoints::ExecMemCheck(dst, true, size, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, src, size, "KernelMemcpy"); + NotifyMemInfo(MemBlockFlags::WRITE, dst, size, "KernelMemcpy"); return dst; } @@ -689,6 +690,8 @@ static u32 sysclib_memcpy(u32 dst, u32 src, u32 size) { if (Memory::IsValidRange(dst, size) && Memory::IsValidRange(src, size)) { memcpy(Memory::GetPointer(dst), Memory::GetPointer(src), size); } + NotifyMemInfo(MemBlockFlags::READ, src, size, "KernelMemcpy"); + NotifyMemInfo(MemBlockFlags::WRITE, dst, size, "KernelMemcpy"); return dst; } @@ -754,6 +757,7 @@ static u32 sysclib_memset(u32 destAddr, int data, int size) { if (Memory::IsValidRange(destAddr, size)) { memset(Memory::GetPointer(destAddr), data, size); } + NotifyMemInfo(MemBlockFlags::WRITE, destAddr, size, "KernelMemset"); return 0; } @@ -786,6 +790,8 @@ static u32 sysclib_memmove(u32 dst, u32 src, u32 size) { if (Memory::IsValidRange(dst, size) && Memory::IsValidRange(src, size)) { memmove(Memory::GetPointer(dst), Memory::GetPointer(src), size); } + NotifyMemInfo(MemBlockFlags::READ, src, size, "KernelMemmove"); + NotifyMemInfo(MemBlockFlags::WRITE, dst, size, "KernelMemmove"); return 0; } diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 50b0b75fdf..05e4a7d8e7 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -20,16 +20,17 @@ #include #include -#include "Common/Serialize/Serializer.h" -#include "Common/Serialize/SerializeFuncs.h" -#include "Common/Serialize/SerializeMap.h" +#include "Core/CoreTiming.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/HLE/HLE.h" #include "Core/HLE/FunctionWrappers.h" #include "Core/System.h" #include "Core/MIPS/MIPS.h" #include "Core/MemMapHelpers.h" -#include "Core/CoreTiming.h" #include "Core/Reporting.h" +#include "Common/Serialize/Serializer.h" +#include "Common/Serialize/SerializeFuncs.h" +#include "Common/Serialize/SerializeMap.h" #include "Core/HLE/sceKernel.h" #include "Core/HLE/sceKernelThread.h" @@ -426,8 +427,8 @@ void __KernelFplEndCallback(SceUID threadID, SceUID prevCallbackId); void __KernelMemoryInit() { - kernelMemory.Init(PSP_GetKernelMemoryBase(), PSP_GetKernelMemoryEnd() - PSP_GetKernelMemoryBase()); - userMemory.Init(PSP_GetUserMemoryBase(), PSP_GetUserMemoryEnd() - PSP_GetUserMemoryBase()); + kernelMemory.Init(PSP_GetKernelMemoryBase(), PSP_GetKernelMemoryEnd() - PSP_GetKernelMemoryBase(), false); + userMemory.Init(PSP_GetUserMemoryBase(), PSP_GetUserMemoryEnd() - PSP_GetUserMemoryBase(), false); Memory::Memset(PSP_GetKernelMemoryBase(), 0, PSP_GetKernelMemoryEnd() - PSP_GetKernelMemoryBase()); Memory::Memset(PSP_GetUserMemoryBase(), 0, PSP_GetUserMemoryEnd() - PSP_GetUserMemoryBase()); INFO_LOG(SCEKERNEL, "Kernel and user memory pools initialized"); @@ -510,6 +511,7 @@ static bool __KernelUnlockFplForThread(FPL *fpl, FplWaitingThread &threadInfo, u { u32 blockPtr = fpl->address + fpl->alignedSize * blockNum; Memory::Write_U32(blockPtr, threadInfo.addrPtr); + NotifyMemInfo(MemBlockFlags::SUB_ALLOC, blockPtr, fpl->alignedSize, "FplAllocate"); } else return false; @@ -722,6 +724,7 @@ int sceKernelAllocateFpl(SceUID uid, u32 blockPtrAddr, u32 timeoutPtr) if (blockNum >= 0) { u32 blockPtr = fpl->address + fpl->alignedSize * blockNum; Memory::Write_U32(blockPtr, blockPtrAddr); + NotifyMemInfo(MemBlockFlags::SUB_ALLOC, blockPtr, fpl->alignedSize, "FplAllocate"); } else { SceUID threadID = __KernelGetCurThread(); HLEKernel::RemoveWaitingThread(fpl->waitingThreads, threadID); @@ -753,6 +756,7 @@ int sceKernelAllocateFplCB(SceUID uid, u32 blockPtrAddr, u32 timeoutPtr) if (blockNum >= 0) { u32 blockPtr = fpl->address + fpl->alignedSize * blockNum; Memory::Write_U32(blockPtr, blockPtrAddr); + NotifyMemInfo(MemBlockFlags::SUB_ALLOC, blockPtr, fpl->alignedSize, "FplAllocate"); } else { SceUID threadID = __KernelGetCurThread(); HLEKernel::RemoveWaitingThread(fpl->waitingThreads, threadID); @@ -784,6 +788,7 @@ int sceKernelTryAllocateFpl(SceUID uid, u32 blockPtrAddr) if (blockNum >= 0) { u32 blockPtr = fpl->address + fpl->alignedSize * blockNum; Memory::Write_U32(blockPtr, blockPtrAddr); + NotifyMemInfo(MemBlockFlags::SUB_ALLOC, blockPtr, fpl->alignedSize, "FplAllocate"); return 0; } else { return SCE_KERNEL_ERROR_NO_MEMORY; @@ -812,6 +817,9 @@ int sceKernelFreeFpl(SceUID uid, u32 blockPtr) return SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK; } else { if (fpl->freeBlock(blockNum)) { + u32 blockPtr = fpl->address + fpl->alignedSize * blockNum; + NotifyMemInfo(MemBlockFlags::SUB_FREE, blockPtr, fpl->alignedSize, "FplFree"); + DEBUG_LOG(SCEKERNEL, "sceKernelFreeFpl(%i, %08x)", uid, blockPtr); __KernelSortFplThreads(fpl); @@ -1503,7 +1511,7 @@ SceUID sceKernelCreateVpl(const char *name, int partition, u32 attr, u32 vplSize // A vpl normally has accounting stuff in the first 32 bytes. vpl->address = memBlockPtr + 0x20; - vpl->alloc.Init(vpl->address, vpl->nv.poolSize); + vpl->alloc.Init(vpl->address, vpl->nv.poolSize, true); vpl->header = PSPPointer::Create(memBlockPtr); vpl->header->Init(memBlockPtr, vplSize); @@ -1572,7 +1580,7 @@ static bool __KernelAllocateVpl(SceUID uid, u32 size, u32 addrPtr, u32 &error, b } else { // Padding (normally used to track the allocation.) u32 allocSize = size + 8; - addr = vpl->alloc.Alloc(allocSize, true); + addr = vpl->alloc.Alloc(allocSize, true, "VplAllocate"); } if (addr != (u32) -1) { Memory::Write_U32(addr, addrPtr); @@ -1953,6 +1961,7 @@ int __KernelFreeTls(TLSPL *tls, SceUID threadID) u32 alignedSize = (tls->ntls.blockSize + tls->alignment - 1) & ~(tls->alignment - 1); u32 freedAddress = tls->address + freeBlock * alignedSize; + NotifyMemInfo(MemBlockFlags::SUB_ALLOC, freedAddress, tls->ntls.blockSize, "TlsFree"); // Whenever freeing a block, clear it (even if it's not going to wake anyone.) Memory::Memset(freedAddress, 0, tls->ntls.blockSize); @@ -2227,6 +2236,7 @@ int sceKernelGetTlsAddr(SceUID uid) u32 alignedSize = (tls->ntls.blockSize + tls->alignment - 1) & ~(tls->alignment - 1); u32 allocAddress = tls->address + allocBlock * alignedSize; + NotifyMemInfo(MemBlockFlags::SUB_ALLOC, allocAddress, tls->ntls.blockSize, "TlsAddr"); // We clear the blocks upon first allocation (and also when they are freed, both are necessary.) if (needsClear) diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index 361a81824f..f704a67f0b 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -433,6 +433,7 @@ public: // Fill the stack. if ((nt.attr & PSP_THREAD_ATTR_NO_FILLSTACK) == 0) { Memory::Memset(currentStack.start, 0xFF, nt.stackSize); + NotifyMemInfo(MemBlockFlags::WRITE, currentStack.start, nt.stackSize, "ThreadFillStack"); } context.r[MIPS_REG_SP] = currentStack.start + nt.stackSize; currentStack.end = context.r[MIPS_REG_SP]; @@ -457,6 +458,7 @@ public: if ((nt.attr & PSP_THREAD_ATTR_CLEAR_STACK) != 0 && nt.initialStack != 0) { Memory::Memset(nt.initialStack, 0, nt.stackSize); + NotifyMemInfo(MemBlockFlags::WRITE, currentStack.start, nt.stackSize, "ThreadFreeStack"); } if (nt.attr & PSP_THREAD_ATTR_KERNEL) { @@ -483,6 +485,7 @@ public: // We still drop the threadID at the bottom and fill it, but there's no k0. Memory::Memset(currentStack.start, 0xFF, nt.stackSize); Memory::Write_U32(GetUID(), nt.initialStack); + NotifyMemInfo(MemBlockFlags::WRITE, currentStack.start, nt.stackSize, "ThreadExtendStack"); return true; } @@ -2043,8 +2046,10 @@ int __KernelStartThread(SceUID threadToStartID, int argSize, u32 argBlockPtr, bo } // Now copy argument to stack. - if (!forceArgs && Memory::IsValidAddress(argBlockPtr)) + if (!forceArgs && Memory::IsValidAddress(argBlockPtr)) { Memory::Memcpy(sp, argBlockPtr, argSize); + NotifyMemInfo(MemBlockFlags::WRITE, argBlockPtr, argSize, "ThreadStartArgs"); + } // On the PSP, there's an extra 64 bytes of stack eaten after the args. // This could be stack overflow safety, or just stack eaten by the kernel entry func. diff --git a/Core/HLE/sceMp3.cpp b/Core/HLE/sceMp3.cpp index 9b1056e943..de9c3fd8ae 100644 --- a/Core/HLE/sceMp3.cpp +++ b/Core/HLE/sceMp3.cpp @@ -18,17 +18,18 @@ #include #include -#include "Common/Serialize/SerializeFuncs.h" -#include "Common/Serialize/SerializeMap.h" #include "Core/Config.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/HLE/HLE.h" #include "Core/HLE/FunctionWrappers.h" #include "Core/HLE/sceKernelMemory.h" #include "Core/HLE/sceMp3.h" #include "Core/HW/MediaEngine.h" +#include "Core/HW/SimpleAudioDec.h" #include "Core/MemMap.h" #include "Core/Reporting.h" -#include "Core/HW/SimpleAudioDec.h" +#include "Common/Serialize/SerializeFuncs.h" +#include "Common/Serialize/SerializeMap.h" static const u32 ERROR_MP3_INVALID_HANDLE = 0x80671001; static const u32 ERROR_MP3_UNRESERVED_HANDLE = 0x80671102; @@ -698,6 +699,7 @@ static u32 sceMp3LowLevelDecode(u32 mp3, u32 sourceAddr, u32 sourceBytesConsumed int outpcmbytes = 0; ctx->decoder->Decode((void*)inbuff, 4096, outbuff, &outpcmbytes); + NotifyMemInfo(MemBlockFlags::WRITE, samplesAddr, outpcmbytes, "Mp3LowLevelDecode"); Memory::Write_U32(ctx->decoder->GetSourcePos(), sourceBytesConsumedAddr); Memory::Write_U32(outpcmbytes, sampleBytesAddr); diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index d95c055eac..94b7a67fcf 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -678,15 +678,14 @@ static u32 sceWlanGetEtherAddr(u32 addrAddr) { Memory::Memset(addrAddr, PPSSPP_ID, 6); // Making sure the 1st 2-bits on the 1st byte of OUI are zero to prevent issue with some games (ie. Gran Turismo) addr[0] &= 0xfc; - } - else - // Read MAC Address from config - if (!ParseMacAddress(g_Config.sMACAddress.c_str(), addr)) { - ERROR_LOG(SCENET, "Error parsing mac address %s", g_Config.sMACAddress.c_str()); - Memory::Memset(addrAddr, 0, 6); } else { - CBreakPoints::ExecMemCheck(addrAddr, true, 6, currentMIPS->pc); + // Read MAC Address from config + if (!ParseMacAddress(g_Config.sMACAddress.c_str(), addr)) { + ERROR_LOG(SCENET, "Error parsing mac address %s", g_Config.sMACAddress.c_str()); + Memory::Memset(addrAddr, 0, 6); + } } + NotifyMemInfo(MemBlockFlags::WRITE, addrAddr, 6, "WlanEtherAddr"); return hleLogSuccessI(SCENET, hleDelayResult(0, "get ether mac", 200)); } diff --git a/Core/HW/MediaEngine.cpp b/Core/HW/MediaEngine.cpp index d7dca48150..58bdf6cec8 100644 --- a/Core/HW/MediaEngine.cpp +++ b/Core/HW/MediaEngine.cpp @@ -17,7 +17,7 @@ #include "Common/Serialize/SerializeFuncs.h" #include "Core/Config.h" -#include "Core/Debugger/Breakpoints.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/HW/MediaEngine.h" #include "Core/MemMap.h" #include "Core/MIPS/MIPS.h" @@ -816,7 +816,7 @@ int MediaEngine::writeVideoImage(u32 bufferPtr, int frameWidth, int videoPixelMo delete [] imgbuf; } - CBreakPoints::ExecMemCheck(bufferPtr, true, videoImageSize, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, bufferPtr, videoImageSize, "VideoDecode"); return videoImageSize; #endif // USE_FFMPEG @@ -871,7 +871,6 @@ int MediaEngine::writeVideoImageWithRange(u32 bufferPtr, int frameWidth, int vid writeVideoLineRGBA(imgbuf, data, width); data += m_desWidth * sizeof(u32); imgbuf += videoLineSize; - CBreakPoints::ExecMemCheck(bufferPtr + y * frameWidth * sizeof(u32), true, width * sizeof(u32), currentMIPS->pc); } break; @@ -881,7 +880,6 @@ int MediaEngine::writeVideoImageWithRange(u32 bufferPtr, int frameWidth, int vid writeVideoLineABGR5650(imgbuf, data, width); data += m_desWidth * sizeof(u16); imgbuf += videoLineSize; - CBreakPoints::ExecMemCheck(bufferPtr + y * frameWidth * sizeof(u16), true, width * sizeof(u16), currentMIPS->pc); } break; @@ -891,7 +889,6 @@ int MediaEngine::writeVideoImageWithRange(u32 bufferPtr, int frameWidth, int vid writeVideoLineABGR5551(imgbuf, data, width); data += m_desWidth * sizeof(u16); imgbuf += videoLineSize; - CBreakPoints::ExecMemCheck(bufferPtr + y * frameWidth * sizeof(u16), true, width * sizeof(u16), currentMIPS->pc); } break; @@ -901,7 +898,6 @@ int MediaEngine::writeVideoImageWithRange(u32 bufferPtr, int frameWidth, int vid writeVideoLineABGR4444(imgbuf, data, width); data += m_desWidth * sizeof(u16); imgbuf += videoLineSize; - CBreakPoints::ExecMemCheck(bufferPtr + y * frameWidth * sizeof(u16), true, width * sizeof(u16), currentMIPS->pc); } break; @@ -921,6 +917,7 @@ int MediaEngine::writeVideoImageWithRange(u32 bufferPtr, int frameWidth, int vid DoSwizzleTex16((const u32 *)imgbuf, buffer, bxc, byc, videoLineSize); delete [] imgbuf; } + NotifyMemInfo(MemBlockFlags::WRITE, bufferPtr, videoImageSize, "VideoDecodeRange"); return videoImageSize; #endif // USE_FFMPEG @@ -995,7 +992,7 @@ int MediaEngine::getAudioSamples(u32 bufferPtr) { ERROR_LOG(ME, "Audio (%s) decode failed during video playback", GetCodecName(m_audioType)); } - CBreakPoints::ExecMemCheck(bufferPtr, true, outbytes, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, bufferPtr, outbytes, "VideoDecodeAudio"); } return 0x2000; diff --git a/Core/HW/SimpleAudioDec.cpp b/Core/HW/SimpleAudioDec.cpp index 2e9ac873d4..8475e541a8 100644 --- a/Core/HW/SimpleAudioDec.cpp +++ b/Core/HW/SimpleAudioDec.cpp @@ -19,6 +19,7 @@ #include "Common/Serialize/SerializeFuncs.h" #include "Core/Config.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/HLE/FunctionWrappers.h" #include "Core/HW/SimpleAudioDec.h" #include "Core/HW/MediaEngine.h" @@ -375,6 +376,7 @@ u32 AuCtx::AuDecode(u32 pcmAddr) { memset(outbuf + outpcmbufsize, 0, PCMBufSize - outpcmbufsize); } + NotifyMemInfo(MemBlockFlags::WRITE, pcmAddr, outpcmbufsize, "AuDecode"); if (pcmAddr) Memory::Write_U32(PCMBuf, pcmAddr); return outpcmbufsize; diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index d027fdd191..a751a94bfc 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -38,7 +38,7 @@ #include "Core/Core.h" #include "Core/Debugger/SymbolMap.h" -#include "Core/Debugger/Breakpoints.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/Config.h" #include "Core/ConfigValues.h" #include "Core/HLE/ReplaceTables.h" @@ -468,7 +468,7 @@ void Memset(const u32 _Address, const u8 _iValue, const u32 _iLength) { Write_U8(_iValue, (u32)(_Address + i)); } - CBreakPoints::ExecMemCheck(_Address, true, _iLength, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, _Address, _iLength, "Memset"); } } // namespace diff --git a/Core/MemMapHelpers.h b/Core/MemMapHelpers.h index 9431db5c0d..f5bda4a6f9 100644 --- a/Core/MemMapHelpers.h +++ b/Core/MemMapHelpers.h @@ -18,7 +18,7 @@ #pragma once #include "Common/CommonTypes.h" -#include "Core/Debugger/Breakpoints.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/MemMap.h" #include "Core/MIPS/MIPS.h" @@ -33,7 +33,7 @@ inline void Memcpy(const u32 to_address, const void *from_data, const u32 len) u8 *to = GetPointer(to_address); if (to) { memcpy(to, from_data, len); - CBreakPoints::ExecMemCheck(to_address, true, len, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, to_address, len, "Memcpy"); } // if not, GetPointer will log. } @@ -43,7 +43,7 @@ inline void Memcpy(void *to_data, const u32 from_address, const u32 len) const u8 *from = GetPointer(from_address); if (from) { memcpy(to_data, from, len); - CBreakPoints::ExecMemCheck(from_address, false, len, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, from_address, len, "Memcpy"); } // if not, GetPointer will log. } @@ -51,7 +51,8 @@ inline void Memcpy(void *to_data, const u32 from_address, const u32 len) inline void Memcpy(const u32 to_address, const u32 from_address, const u32 len) { Memcpy(GetPointer(to_address), from_address, len); - CBreakPoints::ExecMemCheck(to_address, true, len, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, from_address, len, "Memcpy"); + NotifyMemInfo(MemBlockFlags::WRITE, to_address, len, "Memcpy"); } void Memset(const u32 _Address, const u8 _Data, const u32 _iLength); diff --git a/Core/Util/BlockAllocator.cpp b/Core/Util/BlockAllocator.cpp index 7dfa4637ba..76ac5b03d1 100644 --- a/Core/Util/BlockAllocator.cpp +++ b/Core/Util/BlockAllocator.cpp @@ -21,6 +21,7 @@ #include "Common/Serialize/Serializer.h" #include "Common/Serialize/SerializeFuncs.h" #include "Common/StringUtils.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/Util/BlockAllocator.h" #include "Core/Reporting.h" @@ -35,14 +36,14 @@ BlockAllocator::~BlockAllocator() Shutdown(); } -void BlockAllocator::Init(u32 rangeStart, u32 rangeSize) -{ +void BlockAllocator::Init(u32 rangeStart, u32 rangeSize, bool suballoc) { Shutdown(); rangeStart_ = rangeStart; rangeSize_ = rangeSize; //Initial block, covering everything top_ = new Block(rangeStart_, rangeSize_, false, NULL, NULL); bottom_ = top_; + suballoc_ = suballoc; } void BlockAllocator::Shutdown() @@ -90,7 +91,7 @@ u32 BlockAllocator::AllocAligned(u32 &size, u32 sizeGrain, u32 grain, bool fromT if (offset >= grain_) InsertFreeBefore(&b, offset); b.taken = true; - b.SetTag(tag); + b.SetAllocated(tag, suballoc_); return b.start; } else @@ -99,7 +100,7 @@ u32 BlockAllocator::AllocAligned(u32 &size, u32 sizeGrain, u32 grain, bool fromT if (offset >= grain_) InsertFreeBefore(&b, offset); b.taken = true; - b.SetTag(tag); + b.SetAllocated(tag, suballoc_); return b.start; } } @@ -120,7 +121,7 @@ u32 BlockAllocator::AllocAligned(u32 &size, u32 sizeGrain, u32 grain, bool fromT if (offset >= grain_) InsertFreeAfter(&b, offset); b.taken = true; - b.SetTag(tag); + b.SetAllocated(tag, suballoc_); return b.start; } else @@ -129,7 +130,7 @@ u32 BlockAllocator::AllocAligned(u32 &size, u32 sizeGrain, u32 grain, bool fromT if (offset >= grain_) InsertFreeAfter(&b, offset); b.taken = true; - b.SetTag(tag); + b.SetAllocated(tag, suballoc_); return b.start; } } @@ -195,7 +196,7 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag) if (b.size != alignedSize) InsertFreeAfter(&b, b.size - alignedSize); b.taken = true; - b.SetTag(tag); + b.SetAllocated(tag, suballoc_); CheckBlocks(); return position; } @@ -205,7 +206,7 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag) if (b.size > alignedSize) InsertFreeAfter(&b, b.size - alignedSize); b.taken = true; - b.SetTag(tag); + b.SetAllocated(tag, suballoc_); return position; } @@ -268,6 +269,7 @@ bool BlockAllocator::Free(u32 position) Block *b = GetBlockFromAddress(position); if (b && b->taken) { + NotifyMemInfo(suballoc_ ? MemBlockFlags::SUB_FREE : MemBlockFlags::FREE, b->start, b->size, ""); b->taken = false; MergeFreeBlocks(b); return true; @@ -284,6 +286,7 @@ bool BlockAllocator::FreeExact(u32 position) Block *b = GetBlockFromAddress(position); if (b && b->taken && b->start == position) { + NotifyMemInfo(suballoc_ ? MemBlockFlags::SUB_FREE : MemBlockFlags::FREE, b->start, b->size, ""); b->taken = false; MergeFreeBlocks(b); return true; @@ -485,8 +488,8 @@ BlockAllocator::Block::Block(u32 _start, u32 _size, bool _taken, Block *_prev, B truncate_cpy(tag, "(untitled)"); } -void BlockAllocator::Block::SetTag(const char *_tag) -{ +void BlockAllocator::Block::SetAllocated(const char *_tag, bool suballoc) { + NotifyMemInfo(suballoc ? MemBlockFlags::SUB_ALLOC : MemBlockFlags::ALLOC, start, size, _tag); if (_tag) truncate_cpy(tag, _tag); else diff --git a/Core/Util/BlockAllocator.h b/Core/Util/BlockAllocator.h index 32bde54aac..91e9642462 100644 --- a/Core/Util/BlockAllocator.h +++ b/Core/Util/BlockAllocator.h @@ -27,7 +27,7 @@ public: BlockAllocator(int grain = 16); // 16 byte granularity by default. ~BlockAllocator(); - void Init(u32 _rangeStart, u32 _rangeSize); + void Init(u32 _rangeStart, u32 _rangeSize, bool suballoc); void Shutdown(); void ListBlocks() const; @@ -62,7 +62,7 @@ private: struct Block { Block(u32 _start, u32 _size, bool _taken, Block *_prev, Block *_next); - void SetTag(const char *_tag); + void SetAllocated(const char *_tag, bool suballoc); void DoState(PointerWrap &p); u32 start; u32 size; @@ -78,6 +78,7 @@ private: u32 rangeSize_; u32 grain_; + bool suballoc_; void MergeFreeBlocks(Block *fromBlock); Block *GetBlockFromAddress(u32 addr); diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index f30a05bee5..1da7f6acbd 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -28,7 +28,7 @@ #include "Core/ConfigValues.h" #include "Core/Core.h" #include "Core/CoreParameter.h" -#include "Core/Debugger/Breakpoints.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/Host.h" #include "Core/MIPS/MIPS.h" #include "Core/Reporting.h" @@ -1690,10 +1690,14 @@ void FramebufferManagerCommon::ApplyClearToMemory(int x1, int y1, int x2, int y2 const int stride = gstate.FrameBufStride(); const int width = x2 - x1; + const int byteStride = stride * bpp; + const int byteWidth = width * bpp; + for (int y = y1; y < y2; ++y) { + NotifyMemInfo(MemBlockFlags::WRITE, gstate.getFrameBufAddress() + x1 * bpp + y * byteStride, byteWidth, "FramebufferClear"); + } + // Can use memset for simple cases. Often alpha is different and gums up the works. if (singleByteClear) { - const int byteStride = stride * bpp; - const int byteWidth = width * bpp; addr += x1 * bpp; for (int y = y1; y < y2; ++y) { memset(addr + y * byteStride, clearBits, byteWidth); @@ -2166,7 +2170,7 @@ void FramebufferManagerCommon::PackFramebufferSync_(VirtualFramebuffer *vfb, int if (destPtr) { draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, x, y, w, h, destFormat, destPtr, vfb->fb_stride, "PackFramebufferSync_"); - CBreakPoints::ExecMemCheck(fb_address + dstByteOffset, true, dstSize, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address + dstByteOffset, dstSize, "FramebufferPack"); } else { ERROR_LOG(G3D, "PackFramebufferSync_: Tried to readback to bad address %08x (stride = %d)", fb_address + dstByteOffset, vfb->fb_stride); } diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 5cbc056a5e..07139f0c04 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -17,6 +17,7 @@ #include "GPU/GPUState.h" #include "Core/Config.h" #include "Core/CoreTiming.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/MemMap.h" #include "Core/Host.h" #include "Core/Reporting.h" @@ -25,7 +26,6 @@ #include "Core/HLE/sceKernelInterrupt.h" #include "Core/HLE/sceKernelThread.h" #include "Core/HLE/sceGe.h" -#include "Core/Debugger/Breakpoints.h" #include "Core/MemMapHelpers.h" #include "Core/Util/PPGeDraw.h" #include "GPU/Common/DrawEngineCommon.h" @@ -2720,14 +2720,17 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) { framebufferManager_->NotifyBlockTransferAfter(dstBasePtr, dstStride, dstX, dstY, srcBasePtr, srcStride, srcX, srcY, width, height, bpp, skipDrawReason); } - CBreakPoints::ExecMemCheck(srcBasePtr + (srcY * srcStride + srcX) * bpp, false, height * srcStride * bpp, currentMIPS->pc); - CBreakPoints::ExecMemCheck(dstBasePtr + (dstY * dstStride + dstX) * bpp, true, height * dstStride * bpp, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, srcBasePtr + (srcY * srcStride + srcX) * bpp, height * srcStride * bpp, "GPUBlockTransfer"); + NotifyMemInfo(MemBlockFlags::WRITE, dstBasePtr + (dstY * dstStride + dstX) * bpp, height * dstStride * bpp, "GPUBlockTransfer"); // TODO: Correct timing appears to be 1.9, but erring a bit low since some of our other timing is inaccurate. cyclesExecuted += ((height * width * bpp) * 16) / 10; } bool GPUCommon::PerformMemoryCopy(u32 dest, u32 src, int size) { + NotifyMemInfo(MemBlockFlags::READ, src, size, "GPUMemcpy"); + NotifyMemInfo(MemBlockFlags::WRITE, dest, size, "GPUMemcpy"); + // Track stray copies of a framebuffer in RAM. MotoGP does this. if (framebufferManager_->MayIntersectFramebuffer(src) || framebufferManager_->MayIntersectFramebuffer(dest)) { if (!framebufferManager_->NotifyFramebufferCopy(src, dest, size, false, gstate_c.skipDrawReason)) { @@ -2749,6 +2752,8 @@ bool GPUCommon::PerformMemoryCopy(u32 dest, u32 src, int size) { } bool GPUCommon::PerformMemorySet(u32 dest, u8 v, int size) { + NotifyMemInfo(MemBlockFlags::WRITE, dest, size, "GPUMemset"); + // This may indicate a memset, usually to 0, of a framebuffer. if (framebufferManager_->MayIntersectFramebuffer(dest)) { Memory::Memset(dest, v, size); diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index bff4f56be6..a04369a723 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -26,7 +26,7 @@ #include "Core/Config.h" #include "Core/ConfigValues.h" #include "Core/Core.h" -#include "Core/Debugger/Breakpoints.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/MemMap.h" #include "Core/HLE/sceKernelInterrupt.h" #include "Core/HLE/sceGe.h" @@ -653,8 +653,8 @@ void SoftGPU::ExecuteOp(u32 op, u32 diff) { memcpy(dst, src, width * bpp); } - CBreakPoints::ExecMemCheck(srcBasePtr + (srcY * srcStride + srcX) * bpp, false, height * srcStride * bpp, currentMIPS->pc); - CBreakPoints::ExecMemCheck(dstBasePtr + (srcY * dstStride + srcX) * bpp, true, height * dstStride * bpp, currentMIPS->pc); + NotifyMemInfo(MemBlockFlags::READ, srcBasePtr + (srcY * srcStride + srcX) * bpp, height * srcStride * bpp, "GPUBlockTransfer"); + NotifyMemInfo(MemBlockFlags::WRITE, dstBasePtr + (dstY * dstStride + dstX) * bpp, height * dstStride * bpp, "GPUBlockTransfer"); // TODO: Correct timing appears to be 1.9, but erring a bit low since some of our other timing is inaccurate. cyclesExecuted += ((height * width * bpp) * 16) / 10; diff --git a/UWP/CoreUWP/CoreUWP.vcxproj b/UWP/CoreUWP/CoreUWP.vcxproj index 8b40a36f2e..8f7b510303 100644 --- a/UWP/CoreUWP/CoreUWP.vcxproj +++ b/UWP/CoreUWP/CoreUWP.vcxproj @@ -389,6 +389,7 @@ + @@ -621,6 +622,7 @@ + diff --git a/UWP/CoreUWP/CoreUWP.vcxproj.filters b/UWP/CoreUWP/CoreUWP.vcxproj.filters index c688cd49f5..f324ec0208 100644 --- a/UWP/CoreUWP/CoreUWP.vcxproj.filters +++ b/UWP/CoreUWP/CoreUWP.vcxproj.filters @@ -563,6 +563,9 @@ Debugger + + Debugger + Debugger @@ -1372,6 +1375,9 @@ Debugger + + Debugger + Debugger diff --git a/android/jni/Android.mk b/android/jni/Android.mk index e3e9ba19ff..c012adab9b 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -403,6 +403,7 @@ EXEC_AND_LIB_FILES := \ $(SRC)/Core/WebServer.cpp \ $(SRC)/Core/Debugger/Breakpoints.cpp \ $(SRC)/Core/Debugger/DisassemblyManager.cpp \ + $(SRC)/Core/Debugger/MemBlockInfo.cpp \ $(SRC)/Core/Debugger/SymbolMap.cpp \ $(SRC)/Core/Debugger/WebSocket.cpp \ $(SRC)/Core/Debugger/WebSocket/BreakpointSubscriber.cpp \