uint64_t LinkedAddress) {
auto InsertResult = Symbols.insert(
std::make_pair(Name, SymbolMapping(ObjectAddress, LinkedAddress)));
+
+ if (InsertResult.second)
+ AddressToMapping[ObjectAddress] = &*InsertResult.first;
return InsertResult.second;
}
return *Objects.back();
}
-const DebugMapObject::SymbolMapping *
+const DebugMapObject::DebugMapEntry *
DebugMapObject::lookupSymbol(StringRef SymbolName) const {
StringMap<SymbolMapping>::const_iterator Sym = Symbols.find(SymbolName);
if (Sym == Symbols.end())
return nullptr;
- return &Sym->getValue();
+ return &*Sym;
+}
+
+const DebugMapObject::DebugMapEntry *
+DebugMapObject::lookupObjectAddress(uint64_t Address) const {
+ auto Mapping = AddressToMapping.find(Address);
+ if (Mapping == AddressToMapping.end())
+ return nullptr;
+ return Mapping->getSecond();
}
void DebugMap::print(raw_ostream &OS) const {
#ifndef LLVM_TOOLS_DSYMUTIL_DEBUGMAP_H
#define LLVM_TOOLS_DSYMUTIL_DEBUGMAP_H
+#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/Triple.h"
#include "llvm/ADT/iterator_range.h"
: ObjectAddress(ObjectAddress), BinaryAddress(BinaryAddress) {}
};
+ typedef StringMapEntry<SymbolMapping> DebugMapEntry;
+
/// \brief Adds a symbol mapping to this DebugMapObject.
/// \returns false if the symbol was already registered. The request
/// is discarded in this case.
/// \brief Lookup a symbol mapping.
/// \returns null if the symbol isn't found.
- const SymbolMapping *lookupSymbol(StringRef SymbolName) const;
+ const DebugMapEntry *lookupSymbol(StringRef SymbolName) const;
+
+ /// \brief Lookup an objectfile address.
+ /// \returns null if the address isn't found.
+ const DebugMapEntry *lookupObjectAddress(uint64_t Address) const;
llvm::StringRef getObjectFilename() const { return Filename; }
std::string Filename;
StringMap<SymbolMapping> Symbols;
+ DenseMap<uint64_t, DebugMapEntry *> AddressToMapping;
};
}
}