[PATCH] D28828: [DWARF] [ObjectYAML] Adding APIs for unittesting

Chris Bieneman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 18 13:48:52 PST 2017

beanz added inline comments.

Comment at: lib/DebugInfo/DWARF/DWARFContext.cpp:819-851
+    StringRef *SectionData =
+        StringSwitch<StringRef *>(SecIt.first())
+            .Case("debug_info", &InfoSection.Data)
+            .Case("debug_abbrev", &AbbrevSection)
+            .Case("debug_loc", &LocSection.Data)
+            .Case("debug_line", &LineSection.Data)
+            .Case("debug_aranges", &ARangeSection)
dblaikie wrote:
> Looks like a duplicate of the StringSwitch in the other ctor - could be refactored to a common utility function?
Yep, will do.

Comment at: lib/ObjectYAML/DWARFEmitter.cpp:356-358
+  YIn >> DI;
+  if (YIn.error())
+    return DebugSections;
dblaikie wrote:
> Should this perhaps return ErrorOr<StringMap<...>> & so the error can be propagated/reported?
Will do.

Comment at: lib/ObjectYAML/DWARFEmitter.cpp:360-369
+  EmitDebugSectionImpl(DI, &DWARFYAML::EmitDebugInfo, "debug_info",
+                       DebugSections);
+  EmitDebugSectionImpl(DI, &DWARFYAML::EmitDebugLine, "debug_line",
+                       DebugSections);
+  EmitDebugSectionImpl(DI, &DWARFYAML::EmitDebugStr, "debug_str",
+                       DebugSections);
+  EmitDebugSectionImpl(DI, &DWARFYAML::EmitDebugAbbrev, "debug_abbrev",
dblaikie wrote:
> These are the supported sections at the moment - but I guess it'll grow support over time? Any way to refactor this so it goes along with the support as it's added? (is there similar code elsewhere already doing something like this to generate all the outputs in yaml2obj?)
Yes, I expect this to grow over time. Because the order and way in which debug sections are emitted can vary between object files there is no duplication of this in yaml2obj that would make sense to remove.


More information about the llvm-commits mailing list