summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-04-27 16:10:29 +0000
committerReid Kleckner <rnk@google.com>2016-04-27 16:10:29 +0000
commit0336cc05e718cd394cfd22ab519f9a9a4c998b08 (patch)
treef9a992b369a5c359b90467a097be779c83825a64 /llvm/lib
parent5b759f82fa0a48eb828d59efd5fa2b923eb94a3d (diff)
downloadbcm5719-llvm-0336cc05e718cd394cfd22ab519f9a9a4c998b08.tar.gz
bcm5719-llvm-0336cc05e718cd394cfd22ab519f9a9a4c998b08.zip
[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 llvm-svn: 267732
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DebugInfo/PDB/PDBContext.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/llvm/lib/DebugInfo/PDB/PDBContext.cpp b/llvm/lib/DebugInfo/PDB/PDBContext.cpp
index 561a91ea08b..73c56162430 100644
--- a/llvm/lib/DebugInfo/PDB/PDBContext.cpp
+++ b/llvm/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();
}
OpenPOWER on IntegriCloud