[dsymutil] Allow debug map mappings with no object file address. NFC
This change just changes the data structure that ties symbol names,
object file address and linked binary addresses to accept mappings
with no object file address. Such symbol mappings are not fed into
the debug map yet, so this patch is NFC.
A subsequent patch will make use of this functionality for common
symbols.
llvm-svn: 259317
diff --git a/llvm/tools/dsymutil/DebugMap.cpp b/llvm/tools/dsymutil/DebugMap.cpp
index 4717085..d2d5b61 100644
--- a/llvm/tools/dsymutil/DebugMap.cpp
+++ b/llvm/tools/dsymutil/DebugMap.cpp
@@ -24,13 +24,13 @@
sys::TimeValue Timestamp)
: Filename(ObjectFilename), Timestamp(Timestamp) {}
-bool DebugMapObject::addSymbol(StringRef Name, uint64_t ObjectAddress,
+bool DebugMapObject::addSymbol(StringRef Name, Optional<uint64_t> ObjectAddress,
uint64_t LinkedAddress, uint32_t Size) {
auto InsertResult = Symbols.insert(
std::make_pair(Name, SymbolMapping(ObjectAddress, LinkedAddress, Size)));
- if (InsertResult.second)
- AddressToMapping[ObjectAddress] = &*InsertResult.first;
+ if (ObjectAddress && InsertResult.second)
+ AddressToMapping[*ObjectAddress] = &*InsertResult.first;
return InsertResult.second;
}
@@ -47,8 +47,11 @@
Entries.begin(), Entries.end(),
[](const Entry &LHS, const Entry &RHS) { return LHS.first < RHS.first; });
for (const auto &Sym : Entries) {
- OS << format("\t%016" PRIx64 " => %016" PRIx64 "+0x%x\t%s\n",
- uint64_t(Sym.second.ObjectAddress),
+ if (Sym.second.ObjectAddress)
+ OS << format("\t%016" PRIx64, uint64_t(*Sym.second.ObjectAddress));
+ else
+ OS << "\t????????????????";
+ OS << format(" => %016" PRIx64 "+0x%x\t%s\n",
uint64_t(Sym.second.BinaryAddress), uint32_t(Sym.second.Size),
Sym.first.data());
}
@@ -136,7 +139,7 @@
void MappingTraits<std::pair<std::string, DebugMapObject::SymbolMapping>>::
mapping(IO &io, std::pair<std::string, DebugMapObject::SymbolMapping> &s) {
io.mapRequired("sym", s.first);
- io.mapRequired("objAddr", s.second.ObjectAddress);
+ io.mapOptional("objAddr", s.second.ObjectAddress);
io.mapRequired("binAddr", s.second.BinaryAddress);
io.mapOptional("size", s.second.Size);
}
@@ -237,7 +240,9 @@
dsymutil::DebugMapObject Res(Path, TV);
for (auto &Entry : Entries) {
auto &Mapping = Entry.second;
- uint64_t ObjAddress = Mapping.ObjectAddress;
+ Optional<uint64_t> ObjAddress;
+ if (Mapping.ObjectAddress)
+ ObjAddress = *Mapping.ObjectAddress;
auto AddressIt = SymbolAddresses.find(Entry.first);
if (AddressIt != SymbolAddresses.end())
ObjAddress = AddressIt->getValue();