This patch refactors the DWARF section dumpers. When dumping a DWARF
section, if the DWARF parser fails to parse the section, we will dump it
as a raw content section. This patch also fixes a bug in
DWARFYAML::Data::isEmpty(). Finally, a test case that tests dumping the
__debug_aranges section is added.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/tools/obj2yaml/macho2yaml.cpp | ||
---|---|---|
29 | Probably, std::unique_ptr<MachOYAML::Object> &Y -> const MachOYAML::Object &Y | |
154 | Why not just something like the following? if (SecName == "__debug_abbrev") return dumpDebugAbbrev(DCtx, DWARF); if (SecName == "__debug_aranges") return dumpDebugARanges(DCtx, DWARF); |
Address review comments.
Thanks for reviewing!
llvm/tools/obj2yaml/macho2yaml.cpp | ||
---|---|---|
29 | Y.DWARF is modified in dumpDebugSection(), so I change it to MachOYAML::Object &Y. |
llvm/tools/obj2yaml/macho2yaml.cpp | ||
---|---|---|
153 | Perhaps we need a test for an unknown debug section to test this? |
llvm/tools/obj2yaml/macho2yaml.cpp | ||
---|---|---|
153 | The implementation of yaml2macho is buggy, we cannot specify the content of a section whose segname is __DWARF. if (Sec.segname == "__DWARF") { if (Sec.sectname == "__debug_str") Err = emitDebugStr(); else if (Sec.sectname == "__debug_info") Err = emitDebugInfo(); ... else if (Sec.sectname == "__debug_line") Err = emitDebugLine(); if (Err) return Err; continue; // Emitting the custom content is unreachable. } if (Sec.content) emitContent(); So I create a section whose segname is __FOO and sectname is __debug_foo to bypass the ec.segname == "__DWARF" checking. I also add a test case e) to test dumping a __debug_aranges section whose segname is __FOO. This is to prove that when the segname isn't __DWARF but the sectname starts with __debug_, dumpDebugSection() is still called. |
OK, thanks. This LGTM, but please hold on a bit to give other people a chance to comment too.