[PATCH] D73086: [DWARF5] Added support for debug_macro section parsing and dumping in llvm-dwarfdump.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 18 15:25:06 PST 2020


dblaikie added inline comments.


================
Comment at: llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp:91-97
+      // Contribution of one CU finished, dump this and
+      // check if Offset is still valid, if so, start parsing/dumping
+      // debug_macro again.This is not needed for debug_macinfo section since
+      // contribution from different CU's got merged into single debug_macinfo
+      // section with macro termination sequence at the end of the section.
+      if (getVersion() >= 5)
+        return;
----------------
SouraVX wrote:
> dblaikie wrote:
> > I can't seem to make sense of this comment. Both the commend and the code seem incorrect to me - there should still be one debug_macro contribution per-CU in DWARFv5 (it'd not be possible for there to be only one across all CUs without DWARF-aware linking, which is something the DWARF spec tries very hard to not require)
> > 
> > Have you tried compiling two files with DWARFv5 debug_macro contents using your prototype patches & then looking at the result? I would expect there should be two debug_macro contributions, and that this functionality as currently commented/written would only dump one of them.
> Apologies for the confusion here, Yes I've tested the generation/ dumping using dwarfdump even with objdump rigorously.
> This work flawlessly for multipe CU case. 
> Snippet from dump taken just now 2 CU --
> ```
> .debug_macro contents:
> 0x00000000: macro header: version = 0x0005, flags = 0x02, debug_line_offset = 0x0000
> DW_MACRO_start_file - lineno: 0 filenum: 0
>   DW_MACRO_define_strp - lineno: 1 macro: BAR 4
> DW_MACRO_end_file
> DW_MACRO_define_strp - lineno: 0 macro: __llvm__ 1
> 
> 0080a: macro header: version = 0x0005, flags = 0x02, debug_line_offset = 0x0067
> DW_MACRO_start_file - lineno: 0 filenum: 0
>   DW_MACRO_define_strp - lineno: 1 macro: BAR 4
> DW_MACRO_end_file
> DW_MACRO_define_strp - lineno: 0 macro: __llvm__ 1
> ```
> I've crossed checked these macro and debug_line offsets with objdump also using same binary. matches!
OK, so this is a subtle divergence between how debug_macinfo is parsed and debug_macro is parsed, even though they share some code. With macinfo the looping happens here in this function and with macro the looping happens in the caller to this in dumpMacroSection.

Please fix this so macro and macinfo are handled in similar/the same way - both should build a single DWARFDebugMacro object representing all the contributions, then dump them together from there. (look at the way the existing macinfo support is written in DWARFContext - starting there/making the macro support similar)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73086/new/

https://reviews.llvm.org/D73086





More information about the llvm-commits mailing list