summaryrefslogtreecommitdiff
path: root/third_party/llvm-project
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/llvm-project')
-rw-r--r--third_party/llvm-project/DWARFEmitter.cpp20
-rw-r--r--third_party/llvm-project/dwarf2yaml.cpp29
-rw-r--r--third_party/llvm-project/include/llvm/ObjectYAML/DWARFEmitter.h1
-rw-r--r--third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h12
4 files changed, 62 insertions, 0 deletions
diff --git a/third_party/llvm-project/DWARFEmitter.cpp b/third_party/llvm-project/DWARFEmitter.cpp
index b17ad83ef..8acef5bef 100644
--- a/third_party/llvm-project/DWARFEmitter.cpp
+++ b/third_party/llvm-project/DWARFEmitter.cpp
@@ -130,6 +130,24 @@ void DWARFYAML::EmitDebugRanges(raw_ostream &OS, const DWARFYAML::Data &DI) {
}
}
+// XXX BINARYEN
+void DWARFYAML::EmitDebugLoc(raw_ostream &OS, const DWARFYAML::Data &DI) {
+ for (auto Loc : DI.Locs) {
+ writeInteger((uint32_t)Loc.Start, OS, DI.IsLittleEndian);
+ writeInteger((uint32_t)Loc.End, OS, DI.IsLittleEndian);
+ if (Loc.Start == 0 && Loc.End == 0) {
+ // End of a list.
+ continue;
+ }
+ if (Loc.Start != -1) {
+ writeInteger((uint16_t)Loc.Location.size(), OS, DI.IsLittleEndian);
+ for (auto x : Loc.Location) {
+ writeInteger((uint8_t)x, OS, DI.IsLittleEndian);
+ }
+ }
+ }
+}
+
void DWARFYAML::EmitPubSection(raw_ostream &OS,
const DWARFYAML::PubSection &Sect,
bool IsLittleEndian) {
@@ -430,6 +448,8 @@ EmitDebugSections(llvm::DWARFYAML::Data &DI, bool ApplyFixups) {
DebugSections);
EmitDebugSectionImpl(DI, &DWARFYAML::EmitDebugRanges, "debug_ranges",
DebugSections); // XXX BINARYEN
+ EmitDebugSectionImpl(DI, &DWARFYAML::EmitDebugLoc, "debug_loc",
+ DebugSections); // XXX BINARYEN
return std::move(DebugSections);
}
} // namespace DWARFYAML
diff --git a/third_party/llvm-project/dwarf2yaml.cpp b/third_party/llvm-project/dwarf2yaml.cpp
index 7d5f2e048..994be5511 100644
--- a/third_party/llvm-project/dwarf2yaml.cpp
+++ b/third_party/llvm-project/dwarf2yaml.cpp
@@ -105,6 +105,34 @@ void dumpDebugRanges(DWARFContext &DCtx, DWARFYAML::Data &Y) { // XXX BINARYEN
}
}
+void dumpDebugLoc(DWARFContext &DCtx, DWARFYAML::Data &Y) { // XXX BINARYEN
+ uint8_t savedAddressByteSize = 4;
+ DWARFDataExtractor locsData(DCtx.getDWARFObj(), DCtx.getDWARFObj().getLocSection(),
+ DCtx.isLittleEndian(), savedAddressByteSize);
+ uint64_t offset = 0;
+ DWARFDebugLoc locList;
+ while (locsData.isValidOffset(offset)) {
+ auto list = locList.parseOneLocationList(locsData, &offset);
+ if (!list) {
+ errs() << "debug_loc error\n";
+ break;
+ }
+ for (auto& entry : list.get().Entries) {
+ DWARFYAML::Loc loc;
+ loc.Start = entry.Begin;
+ loc.End = entry.End;
+ for (auto x : entry.Loc) {
+ loc.Location.push_back(x);
+ }
+ Y.Locs.push_back(loc);
+ }
+ DWARFYAML::Loc loc;
+ loc.Start = 0;
+ loc.End = 0;
+ Y.Locs.push_back(loc);
+ }
+}
+
void dumpPubSection(DWARFContext &DCtx, DWARFYAML::PubSection &Y,
DWARFSection Section) {
DWARFDataExtractor PubSectionData(DCtx.getDWARFObj(), Section,
@@ -380,6 +408,7 @@ std::error_code dwarf2yaml(DWARFContext &DCtx, DWARFYAML::Data &Y) {
dumpDebugStrings(DCtx, Y);
dumpDebugARanges(DCtx, Y);
dumpDebugRanges(DCtx, Y); // XXX BINARYEN
+ dumpDebugLoc(DCtx, Y); // XXX BINARYEN
dumpDebugPubSections(DCtx, Y);
dumpDebugInfo(DCtx, Y);
dumpDebugLines(DCtx, Y);
diff --git a/third_party/llvm-project/include/llvm/ObjectYAML/DWARFEmitter.h b/third_party/llvm-project/include/llvm/ObjectYAML/DWARFEmitter.h
index 85bc81c60..b4d62f44d 100644
--- a/third_party/llvm-project/include/llvm/ObjectYAML/DWARFEmitter.h
+++ b/third_party/llvm-project/include/llvm/ObjectYAML/DWARFEmitter.h
@@ -33,6 +33,7 @@ void EmitDebugStr(raw_ostream &OS, const Data &DI);
void EmitDebugAranges(raw_ostream &OS, const Data &DI);
void EmitDebugRanges(raw_ostream &OS, const Data &DI); // XXX BINARYEN
+void EmitDebugLoc(raw_ostream &OS, const Data &DI); // XXX BINARYEN
void EmitPubSection(raw_ostream &OS, const PubSection &Sect,
bool IsLittleEndian);
void EmitDebugInfo(raw_ostream &OS, const Data &DI);
diff --git a/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h b/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h
index 943868b36..948418c7b 100644
--- a/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h
+++ b/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h
@@ -77,6 +77,12 @@ struct Range {
uint64_t End;
uint64_t SectionIndex; // XXX ?
};
+
+struct Loc {
+ uint32_t Start;
+ uint32_t End;
+ std::vector<uint8_t> Location;
+};
// XXX BINARYEN -->
struct PubEntry {
@@ -154,6 +160,7 @@ struct Data {
std::vector<StringRef> DebugStrings;
std::vector<ARange> ARanges;
std::vector<Range> Ranges; // XXX BINARYEN
+ std::vector<Loc> Locs; // XXX BINARYEN
PubSection PubNames;
PubSection PubTypes;
@@ -175,6 +182,7 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Abbrev)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARangeDescriptor)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARange)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Range) // XXX BINARYEN
+LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Loc) // XXX BINARYEN
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::PubEntry)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Unit)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::FormValue)
@@ -210,6 +218,10 @@ template <> struct MappingTraits<DWARFYAML::Range> { // XXX BINARYEN
static void mapping(IO &IO, DWARFYAML::Range &Range);
};
+template <> struct MappingTraits<DWARFYAML::Loc> { // XXX BINARYEN
+ static void mapping(IO &IO, DWARFYAML::Loc &Loc);
+};
+
template <> struct MappingTraits<DWARFYAML::PubEntry> {
static void mapping(IO &IO, DWARFYAML::PubEntry &Entry);
};