Debugging: Add minimalist PPC profiler

This commit is contained in:
Exzap 2023-06-25 08:38:25 +02:00
parent 45072fccb2
commit 9499870cc9
7 changed files with 281 additions and 43 deletions

View file

@ -83,6 +83,20 @@ RPLStoredSymbol* rplSymbolStorage_getByAddress(MPTR address)
return rplSymbolStorage.map_symbolByAddress[address];
}
RPLStoredSymbol* rplSymbolStorage_getByClosestAddress(MPTR address)
{
// highly inefficient but doesn't matter for now
std::unique_lock<std::mutex> lck(rplSymbolStorage.m_symbolStorageMutex);
for(uint32 i=0; i<4096; i++)
{
RPLStoredSymbol* symbol = rplSymbolStorage.map_symbolByAddress[address];
if(symbol)
return symbol;
address -= 4;
}
return nullptr;
}
void rplSymbolStorage_remove(RPLStoredSymbol* storedSymbol)
{
std::unique_lock<std::mutex> lck(rplSymbolStorage.m_symbolStorageMutex);

View file

@ -12,6 +12,7 @@ RPLStoredSymbol* rplSymbolStorage_store(const char* libName, const char* symbolN
void rplSymbolStorage_remove(RPLStoredSymbol* storedSymbol);
void rplSymbolStorage_removeRange(MPTR address, sint32 length);
RPLStoredSymbol* rplSymbolStorage_getByAddress(MPTR address);
RPLStoredSymbol* rplSymbolStorage_getByClosestAddress(MPTR address);
void rplSymbolStorage_createJumpProxySymbol(MPTR jumpAddress, MPTR destAddress);
std::unordered_map<uint32, RPLStoredSymbol*>& rplSymbolStorage_lockSymbolMap();

View file

@ -812,17 +812,21 @@ namespace coreinit
return suspendCounter > 0;
}
bool OSIsThreadRunningNoLock(OSThread_t* thread)
{
cemu_assert_debug(__OSHasSchedulerLock());
return thread->state == OSThread_t::THREAD_STATE::STATE_RUNNING;
}
bool OSIsThreadRunning(OSThread_t* thread)
{
bool isRunning = false;
__OSLockScheduler();
if (thread->state == OSThread_t::THREAD_STATE::STATE_RUNNING)
isRunning = true;
isRunning = OSIsThreadRunningNoLock(thread);
__OSUnlockScheduler();
return isRunning;
}
void OSCancelThread(OSThread_t* thread)
{
__OSLockScheduler();

View file

@ -538,6 +538,7 @@ namespace coreinit
bool OSIsThreadTerminated(OSThread_t* thread);
bool OSIsThreadSuspended(OSThread_t* thread);
bool OSIsThreadRunningNoLock(OSThread_t* thread);
bool OSIsThreadRunning(OSThread_t* thread);
// OSThreadQueue
@ -603,6 +604,8 @@ namespace coreinit
void __OSAddReadyThreadToRunQueue(OSThread_t* thread);
bool __OSCoreShouldSwitchToThread(OSThread_t* currentThread, OSThread_t* newThread);
void __OSQueueThreadDeallocation(OSThread_t* thread);
bool __OSIsThreadActive(OSThread_t* thread);
}
#pragma pack()