From c67eecce0d87c3738c9a133e3d2f502ce28f37dd Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Wed, 19 Feb 2025 23:22:56 -0500 Subject: [SharedCache] Demangle relevant symbols Use the LLVM demangler to demangle relevant symbols --- view/sharedcache/core/SharedCache.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'view/sharedcache/core/SharedCache.cpp') diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp index 6fe0dc24..afbd3b58 100644 --- a/view/sharedcache/core/SharedCache.cpp +++ b/view/sharedcache/core/SharedCache.cpp @@ -2348,7 +2348,11 @@ void SharedCache::ProcessSymbols(std::shared_ptr file, cons if ((nlist.n_desc & N_ARM_THUMB_DEF) == N_ARM_THUMB_DEF) symbolAddress++; - Ref sym = new Symbol(symbolType.value(), symbolName, symbolAddress, nullptr, GlobalBinding); + QualifiedName demangledName = {}; + std::string shortName = symbolName; + if (DemangleLLVM(symbolName, demangledName, true)) + shortName = demangledName.GetString(); + Ref sym = new Symbol(symbolType.value(), shortName, shortName, symbolName, symbolAddress, nullptr); symbolList.emplace_back(sym); } @@ -3300,7 +3304,13 @@ void Deserialize(DeserializationContext& context, std::string_view name, std::string symbolName = symbol_array[0].GetString(); uint64_t address = symbol_array[1].GetUint64(); BNSymbolType type = (BNSymbolType)symbol_array[2].GetUint(); - symbols.insert({address, new Symbol(type, symbolName, address)}); + + QualifiedName demangledName = {}; + std::string shortName = symbolName; + if (DemangleLLVM(symbolName, demangledName, true)) + shortName = demangledName.GetString(); + Ref sym = new Symbol(type, shortName, shortName, symbolName, address, nullptr); + symbols.insert({address, sym}); } value[pair[0].GetUint64()] = std::make_shared>>(std::move(symbols)); } @@ -3321,7 +3331,13 @@ void Deserialize(DeserializationContext& context, std::string_view name, std::string symbolName = symbol_array[0].GetString(); uint64_t address = symbol_array[1].GetUint64(); BNSymbolType type = (BNSymbolType)symbol_array[2].GetUint(); - symbols.push_back(new Symbol(type, symbolName, address)); + + QualifiedName demangledName = {}; + std::string shortName = symbolName; + if (DemangleLLVM(symbolName, demangledName, true)) + shortName = demangledName.GetString(); + Ref sym = new Symbol(type, shortName, shortName, symbolName, address, nullptr); + symbols.emplace_back(sym); } value[pair[0].GetUint64()] = std::make_shared>>(std::move(symbols)); } -- cgit v1.3.1