[PATCH] D80861: [ObjectYAML][DWARF] Let `dumpPubSection` return `DWARFYAML::PubSection`.
Xing GUO via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 29 23:23:32 PDT 2020
Higuoxing created this revision.
Higuoxing added reviewers: grimar, jhenderson.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch addresses comments in D80722 <https://reviews.llvm.org/D80722#inline-742353>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D80861
Files:
llvm/tools/obj2yaml/dwarf2yaml.cpp
Index: llvm/tools/obj2yaml/dwarf2yaml.cpp
===================================================================
--- llvm/tools/obj2yaml/dwarf2yaml.cpp
+++ llvm/tools/obj2yaml/dwarf2yaml.cpp
@@ -115,10 +115,12 @@
return ErrorSuccess();
}
-void dumpPubSection(DWARFContext &DCtx, DWARFYAML::PubSection &Y,
- DWARFSection Section) {
+static DWARFYAML::PubSection dumpPubSection(const DWARFContext &DCtx,
+ const DWARFSection &Section,
+ bool IsGNUStyle) {
DWARFDataExtractor PubSectionData(DCtx.getDWARFObj(), Section,
DCtx.isLittleEndian(), 0);
+ DWARFYAML::PubSection Y(IsGNUStyle);
uint64_t Offset = 0;
dumpInitialLength(PubSectionData, Offset, Y.Length);
Y.Version = PubSectionData.getU16(&Offset);
@@ -127,41 +129,35 @@
while (Offset < Y.Length.getLength()) {
DWARFYAML::PubEntry NewEntry;
NewEntry.DieOffset = PubSectionData.getU32(&Offset);
- if (Y.IsGNUStyle)
+ if (IsGNUStyle)
NewEntry.Descriptor = PubSectionData.getU8(&Offset);
NewEntry.Name = PubSectionData.getCStr(&Offset);
Y.Entries.push_back(NewEntry);
}
+
+ return Y;
}
void dumpDebugPubSections(DWARFContext &DCtx, DWARFYAML::Data &Y) {
const DWARFObject &D = DCtx.getDWARFObj();
const DWARFSection PubNames = D.getPubnamesSection();
- if (!PubNames.Data.empty()) {
- Y.PubNames.emplace(/*IsGNUStyle=*/false);
- dumpPubSection(DCtx, *Y.PubNames, PubNames);
- }
+ if (!PubNames.Data.empty())
+ Y.PubNames = dumpPubSection(DCtx, PubNames, /*IsGNUStyle=*/false);
const DWARFSection PubTypes = D.getPubtypesSection();
- if (!PubTypes.Data.empty()) {
- Y.PubTypes.emplace(/*IsGNUStyle=*/false);
- dumpPubSection(DCtx, *Y.PubTypes, PubTypes);
- }
+ if (!PubTypes.Data.empty())
+ Y.PubTypes = dumpPubSection(DCtx, PubTypes, /*IsGNUStyle=*/false);
const DWARFSection GNUPubNames = D.getGnuPubnamesSection();
- if (!GNUPubNames.Data.empty()) {
+ if (!GNUPubNames.Data.empty())
// TODO: Test dumping .debug_gnu_pubnames section.
- Y.GNUPubNames.emplace(/*IsGNUStyle=*/true);
- dumpPubSection(DCtx, *Y.GNUPubNames, GNUPubNames);
- }
+ Y.GNUPubNames = dumpPubSection(DCtx, GNUPubNames, /*IsGNUStyle=*/true);
const DWARFSection GNUPubTypes = D.getGnuPubtypesSection();
- if (!GNUPubTypes.Data.empty()) {
+ if (!GNUPubTypes.Data.empty())
// TODO: Test dumping .debug_gnu_pubtypes section.
- Y.GNUPubTypes.emplace(/*IsGNUStyle=*/true);
- dumpPubSection(DCtx, *Y.GNUPubTypes, GNUPubTypes);
- }
+ Y.GNUPubTypes = dumpPubSection(DCtx, GNUPubTypes, /*IsGNUStyle=*/true);
}
void dumpDebugInfo(DWARFContext &DCtx, DWARFYAML::Data &Y) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80861.267439.patch
Type: text/x-patch
Size: 2768 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200530/d0a836dc/attachment.bin>
More information about the llvm-commits
mailing list