forked from OSchip/llvm-project
[dsymutil] Add DebugMapObject::lookupObjectAddress()
It turns out the debug map will be interogated both by name and by object file address. Add the latter capability. llvm-svn: 229177
This commit is contained in:
parent
f942c0c89d
commit
1595c5d37d
|
@ -26,6 +26,9 @@ bool DebugMapObject::addSymbol(StringRef Name, uint64_t ObjectAddress,
|
|||
uint64_t LinkedAddress) {
|
||||
auto InsertResult = Symbols.insert(
|
||||
std::make_pair(Name, SymbolMapping(ObjectAddress, LinkedAddress)));
|
||||
|
||||
if (InsertResult.second)
|
||||
AddressToMapping[ObjectAddress] = &*InsertResult.first;
|
||||
return InsertResult.second;
|
||||
}
|
||||
|
||||
|
@ -58,12 +61,20 @@ DebugMapObject &DebugMap::addDebugMapObject(StringRef ObjectFilePath) {
|
|||
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 {
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#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"
|
||||
|
@ -104,6 +105,8 @@ public:
|
|||
: 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.
|
||||
|
@ -112,7 +115,11 @@ public:
|
|||
|
||||
/// \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; }
|
||||
|
||||
|
@ -127,6 +134,7 @@ private:
|
|||
|
||||
std::string Filename;
|
||||
StringMap<SymbolMapping> Symbols;
|
||||
DenseMap<uint64_t, DebugMapEntry *> AddressToMapping;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue