diff options
author | Reid Kleckner <rnk@google.com> | 2016-04-27 16:10:29 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2016-04-27 16:10:29 +0000 |
commit | 8a9e8e98ef2059cc91acaac69e496ab893d85fe0 (patch) | |
tree | 1b67a3df06524689f3b7a9a0262ab9da719431a5 /lib/DebugInfo/PDB/PDBContext.cpp | |
parent | 0493c734a287b5dc2ba011cb3b23dde7d2a45773 (diff) |
[PDB] Fix function names for private symbols in PDBs
Summary:
llvm-symbolizer wants to get linkage names of functions for historical
reasons. Linkage names are only recorded in the PDB for public symbols,
and the linkage name is apparently stored separately in some "public
symbol" record. We had a workaround in PDBContext which would look for
such symbols when the user requested linkage names.
However, when given an address that was truly in a private function and
public funciton, we would accidentally find nearby public symbols and
return those function names. The fix is to look for both function
symbols and public symbols and only prefer the public symbol name if the
addresses of the symbols agree.
Fixes PR27492
Reviewers: zturner
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D19571
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267732 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/DebugInfo/PDB/PDBContext.cpp')
-rw-r--r-- | lib/DebugInfo/PDB/PDBContext.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/lib/DebugInfo/PDB/PDBContext.cpp b/lib/DebugInfo/PDB/PDBContext.cpp index 561a91ea08b..73c56162430 100644 --- a/lib/DebugInfo/PDB/PDBContext.cpp +++ b/lib/DebugInfo/PDB/PDBContext.cpp @@ -96,26 +96,24 @@ std::string PDBContext::getFunctionName(uint64_t Address, if (NameKind == DINameKind::None) return std::string(); + std::unique_ptr<PDBSymbol> FuncSymbol = + Session->findSymbolByAddress(Address, PDB_SymType::Function); + auto *Func = dyn_cast_or_null<PDBSymbolFunc>(FuncSymbol.get()); + if (NameKind == DINameKind::LinkageName) { // It is not possible to get the mangled linkage name through a // PDBSymbolFunc. For that we have to specifically request a // PDBSymbolPublicSymbol. auto PublicSym = Session->findSymbolByAddress(Address, PDB_SymType::PublicSymbol); - if (auto PS = dyn_cast_or_null<PDBSymbolPublicSymbol>(PublicSym.get())) - return PS->getName(); + if (auto *PS = dyn_cast_or_null<PDBSymbolPublicSymbol>(PublicSym.get())) { + // If we also have a function symbol, prefer the use of public symbol name + // only if it refers to the same address. The public symbol uses the + // linkage name while the function does not. + if (!Func || Func->getVirtualAddress() == PS->getVirtualAddress()) + return PS->getName(); + } } - auto FuncSymbol = - Session->findSymbolByAddress(Address, PDB_SymType::Function); - - // This could happen either if there was no public symbol (e.g. not - // external) or the user requested the short name. In the former case, - // although they technically requested the linkage name, if the linkage - // name is not available we fallback to at least returning a non-empty - // string. - if (auto Func = dyn_cast_or_null<PDBSymbolFunc>(FuncSymbol.get())) - return Func->getName(); - - return std::string(); + return Func ? Func->getName() : std::string(); } |