mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-22 09:09:18 +01:00
debugger: Add symbol support to PPC stack traces
Also moved the declaration to precompiled.h instead of redefining it wherever it is used
This commit is contained in:
parent
252429933f
commit
47f1dcf996
@ -501,8 +501,6 @@ void debugger_createPPCStateSnapshot(PPCInterpreter_t* hCPU)
|
|||||||
debuggerState.debugSession.ppcSnapshot.cr[i] = hCPU->cr[i];
|
debuggerState.debugSession.ppcSnapshot.cr[i] = hCPU->cr[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugLogStackTrace(OSThread_t* thread, MPTR sp);
|
|
||||||
|
|
||||||
void debugger_enterTW(PPCInterpreter_t* hCPU)
|
void debugger_enterTW(PPCInterpreter_t* hCPU)
|
||||||
{
|
{
|
||||||
// handle logging points
|
// handle logging points
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "Cafe/OS/common/OSCommon.h"
|
#include "Cafe/OS/common/OSCommon.h"
|
||||||
#include "Common/SysAllocator.h"
|
#include "Common/SysAllocator.h"
|
||||||
#include "Cafe/OS/RPL/rpl.h"
|
#include "Cafe/OS/RPL/rpl_symbol_storage.h"
|
||||||
|
|
||||||
#include "Cafe/OS/libs/coreinit/coreinit_Misc.h"
|
#include "Cafe/OS/libs/coreinit/coreinit_Misc.h"
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ sint32 ScoreStackTrace(OSThread_t* thread, MPTR sp)
|
|||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugLogStackTrace(OSThread_t* thread, MPTR sp)
|
void DebugLogStackTrace(OSThread_t* thread, MPTR sp, bool printSymbols)
|
||||||
{
|
{
|
||||||
// sp might not point to a valid stackframe
|
// sp might not point to a valid stackframe
|
||||||
// scan stack and evaluate which sp is most likely the beginning of the stackframe
|
// scan stack and evaluate which sp is most likely the beginning of the stackframe
|
||||||
@ -107,7 +107,15 @@ void DebugLogStackTrace(OSThread_t* thread, MPTR sp)
|
|||||||
|
|
||||||
uint32 returnAddress = 0;
|
uint32 returnAddress = 0;
|
||||||
returnAddress = memory_readU32(nextStackPtr + 4);
|
returnAddress = memory_readU32(nextStackPtr + 4);
|
||||||
cemuLog_log(LogType::Force, fmt::format("SP {0:08x} ReturnAddr {1:08x}", nextStackPtr, returnAddress));
|
|
||||||
|
RPLStoredSymbol* symbol = nullptr;
|
||||||
|
if(printSymbols)
|
||||||
|
symbol = rplSymbolStorage_getByClosestAddress(returnAddress);
|
||||||
|
|
||||||
|
if(symbol)
|
||||||
|
cemuLog_log(LogType::Force, fmt::format("SP {:08x} ReturnAddr {:08x} ({}.{}+0x{:x})", nextStackPtr, returnAddress, (const char*)symbol->libName, (const char*)symbol->symbolName, returnAddress - symbol->address));
|
||||||
|
else
|
||||||
|
cemuLog_log(LogType::Force, fmt::format("SP {:08x} ReturnAddr {:08x}", nextStackPtr, returnAddress));
|
||||||
|
|
||||||
currentStackPtr = nextStackPtr;
|
currentStackPtr = nextStackPtr;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
#include "Cafe/HW/Espresso/PPCCallback.h"
|
#include "Cafe/HW/Espresso/PPCCallback.h"
|
||||||
#include "Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.h"
|
#include "Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.h"
|
||||||
|
|
||||||
void DebugLogStackTrace(OSThread_t* thread, MPTR sp);
|
|
||||||
|
|
||||||
#define EXP_HEAP_GET_FROM_FREE_BLOCKCHAIN(__blockchain__) (MEMExpHeapHead2*)((uintptr_t)__blockchain__ - offsetof(MEMExpHeapHead2, expHeapHead) - offsetof(MEMExpHeapHead40_t, chainFreeBlocks))
|
#define EXP_HEAP_GET_FROM_FREE_BLOCKCHAIN(__blockchain__) (MEMExpHeapHead2*)((uintptr_t)__blockchain__ - offsetof(MEMExpHeapHead2, expHeapHead) - offsetof(MEMExpHeapHead40_t, chainFreeBlocks))
|
||||||
|
|
||||||
namespace coreinit
|
namespace coreinit
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
#include "Cafe/HW/Espresso/Debugger/GDBStub.h"
|
#include "Cafe/HW/Espresso/Debugger/GDBStub.h"
|
||||||
#include "ExceptionHandler.h"
|
#include "ExceptionHandler.h"
|
||||||
|
|
||||||
void DebugLogStackTrace(OSThread_t* thread, MPTR sp);
|
|
||||||
|
|
||||||
bool crashLogCreated = false;
|
bool crashLogCreated = false;
|
||||||
|
|
||||||
bool CrashLog_Create()
|
bool CrashLog_Create()
|
||||||
@ -97,7 +95,7 @@ void ExceptionHandler_LogGeneralInfo()
|
|||||||
MPTR currentStackVAddr = hCPU->gpr[1];
|
MPTR currentStackVAddr = hCPU->gpr[1];
|
||||||
CrashLog_WriteLine("");
|
CrashLog_WriteLine("");
|
||||||
CrashLog_WriteHeader("PPC stack trace");
|
CrashLog_WriteHeader("PPC stack trace");
|
||||||
DebugLogStackTrace(currentThread, currentStackVAddr);
|
DebugLogStackTrace(currentThread, currentStackVAddr, true);
|
||||||
|
|
||||||
// stack dump
|
// stack dump
|
||||||
CrashLog_WriteLine("");
|
CrashLog_WriteLine("");
|
||||||
|
@ -552,6 +552,9 @@ inline uint32 GetTitleIdLow(uint64 titleId)
|
|||||||
#include "Cafe/HW/Espresso/PPCState.h"
|
#include "Cafe/HW/Espresso/PPCState.h"
|
||||||
#include "Cafe/HW/Espresso/PPCCallback.h"
|
#include "Cafe/HW/Espresso/PPCCallback.h"
|
||||||
|
|
||||||
|
// PPC stack trace printer
|
||||||
|
void DebugLogStackTrace(struct OSThread_t* thread, MPTR sp, bool printSymbols = false);
|
||||||
|
|
||||||
// generic formatter for enums (to underlying)
|
// generic formatter for enums (to underlying)
|
||||||
template <typename Enum>
|
template <typename Enum>
|
||||||
requires std::is_enum_v<Enum>
|
requires std::is_enum_v<Enum>
|
||||||
|
@ -277,12 +277,10 @@ void DebugPPCThreadsWindow::RefreshThreadList()
|
|||||||
m_thread_list->SetScrollPos(0, scrollPos, true);
|
m_thread_list->SetScrollPos(0, scrollPos, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugLogStackTrace(OSThread_t* thread, MPTR sp);
|
|
||||||
|
|
||||||
void DebugPPCThreadsWindow::DumpStackTrace(OSThread_t* thread)
|
void DebugPPCThreadsWindow::DumpStackTrace(OSThread_t* thread)
|
||||||
{
|
{
|
||||||
cemuLog_log(LogType::Force, "Dumping stack trace for thread {0:08x} LR: {1:08x}", memory_getVirtualOffsetFromPointer(thread), _swapEndianU32(thread->context.lr));
|
cemuLog_log(LogType::Force, "Dumping stack trace for thread {0:08x} LR: {1:08x}", memory_getVirtualOffsetFromPointer(thread), _swapEndianU32(thread->context.lr));
|
||||||
DebugLogStackTrace(thread, _swapEndianU32(thread->context.gpr[1]));
|
DebugLogStackTrace(thread, _swapEndianU32(thread->context.gpr[1]), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugPPCThreadsWindow::PresentProfileResults(OSThread_t* thread, const std::unordered_map<VAddr, uint32>& samples)
|
void DebugPPCThreadsWindow::PresentProfileResults(OSThread_t* thread, const std::unordered_map<VAddr, uint32>& samples)
|
||||||
|
Loading…
Reference in New Issue
Block a user