mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-23 08:09:51 +00:00
Misc logging improvments, minor safety check
This commit is contained in:
parent
9bbb3b3c88
commit
fdfc572b69
@ -132,8 +132,7 @@ LogManager::LogManager() {
|
||||
LogManager::~LogManager() {
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) {
|
||||
#if !defined(MOBILE_DEVICE) || defined(_DEBUG)
|
||||
if (fileLog_ != NULL)
|
||||
RemoveListener(fileLog_);
|
||||
RemoveListener(fileLog_);
|
||||
RemoveListener(consoleLog_);
|
||||
#if defined(_MSC_VER) && defined(USING_WIN_UI)
|
||||
RemoveListener(debuggerLog_);
|
||||
@ -257,11 +256,15 @@ void LogManager::Shutdown() {
|
||||
}
|
||||
|
||||
void LogManager::AddListener(LogListener *listener) {
|
||||
if (!listener)
|
||||
return;
|
||||
std::lock_guard<std::mutex> lk(listeners_lock_);
|
||||
listeners_.push_back(listener);
|
||||
}
|
||||
|
||||
void LogManager::RemoveListener(LogListener *listener) {
|
||||
if (!listener)
|
||||
return;
|
||||
std::lock_guard<std::mutex> lk(listeners_lock_);
|
||||
auto iter = std::find(listeners_.begin(), listeners_.end(), listener);
|
||||
if (iter != listeners_.end())
|
||||
|
@ -59,7 +59,7 @@ u32 BlockAllocator::AllocAligned(u32 &size, u32 sizeGrain, u32 grain, bool fromT
|
||||
{
|
||||
// Sanity check
|
||||
if (size == 0 || size > rangeSize_) {
|
||||
ERROR_LOG(HLE, "Clearly bogus size: %08x - failing allocation", size);
|
||||
ERROR_LOG(SCEKERNEL, "Clearly bogus size: %08x - failing allocation", size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ u32 BlockAllocator::AllocAligned(u32 &size, u32 sizeGrain, u32 grain, bool fromT
|
||||
|
||||
//Out of memory :(
|
||||
ListBlocks();
|
||||
ERROR_LOG(HLE, "Block Allocator (%08x-%08x) failed to allocate %i (%08x) bytes of contiguous memory", rangeStart_, rangeStart_ + rangeSize_, size, size);
|
||||
ERROR_LOG(SCEKERNEL, "Block Allocator (%08x-%08x) failed to allocate %i (%08x) bytes of contiguous memory", rangeStart_, rangeStart_ + rangeSize_, size, size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag)
|
||||
{
|
||||
CheckBlocks();
|
||||
if (size > rangeSize_) {
|
||||
ERROR_LOG(HLE, "Clearly bogus size: %08x - failing allocation", size);
|
||||
ERROR_LOG(SCEKERNEL, "Clearly bogus size: %08x - failing allocation", size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag)
|
||||
u32 alignedPosition = position;
|
||||
u32 alignedSize = size;
|
||||
if (position & (grain_ - 1)) {
|
||||
DEBUG_LOG(HLE, "Position %08x does not align to grain.", position);
|
||||
DEBUG_LOG(SCEKERNEL, "Position %08x does not align to grain.", position);
|
||||
alignedPosition &= ~(grain_ - 1);
|
||||
|
||||
// Since the position was decreased, size must increase.
|
||||
@ -177,7 +177,7 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag)
|
||||
Block &b = *bp;
|
||||
if (b.taken)
|
||||
{
|
||||
ERROR_LOG(HLE, "Block allocator AllocAt failed, block taken! %08x, %i", position, size);
|
||||
ERROR_LOG(SCEKERNEL, "Block allocator AllocAt failed, block taken! %08x, %i", position, size);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
@ -185,7 +185,7 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag)
|
||||
// Make sure the block is big enough to split.
|
||||
if (b.start + b.size < alignedPosition + alignedSize)
|
||||
{
|
||||
ERROR_LOG(HLE, "Block allocator AllocAt failed, not enough contiguous space %08x, %i", position, size);
|
||||
ERROR_LOG(SCEKERNEL, "Block allocator AllocAt failed, not enough contiguous space %08x, %i", position, size);
|
||||
return -1;
|
||||
}
|
||||
//good to go
|
||||
@ -212,24 +212,24 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag)
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(HLE, "Block allocator AllocAt failed :( %08x, %i", position, size);
|
||||
ERROR_LOG(SCEKERNEL, "Block allocator AllocAt failed :( %08x, %i", position, size);
|
||||
}
|
||||
|
||||
|
||||
//Out of memory :(
|
||||
ListBlocks();
|
||||
ERROR_LOG(HLE, "Block Allocator (%08x-%08x) failed to allocate %i (%08x) bytes of contiguous memory", rangeStart_, rangeStart_ + rangeSize_, alignedSize, alignedSize);
|
||||
ERROR_LOG(SCEKERNEL, "Block Allocator (%08x-%08x) failed to allocate %i (%08x) bytes of contiguous memory", rangeStart_, rangeStart_ + rangeSize_, alignedSize, alignedSize);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void BlockAllocator::MergeFreeBlocks(Block *fromBlock)
|
||||
{
|
||||
DEBUG_LOG(HLE, "Merging Blocks");
|
||||
DEBUG_LOG(SCEKERNEL, "Merging Blocks");
|
||||
|
||||
Block *prev = fromBlock->prev;
|
||||
while (prev != NULL && prev->taken == false)
|
||||
{
|
||||
DEBUG_LOG(HLE, "Block Alloc found adjacent free blocks - merging");
|
||||
DEBUG_LOG(SCEKERNEL, "Block Alloc found adjacent free blocks - merging");
|
||||
prev->size += fromBlock->size;
|
||||
if (fromBlock->next == NULL)
|
||||
top_ = prev;
|
||||
@ -249,7 +249,7 @@ void BlockAllocator::MergeFreeBlocks(Block *fromBlock)
|
||||
Block *next = fromBlock->next;
|
||||
while (next != NULL && next->taken == false)
|
||||
{
|
||||
DEBUG_LOG(HLE, "Block Alloc found adjacent free blocks - merging");
|
||||
DEBUG_LOG(SCEKERNEL, "Block Alloc found adjacent free blocks - merging");
|
||||
fromBlock->size += next->size;
|
||||
fromBlock->next = next->next;
|
||||
delete next;
|
||||
@ -273,7 +273,7 @@ bool BlockAllocator::Free(u32 position)
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(HLE, "BlockAllocator : invalid free %08x", position);
|
||||
ERROR_LOG(SCEKERNEL, "BlockAllocator : invalid free %08x", position);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -289,7 +289,7 @@ bool BlockAllocator::FreeExact(u32 position)
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(HLE, "BlockAllocator : invalid free %08x", position);
|
||||
ERROR_LOG(SCEKERNEL, "BlockAllocator : invalid free %08x", position);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -389,13 +389,13 @@ u32 BlockAllocator::GetBlockSizeFromAddress(u32 addr) const
|
||||
|
||||
void BlockAllocator::ListBlocks() const
|
||||
{
|
||||
INFO_LOG(HLE,"-----------");
|
||||
INFO_LOG(SCEKERNEL,"-----------");
|
||||
for (const Block *bp = bottom_; bp != NULL; bp = bp->next)
|
||||
{
|
||||
const Block &b = *bp;
|
||||
INFO_LOG(HLE, "Block: %08x - %08x size %08x taken=%i tag=%s", b.start, b.start+b.size, b.size, b.taken ? 1:0, b.tag);
|
||||
INFO_LOG(SCEKERNEL, "Block: %08x - %08x size %08x taken=%i tag=%s", b.start, b.start+b.size, b.size, b.taken ? 1:0, b.tag);
|
||||
}
|
||||
INFO_LOG(HLE,"-----------");
|
||||
INFO_LOG(SCEKERNEL,"-----------");
|
||||
}
|
||||
|
||||
u32 BlockAllocator::GetLargestFreeBlockSize() const
|
||||
|
9
ext/native/base/logging.cpp
Normal file
9
ext/native/base/logging.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "base/logging.h"
|
||||
|
||||
const char *GetFn(const char *fn) {
|
||||
const char *p = strrchr(fn, '\\');
|
||||
if (p)
|
||||
return p + 1;
|
||||
else
|
||||
return fn;
|
||||
}
|
@ -74,10 +74,12 @@ void OutputDebugStringUTF8(const char *p);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
const char *GetFn(const char *fn);
|
||||
|
||||
#define XLOG_IMPL(type, ...) do {\
|
||||
char temp[512]; \
|
||||
char *p = temp; \
|
||||
int len = snprintf(p, sizeof(temp), type ": %s:%i: ", __FILE__, __LINE__); \
|
||||
int len = snprintf(p, sizeof(temp), type ": %s:%i: ", GetFn(__FILE__), __LINE__); \
|
||||
if (len < sizeof(temp)) { \
|
||||
p += len; \
|
||||
p += snprintf(p, sizeof(temp) - len - 3, type ": " __VA_ARGS__); \
|
||||
|
@ -293,6 +293,7 @@
|
||||
<ClCompile Include="base\colorutil.cpp" />
|
||||
<ClCompile Include="base\compat.cpp" />
|
||||
<ClCompile Include="base\display.cpp" />
|
||||
<ClCompile Include="base\logging.cpp" />
|
||||
<ClCompile Include="base\PCMain.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
|
@ -763,6 +763,9 @@
|
||||
<ClCompile Include="thin3d\d3d11_loader.cpp">
|
||||
<Filter>thin3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="base\logging.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="gfx">
|
||||
|
@ -1128,6 +1128,19 @@ TabHolder::TabHolder(Orientation orientation, float stripSize, LayoutParams *lay
|
||||
tabStrip_->OnChoice.Handle(this, &TabHolder::OnTabClick);
|
||||
}
|
||||
|
||||
void TabHolder::SetCurrentTab(int tab) {
|
||||
if (tab >= (int)tabs_.size()) {
|
||||
// Ignore
|
||||
return;
|
||||
}
|
||||
if (tab != currentTab_) {
|
||||
tabs_[currentTab_]->SetVisibility(V_GONE);
|
||||
currentTab_ = tab;
|
||||
tabs_[currentTab_]->SetVisibility(V_VISIBLE);
|
||||
}
|
||||
tabStrip_->SetSelection(tab);
|
||||
}
|
||||
|
||||
EventReturn TabHolder::OnTabClick(EventParams &e) {
|
||||
// We have e.b set when it was an explicit click action.
|
||||
// In that case, we make the view gone and then visible - this scrolls scrollviews to the top.
|
||||
|
@ -321,14 +321,7 @@ public:
|
||||
return tabContents;
|
||||
}
|
||||
|
||||
void SetCurrentTab(int tab) {
|
||||
if (tab != currentTab_) {
|
||||
tabs_[currentTab_]->SetVisibility(V_GONE);
|
||||
currentTab_ = tab;
|
||||
tabs_[currentTab_]->SetVisibility(V_VISIBLE);
|
||||
}
|
||||
tabStrip_->SetSelection(tab);
|
||||
}
|
||||
void SetCurrentTab(int tab);
|
||||
|
||||
int GetCurrentTab() const { return currentTab_; }
|
||||
std::string Describe() const override { return "TabHolder: " + View::Describe(); }
|
||||
|
Loading…
Reference in New Issue
Block a user