When decompiling a single C++ function via --function _ZN5Debug7Command10VarHandler10GetVarInfoEPNS0_7Context, the function is not found even though it exists in the binary. Additionally, the serialized JSON output demangles local names rather than mangled symbols.
Root Causes
decompileSingleFunction() calls getGlobalFunctions(name) only searches by demangled local name in the global namespace. For C++ symbols, Ghidra demangles them and stores them in namespaces (e.g., GetVarInfo in Debug::Command::VarHandler), so mangled-name lookups return empty results.
PcodeSerializer and FunctionSerializer emit function.getName() (demangled local name) rather than the original mangled symbol name needed by downstream tools to link back to binary symbols.
Fix
Implement a multi-strategy function name lookup for mangled names in the global namespace, and also look up local names in defined namespaces before serialization. Serialize the external functions with their mangled names.
When decompiling a single C++ function via
--function _ZN5Debug7Command10VarHandler10GetVarInfoEPNS0_7Context, the function is not found even though it exists in the binary. Additionally, the serialized JSON output demangles local names rather than mangled symbols.Root Causes
decompileSingleFunction()callsgetGlobalFunctions(name)only searches by demangled local name in the global namespace. For C++ symbols, Ghidra demangles them and stores them in namespaces (e.g.,GetVarInfoinDebug::Command::VarHandler), so mangled-name lookups return empty results.PcodeSerializerandFunctionSerializeremitfunction.getName()(demangled local name) rather than the original mangled symbol name needed by downstream tools to link back to binary symbols.Fix
Implement a multi-strategy function name lookup for mangled names in the global namespace, and also look up local names in defined namespaces before serialization. Serialize the external functions with their mangled names.