Debugger: Add more metadata for memory usage.

This commit is contained in:
Unknown W. Brackets committed 2021-02-15 15:01:21 -08:00
1 parent 8e6a438809
commit f7740edc6d
29 files changed
+276 -151

No files matched your search

+13 -10
View File
@@ -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