Debugger: Notate memset tags directly.

This commit is contained in:
Unknown W. Brackets 2021-02-02 23:53:16 -08:00
parent ca2f7df94f
commit 88e2b9b740
12 changed files with 25 additions and 32 deletions

View File

@ -630,7 +630,7 @@ inline void CallSyscallWithFlags(const HLEFunction *info)
if (flags & HLE_CLEAR_STACK_BYTES) {
u32 stackStart = __KernelGetCurThreadStackStart();
if (currentMIPS->r[MIPS_REG_SP] - info->stackBytesToClear >= stackStart) {
Memory::Memset(currentMIPS->r[MIPS_REG_SP] - info->stackBytesToClear, 0, info->stackBytesToClear);
Memory::Memset(currentMIPS->r[MIPS_REG_SP] - info->stackBytesToClear, 0, info->stackBytesToClear, "HLEStackClear");
}
}

View File

@ -59,8 +59,8 @@ HLEHelperThread::~HLEHelperThread() {
}
void HLEHelperThread::AllocEntry(u32 size) {
entry_ = kernelMemory.Alloc(size);
Memory::Memset(entry_, 0, size);
entry_ = kernelMemory.Alloc(size, false, "HLEHelper");
Memory::Memset(entry_, 0, size, "HLEHelperClear");
currentMIPS->InvalidateICache(entry_, size);
}

View File

@ -2310,7 +2310,7 @@ static u32 _sceAtracGetContextAddress(int atracID) {
u32 contextsize = 256;
atrac->context_ = kernelMemory.Alloc(contextsize, false, "Atrac Context");
if (atrac->context_.IsValid())
Memory::Memset(atrac->context_.ptr, 0, 256);
Memory::Memset(atrac->context_.ptr, 0, 256, "AtracContextClear");
WARN_LOG(ME, "%08x=_sceAtracGetContextAddress(%i): allocated new context", atrac->context_.ptr, atracID);
}

View File

@ -430,8 +430,8 @@ void __KernelMemoryInit()
MemBlockInfoInit();
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());
Memory::Memset(PSP_GetKernelMemoryBase(), 0, PSP_GetKernelMemoryEnd() - PSP_GetKernelMemoryBase(), "MemInit");
Memory::Memset(PSP_GetUserMemoryBase(), 0, PSP_GetUserMemoryEnd() - PSP_GetUserMemoryBase(), "MemInit");
INFO_LOG(SCEKERNEL, "Kernel and user memory pools initialized");
vplWaitTimer = CoreTiming::RegisterEvent("VplTimeout", __KernelVplTimeout);
@ -1968,8 +1968,7 @@ int __KernelFreeTls(TLSPL *tls, SceUID threadID)
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);
NotifyMemInfo(MemBlockFlags::WRITE, freedAddress, tls->ntls.blockSize, "TlsFree");
Memory::Memset(freedAddress, 0, tls->ntls.blockSize, "TlsFree");
// First, let's remove the end check for the freeing thread.
auto freeingLocked = tlsplThreadEndChecks.equal_range(threadID);
@ -2245,8 +2244,7 @@ int sceKernelGetTlsAddr(SceUID uid)
// We clear the blocks upon first allocation (and also when they are freed, both are necessary.)
if (needsClear) {
Memory::Memset(allocAddress, 0, tls->ntls.blockSize);
NotifyMemInfo(MemBlockFlags::WRITE, allocAddress, tls->ntls.blockSize, "TlsAddr");
Memory::Memset(allocAddress, 0, tls->ntls.blockSize, "TlsAddr");
}
return allocAddress;

View File

@ -856,8 +856,7 @@ void PSPModule::Cleanup() {
for (u32 i = 0; i < (u32)(nm.text_size + 3); i += 4) {
Memory::Write_U32(MIPS_MAKE_BREAK(1), nm.text_addr + i);
}
Memory::Memset(nm.text_addr + nm.text_size, -1, nm.data_size + nm.bss_size);
NotifyMemInfo(MemBlockFlags::WRITE, nm.text_addr + nm.text_size, nm.data_size + nm.bss_size, "ModuleClear");
Memory::Memset(nm.text_addr + nm.text_size, -1, nm.data_size + nm.bss_size, "ModuleClear");
// Let's also invalidate, just to make sure it's cleared out for any future data.
currentMIPS->InvalidateICache(memoryBlockAddr, memoryBlockSize);

View File

@ -432,8 +432,7 @@ public:
bool FillStack() {
// 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");
Memory::Memset(currentStack.start, 0xFF, nt.stackSize, "ThreadFillStack");
}
context.r[MIPS_REG_SP] = currentStack.start + nt.stackSize;
currentStack.end = context.r[MIPS_REG_SP];
@ -441,7 +440,7 @@ public:
context.r[MIPS_REG_SP] -= 256;
context.r[MIPS_REG_K0] = context.r[MIPS_REG_SP];
u32 k0 = context.r[MIPS_REG_K0];
Memory::Memset(k0, 0, 0x100);
Memory::Memset(k0, 0, 0x100, "ThreadK0");
Memory::Write_U32(GetUID(), k0 + 0xc0);
Memory::Write_U32(nt.initialStack, k0 + 0xc8);
Memory::Write_U32(0xffffffff, k0 + 0xf8);
@ -457,8 +456,7 @@ public:
DEBUG_LOG(SCEKERNEL, "Freeing thread stack %s", nt.name);
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");
Memory::Memset(nt.initialStack, 0, nt.stackSize, "ThreadFreeStack");
}
if (nt.attr & PSP_THREAD_ATTR_KERNEL) {
@ -483,9 +481,8 @@ public:
nt.stackSize = currentStack.end - currentStack.start;
// We still drop the threadID at the bottom and fill it, but there's no k0.
Memory::Memset(currentStack.start, 0xFF, nt.stackSize);
Memory::Memset(currentStack.start, 0xFF, nt.stackSize, "ThreadExtendStack");
Memory::Write_U32(GetUID(), nt.initialStack);
NotifyMemInfo(MemBlockFlags::WRITE, currentStack.start, nt.stackSize, "ThreadExtendStack");
return true;
}
@ -1294,7 +1291,7 @@ u32 sceKernelReferThreadStatus(u32 threadID, u32 statusPtr)
Memory::Memcpy(statusPtr, &t->nt, std::min(wantedSize, (u32)sizeof(t->nt)));
// TODO: What is this value? Basic tests show 0...
if (wantedSize > sizeof(t->nt))
Memory::Memset(statusPtr + sizeof(t->nt), 0, wantedSize - sizeof(t->nt));
Memory::Memset(statusPtr + sizeof(t->nt), 0, wantedSize - sizeof(t->nt), "ThreadStatus");
} else {
t->nt.nativeSize = THREADINFO_SIZE;
u32 sz = std::min(THREADINFO_SIZE, wantedSize);

View File

@ -1960,7 +1960,7 @@ static u32 sceMpegAtracDecode(u32 mpeg, u32 auAddr, u32 bufferAddr, int init)
// We kept track of the stream number here in sceMpegGetAtracAu().
ctx->mediaengine->setAudioStream(atracAu.esBuffer);
Memory::Memset(bufferAddr, 0, MPEG_ATRAC_ES_OUTPUT_SIZE);
Memory::Memset(bufferAddr, 0, MPEG_ATRAC_ES_OUTPUT_SIZE, "MpegAtracClear");
ctx->mediaengine->getAudioSamples(bufferAddr);
atracAu.pts = ctx->mediaengine->getAudioTimeStamp() + ctx->mpegFirstTimestamp;

View File

@ -965,7 +965,7 @@ static u32 scePsmfVerifyPsmf(u32 psmfAddr)
}
// Kurohyou 2 (at least the demo) uses an uninitialized value that happens to be zero on the PSP.
// It appears to be written by scePsmfVerifyPsmf(), so we write some bytes into the stack here.
Memory::Memset(currentMIPS->r[MIPS_REG_SP] - 0x20, 0, 0x20);
Memory::Memset(currentMIPS->r[MIPS_REG_SP] - 0x20, 0, 0x20, "PsmfStack");
DEBUG_LOG(ME, "scePsmfVerifyPsmf(%08x)", psmfAddr);
return 0;
}
@ -1656,7 +1656,7 @@ static int scePsmfPlayerGetAudioData(u32 psmfPlayer, u32 audioDataAddr)
if (psmfplayer->mediaengine->getAudioSamples(audioDataAddr) == 0) {
if (psmfplayer->totalAudioStreams > 0 && (s64)psmfplayer->psmfPlayerAvcAu.pts < (s64)psmfplayer->totalDurationTimestamp - VIDEO_FRAME_DURATION_TS) {
// Write zeros for any missing trailing frames so it syncs with the video.
Memory::Memset(audioDataAddr, 0, audioSamplesBytes);
Memory::Memset(audioDataAddr, 0, audioSamplesBytes, "PsmfAudioClear");
} else {
ret = (int)ERROR_PSMFPLAYER_NO_MORE_DATA;
}

View File

@ -459,7 +459,7 @@ void Write_Opcode_JIT(const u32 _Address, const Opcode& _Value)
Memory::WriteUnchecked_U32(_Value.encoding, _Address);
}
void Memset(const u32 _Address, const u8 _iValue, const u32 _iLength) {
void Memset(const u32 _Address, const u8 _iValue, const u32 _iLength, const std::string &tag) {
if (IsValidRange(_Address, _iLength)) {
uint8_t *ptr = GetPointerUnchecked(_Address);
memset(ptr, _iValue, _iLength);
@ -468,7 +468,7 @@ void Memset(const u32 _Address, const u8 _iValue, const u32 _iLength) {
Write_U8(_iValue, (u32)(_Address + i));
}
NotifyMemInfo(MemBlockFlags::WRITE, _Address, _iLength, "Memset");
NotifyMemInfo(MemBlockFlags::WRITE, _Address, _iLength, tag);
}
} // namespace

View File

@ -55,7 +55,7 @@ inline void Memcpy(const u32 to_address, const u32 from_address, const u32 len)
NotifyMemInfo(MemBlockFlags::WRITE, to_address, len, "Memcpy");
}
void Memset(const u32 _Address, const u8 _Data, const u32 _iLength);
void Memset(const u32 _Address, const u8 _Data, const u32 _iLength, const std::string &tag = "Memset");
template<class T>
void ReadStruct(u32 address, T *ptr)

