[PATCH] D51081: [DWARF v5] Refactoring range list dumping to fold DWARF v4 functionality into v5 handling (almost NFC).

Wolfgang Pieb via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 21 18:18:01 PDT 2018


wolfgangp created this revision.
wolfgangp added reviewers: aprantl, dblaikie, JDevlieghere, jhenderson, vleschuk.
Herald added a subscriber: mgorny.
Herald added a reviewer: javed.absar.

This patch is motivated by the following observations:

- DWARF 4 rangelists are essentially a subset of DWARF 5 rangelists.
- We implemented DWARF5 largely independently (the consumer side, i.e. mostly llvm-dwarfdump). The DWARF 5 implementations are in DWARFDebugRnglists.*, the DWARF 4 implementations in DWARFDebugRangelists.* with a fair amount of duplication.

So I thought it should be possible to fold the DWARF 4 functionality into the newly implemented DWARF 5 functionality so that, at the expense of a bit more version-dependent code in dump and extract routines, we should be able to eliminate the DWARF4-only code (i.e. DWARFDebugRangeList.*) entirely.

This patch does attempt this in the following way:

- DWARF5 has range list tables, which of course don't exist in DWARF4, so for DWARF 4 (i.e. when we are extracting range lists from the .debug_ranges section) we create a fake table so we can use the same mechanisms as in DWARF 5.

- The extract and dump routines become version-aware so they can do what's expected both for DWARF4 and DWARF5.

The code in DWARFContext.cpp, DWARFUnit.cpp that arbiters between the different versions now just needs to set up the extractors correctly, set the correct section and pass the DWARF version, and should otherwise be version-oblivious to deal with ranges.

This is also prep for location list dumping, where it's possible to do the same thing, i.e. express DWARF4 functionality as a special case of DWARF5. This is why two routines in DWARFUnit.cpp that deal with the setup of range list tables are now templatized, so they can be used for location list tables as well.

One thing to note is that this change is almost, but not quite NFC. The difference is the following: In DWARF4 the range list table in .debug_ranges is dumped with the list offset preceding the entries:

  00000000 00000000 0000abcd
  00000000 ffffffff 0000deaf
  00000000 00000010 00000020

etc. with the leading '00000000' being the list's section offset, which is repeated for every entry.
I didn't find this particularly useful, so the refactor now displays the list with the correct section offset for each entry, with the list offset simply being the first entry's offset.

  00000000 00000000 0000abcd
  00000008 ffffffff 0000deaf
  00000010 00000010 00000020

Apologies for the size of the patch, but this will make the changes for location list dumping smaller.


https://reviews.llvm.org/D51081

Files:
  include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
  include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h
  include/llvm/DebugInfo/DWARF/DWARFListTable.h
  include/llvm/DebugInfo/DWARF/DWARFUnit.h
  lib/DebugInfo/DWARF/CMakeLists.txt
  lib/DebugInfo/DWARF/DWARFContext.cpp
  lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
  lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp
  lib/DebugInfo/DWARF/DWARFDie.cpp
  lib/DebugInfo/DWARF/DWARFListTable.cpp
  lib/DebugInfo/DWARF/DWARFUnit.cpp
  test/DebugInfo/Generic/cu-ranges.ll
  test/DebugInfo/Inputs/gmlt.ll
  test/DebugInfo/X86/dwarfdump-ranges-unrelocated.s
  test/DebugInfo/dwarfdump-ranges.test
  test/MC/ARM/dwarf-asm-multiple-sections.s
  tools/dsymutil/DwarfLinker.cpp
  tools/dsymutil/DwarfStreamer.cpp
  tools/dsymutil/DwarfStreamer.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51081.161862.patch
Type: text/x-patch
Size: 56187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180822/9a157f80/attachment.bin>


More information about the llvm-commits mailing list