summaryrefslogtreecommitdiff
path: root/tools/dsymutil/DebugMap.h
diff options
context:
space:
mode:
authorFrederic Riss <friss@apple.com>2015-06-03 16:57:16 +0000
committerFrederic Riss <friss@apple.com>2015-06-03 16:57:16 +0000
commit001b032fea2f75e59b1b1ed7024e62e6672b3423 (patch)
tree22741de790018e96ece0dde6e9104a721514e627 /tools/dsymutil/DebugMap.h
parent7745dac9d01bce1cdcbda59b7e5726867a659095 (diff)
[dsymutil] Accept a YAML debug map as input instead of a binary.
To do this, the user needs to pass the new -y flag. As it wasn't tested before, the debug map YAML deserialization was completely buggy (mainly because the DebugMapObject has a dual mapping that allows to search by name and by address, but only the StringMap got populated). It's fixed and tested in this commit by augmenting some test with a 2 stage dwarf link: a frist llvm-dsymutil reads the debug map and pipes it in a second instance that does the actual link without touching the initial binary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238941 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/dsymutil/DebugMap.h')
-rw-r--r--tools/dsymutil/DebugMap.h50
1 files changed, 31 insertions, 19 deletions
diff --git a/tools/dsymutil/DebugMap.h b/tools/dsymutil/DebugMap.h
index 8d76f113e91..c2917db981e 100644
--- a/tools/dsymutil/DebugMap.h
+++ b/tools/dsymutil/DebugMap.h
@@ -69,6 +69,7 @@ class DebugMap {
/// For YAML IO support.
///@{
+ friend yaml::MappingTraits<std::unique_ptr<DebugMap>>;
friend yaml::MappingTraits<DebugMap>;
DebugMap() = default;
///@}
@@ -184,33 +185,35 @@ struct MappingTraits<std::pair<std::string, DebugMapObject::SymbolMapping>> {
};
template <> struct MappingTraits<dsymutil::DebugMapObject> {
- typedef StringMap<dsymutil::DebugMapObject::SymbolMapping> SymbolMap;
-
- struct SequencedStringMap {
- SequencedStringMap(IO &io) {}
-
- SequencedStringMap(IO &io, SymbolMap &Map) {
- Entries.reserve(Map.size());
- for (auto &Entry : Map)
+ // Normalize/Denormalize between YAML and a DebugMapObject.
+ struct YamlDMO {
+ YamlDMO(IO &io) {}
+
+ YamlDMO(IO &io, dsymutil::DebugMapObject &Obj) {
+ Filename = Obj.Filename;
+ Entries.reserve(Obj.Symbols.size());
+ for (auto &Entry : Obj.Symbols)
Entries.push_back(std::make_pair(Entry.getKey(), Entry.getValue()));
}
- SymbolMap denormalize(IO &) {
- SymbolMap Res;
-
- for (auto &Entry : Entries)
- Res[Entry.first] = Entry.second;
-
+ dsymutil::DebugMapObject denormalize(IO &) {
+ dsymutil::DebugMapObject Res(Filename);
+ for (auto &Entry : Entries) {
+ auto &Mapping = Entry.second;
+ Res.addSymbol(Entry.first, Mapping.ObjectAddress, Mapping.BinaryAddress,
+ Mapping.Size);
+ }
return Res;
}
+ std::string Filename;
std::vector<dsymutil::DebugMapObject::YAMLSymbolMapping> Entries;
};
- static void mapping(IO &io, dsymutil::DebugMapObject &s) {
- MappingNormalization<SequencedStringMap, SymbolMap> seq(io, s.Symbols);
- io.mapRequired("filename", s.Filename);
- io.mapRequired("symbols", seq->Entries);
+ static void mapping(IO &io, dsymutil::DebugMapObject &DMO) {
+ MappingNormalization<YamlDMO, dsymutil::DebugMapObject> Norm(io, DMO);
+ io.mapRequired("filename", Norm->Filename);
+ io.mapRequired("symbols", Norm->Entries);
}
};
@@ -222,7 +225,7 @@ template <> struct ScalarTraits<Triple> {
static StringRef input(StringRef scalar, void *, Triple &value) {
value = Triple(scalar);
- return value.str();
+ return StringRef();
}
static bool mustQuote(StringRef) { return true; }
@@ -253,6 +256,15 @@ template <> struct MappingTraits<dsymutil::DebugMap> {
io.mapOptional("objects", DM.Objects);
}
};
+
+ template <> struct MappingTraits<std::unique_ptr<dsymutil::DebugMap>> {
+ static void mapping(IO &io, std::unique_ptr<dsymutil::DebugMap> &DM) {
+ if (!DM)
+ DM.reset(new DebugMap());
+ io.mapRequired("triple", DM->BinaryTriple);
+ io.mapOptional("objects", DM->Objects);
+ }
+};
}
}