View File

@ -1261,7 +1261,7 @@ bool PPGeImage::Load() {
}
Memory::Memcpy(texture_, textureData, dataSize);
Memory::Memset(texture_ + dataSize, 0, texSize - dataSize);
Memory::Memset(texture_ + dataSize, 0, texSize - dataSize, "PPGeTexClear");
free(textureData);
lastFrame_ = gpuStats.numFlips;

View File

@ -2728,8 +2728,6 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) {
}
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)) {
@ -2746,23 +2744,24 @@ bool GPUCommon::PerformMemoryCopy(u32 dest, u32 src, int size) {
return true;
}
NotifyMemInfo(MemBlockFlags::READ, src, size, "GPUMemcpy");
NotifyMemInfo(MemBlockFlags::WRITE, dest, size, "GPUMemcpy");
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
GPURecord::NotifyMemcpy(dest, src, size);
return false;
}
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);
Memory::Memset(dest, v, size, "GPUMemset");
if (!framebufferManager_->NotifyFramebufferCopy(dest, dest, size, true, gstate_c.skipDrawReason)) {
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
}
return true;
}
NotifyMemInfo(MemBlockFlags::WRITE, dest, size, "GPUMemset");
// Or perhaps a texture, let's invalidate.
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
GPURecord::NotifyMemset(dest, v, size);