summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/obj2yaml/dwarf2yaml.cpp24
-rw-r--r--llvm/tools/yaml2obj/yaml2dwarf.cpp27
-rw-r--r--llvm/tools/yaml2obj/yaml2macho.cpp3
-rw-r--r--llvm/tools/yaml2obj/yaml2obj.h2
4 files changed, 56 insertions, 0 deletions
diff --git a/llvm/tools/obj2yaml/dwarf2yaml.cpp b/llvm/tools/obj2yaml/dwarf2yaml.cpp
index 112d62621de..ca55702be96 100644
--- a/llvm/tools/obj2yaml/dwarf2yaml.cpp
+++ b/llvm/tools/obj2yaml/dwarf2yaml.cpp
@@ -9,6 +9,7 @@
#include "Error.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
+#include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h"
#include "llvm/ObjectYAML/DWARFYAML.h"
using namespace llvm;
@@ -44,10 +45,33 @@ void dumpDebugStrings(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) {
}
}
+void dumpDebugARanges(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) {
+ DataExtractor ArangesData(DCtx.getARangeSection(), DCtx.isLittleEndian(), 0);
+ uint32_t Offset = 0;
+ DWARFDebugArangeSet Set;
+
+ while (Set.extract(ArangesData, &Offset)) {
+ DWARFYAML::ARange Range;
+ Range.Length = Set.getHeader().Length;
+ Range.Version = Set.getHeader().Version;
+ Range.CuOffset = Set.getHeader().CuOffset;
+ Range.AddrSize = Set.getHeader().AddrSize;
+ Range.SegSize = Set.getHeader().SegSize;
+ for (auto Descriptor : Set.descriptors()) {
+ DWARFYAML::ARangeDescriptor Desc;
+ Desc.Address = Descriptor.Address;
+ Desc.Length = Descriptor.Length;
+ Range.Descriptors.push_back(Desc);
+ }
+ Y.ARanges.push_back(Range);
+ }
+}
+
std::error_code dwarf2yaml(DWARFContextInMemory &DCtx,
DWARFYAML::Data &Y) {
dumpDebugAbbrev(DCtx, Y);
dumpDebugStrings(DCtx, Y);
+ dumpDebugARanges(DCtx, Y);
return obj2yaml_error::success;
}
diff --git a/llvm/tools/yaml2obj/yaml2dwarf.cpp b/llvm/tools/yaml2obj/yaml2dwarf.cpp
index deef9a1d98b..fcc58330ee9 100644
--- a/llvm/tools/yaml2obj/yaml2dwarf.cpp
+++ b/llvm/tools/yaml2obj/yaml2dwarf.cpp
@@ -19,6 +19,12 @@
using namespace llvm;
+void ZeroFillBytes(raw_ostream &OS, size_t Size) {
+ std::vector<uint8_t> FillData;
+ FillData.insert(FillData.begin(), Size, 0);
+ OS.write(reinterpret_cast<char *>(FillData.data()), Size);
+}
+
void yaml2debug_str(raw_ostream &OS, const DWARFYAML::Data &DI) {
for (auto Str : DI.DebugStrings) {
OS.write(Str.data(), Str.size());
@@ -39,3 +45,24 @@ void yaml2debug_abbrev(raw_ostream &OS, const DWARFYAML::Data &DI) {
encodeULEB128(0, OS);
}
}
+
+void yaml2debug_aranges(raw_ostream &OS, const DWARFYAML::Data &DI) {
+ for (auto Range : DI.ARanges) {
+ auto HeaderStart = OS.tell();
+ OS.write(reinterpret_cast<char *>(&Range.Length), 4);
+ OS.write(reinterpret_cast<char *>(&Range.Version), 2);
+ OS.write(reinterpret_cast<char *>(&Range.CuOffset), 4);
+ OS.write(reinterpret_cast<char *>(&Range.AddrSize), 1);
+ OS.write(reinterpret_cast<char *>(&Range.SegSize), 1);
+
+ auto HeaderSize = OS.tell() - HeaderStart;
+ auto FirstDescriptor = alignTo(HeaderSize, Range.AddrSize * 2);
+ ZeroFillBytes(OS, FirstDescriptor - HeaderSize);
+
+ for (auto Descriptor : Range.Descriptors) {
+ OS.write(reinterpret_cast<char *>(&Descriptor.Address), Range.AddrSize);
+ OS.write(reinterpret_cast<char *>(&Descriptor.Length), Range.AddrSize);
+ }
+ ZeroFillBytes(OS, Range.AddrSize * 2);
+ }
+}
diff --git a/llvm/tools/yaml2obj/yaml2macho.cpp b/llvm/tools/yaml2obj/yaml2macho.cpp
index a6d56ef8501..76dec4bb389 100644
--- a/llvm/tools/yaml2obj/yaml2macho.cpp
+++ b/llvm/tools/yaml2obj/yaml2macho.cpp
@@ -393,6 +393,9 @@ Error MachOWriter::writeDWARFData(raw_ostream &OS,
} else if (0 == strncmp(&Section.sectname[0], "__debug_abbrev", 16)) {
yaml2debug_abbrev(OS, Obj.DWARF);
}
+ else if (0 == strncmp(&Section.sectname[0], "__debug_aranges", 16)) {
+ yaml2debug_aranges(OS, Obj.DWARF);
+ }
}
return Error::success();
}
diff --git a/llvm/tools/yaml2obj/yaml2obj.h b/llvm/tools/yaml2obj/yaml2obj.h
index f54ffe57c0b..cd481c0fd4e 100644
--- a/llvm/tools/yaml2obj/yaml2obj.h
+++ b/llvm/tools/yaml2obj/yaml2obj.h
@@ -42,4 +42,6 @@ void yaml2debug_abbrev(llvm::raw_ostream &OS,
void yaml2debug_str(llvm::raw_ostream &OS,
const llvm::DWARFYAML::Data &DI);
+void yaml2debug_aranges(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
+
#endif
OpenPOWER on IntegriCloud