Core/Debugger_SymbolMap: Make GetCallstack() less verbose

This also allows the constructed CallstackEntry instances to be moved into
the output vector, rather than being copied.
This commit is contained in:
Lioncache 2023-12-18 15:40:03 -05:00
parent 75ec350dc4
commit 472c65ed35
1 changed files with 15 additions and 13 deletions

View File

@ -61,26 +61,28 @@ bool GetCallstack(const Core::CPUThreadGuard& guard, std::vector<CallstackEntry>
if (LR(ppc_state) == 0) if (LR(ppc_state) == 0)
{ {
CallstackEntry entry; output.push_back({
entry.Name = "(error: LR=0)"; .Name = "(error: LR=0)",
entry.vAddress = 0x0; .vAddress = 0,
output.push_back(entry); });
return false; return false;
} }
CallstackEntry entry; output.push_back({
entry.Name = fmt::format(" * {} [ LR = {:08x} ]\n", g_symbolDB.GetDescription(LR(ppc_state)), .Name = fmt::format(" * {} [ LR = {:08x} ]\n", g_symbolDB.GetDescription(LR(ppc_state)),
LR(ppc_state) - 4); LR(ppc_state) - 4),
entry.vAddress = LR(ppc_state) - 4; .vAddress = LR(ppc_state) - 4,
output.push_back(entry); });
WalkTheStack(guard, [&entry, &output](u32 func_addr) { WalkTheStack(guard, [&output](u32 func_addr) {
std::string func_desc = g_symbolDB.GetDescription(func_addr); std::string func_desc = g_symbolDB.GetDescription(func_addr);
if (func_desc.empty() || func_desc == "Invalid") if (func_desc.empty() || func_desc == "Invalid")
func_desc = "(unknown)"; func_desc = "(unknown)";
entry.Name = fmt::format(" * {} [ addr = {:08x} ]\n", func_desc, func_addr - 4);
entry.vAddress = func_addr - 4; output.push_back({
output.push_back(entry); .Name = fmt::format(" * {} [ addr = {:08x} ]\n", func_desc, func_addr - 4),
.vAddress = func_addr - 4,
});
}); });
return true; return true;