mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-02 18:53:58 +01:00
Demangle C++ symbol names when loading ELF symbols
C++ homebrew has an unreadable symbol table - everything is _ZN10PxRenderer7DrawImmE... - which makes the disassembly and symbol list nearly useless. Add an Itanium C++ ABI demangler and run ELF symbols through it on load, in both ElfReader::LoadSymbols (unstripped EXECs, which is what a CMake pspdev EBOOT actually contains) and the companion-ELF path. The demangling standard is called Itanium for historical reasons - it was defined for Itanium but ended up being almost universally applicable. Written from scratch rather than using __cxa_demangle, which doesn't exist on MSVC/UWP, or vendoring LLVM's demangler, whose license doesn't fit. Anything unrecognized (arbitrary constant expressions, decltype) aborts the parse and the caller gets the original mangled name back, so a caller never sees a half-parsed result. Recursion is depth-capped since the input comes from a file we didn't write. Checked against c++filt as an oracle: of 1089 mangled symbols in a real C++ homebrew EBOOT, one differs; of 55189 from libstdc++/libLLVM/cc1plus, 22 differ and 413 are declined. Fuzzed with 220k mutated and random inputs under ASan/UBSan. Also adds a right-click menu to the ImDebugger symbol list. Note that SymbolMap stores names in char[128], so the longest STL names get truncated in the UI. Still far more readable than the mangled form. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X3DbkJ8ShYiXU7q5Tv1LZu
This commit is contained in:
1 parent
a0c10a0ea6
commit
049bcd5483
16 files changed
+1427
-3
No files matched your search
@@ -1374,12 +1374,25 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImContro
|
||||
while (clipper.Step()) {
|
||||
for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++) {
|
||||
const int i = symMatches_[row];
|
||||
// Names aren't unique (static functions in different modules, mainly),
|
||||
// so the index has to provide the ID instead.
|
||||
ImGui::PushID(i);
|
||||
if (ImGui::Selectable(symCache_[i].name.c_str(), selectedSymbol_ == i)) {
|
||||
disasmView_.gotoAddr(symCache_[i].address);
|
||||
disasmView_.scrollAddressIntoView();
|
||||
truncate_cpy(selectedSymbolName_, symCache_[i].name);
|
||||
selectedSymbol_ = i;
|
||||
}
|
||||
if (ImGui::BeginPopupContextItem("symctx")) {
|
||||
if (ImGui::MenuItem("Copy name to clipboard")) {
|
||||
System_CopyStringToClipboard(symCache_[i].name);
|
||||
}
|
||||
if (ImGui::MenuItem("Copy address to clipboard")) {
|
||||
System_CopyStringToClipboard(StringFromFormat("%08x", symCache_[i].address));
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
clipper.End();
|
||||
|
||||
Reference in new issue
Block a user