[PATCH] D79962: Fix the verification of DIEs with DW_AT_ranges.

Greg Clayton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 14 19:03:24 PDT 2020


clayborg marked 2 inline comments as done.
clayborg added a comment.

In D79962#2037671 <https://reviews.llvm.org/D79962#2037671>, @dblaikie wrote:

> I'm not able to understand the description of the original bug, perhaps you could show the original behavior for your test case for comparison?


I will improve the description and improve the test to include some checks to make sure something is not there.

Basically if the DW_TAG_compile_unit had a DW_AT_ranges that had overlapping ranges, there was a break statement that would stop it from gathering all of the valid ranges for the compile unit. Then and DIEs whose address ranges didn't get added to the CU's ranges would emit an error. Here is a real example with some names changed:

  error: DIE has overlapping address ranges: [0x0000000000000000, 0x0000000000000008) and [0x0000000000000000, 0x000000000000001e)
  error: DIE address ranges are not contained in its parent's ranges:
  0x0002022e: DW_TAG_compile_unit
                DW_AT_producer	("...")
                DW_AT_language	(DW_LANG_C_plus_plus)
                DW_AT_name	("...")
                DW_AT_stmt_list	(0x00004f60)
                DW_AT_comp_dir	(".")
                DW_AT_GNU_pubnames	(true)
                DW_AT_low_pc	(0x0000000000000000)
                DW_AT_ranges	(0x000010b0
                   [0x000045c4, 0x000045e8)
                   [0x00000000, 0x0000001e)
                   [0x00000000, 0x00000008)
                   [0x000049bc, 0x000049c0)
                   [0x000049c0, 0x00004a08)
                   [0x00004a08, 0x00004a0e))
  
  0x0002f1f1:   DW_TAG_subprogram
                  DW_AT_low_pc	(0x00000000000049c0)
                  DW_AT_high_pc	(0x0000000000004a08)
                  DW_AT_frame_base	(DW_OP_reg13)
                  DW_AT_object_pointer	(0x0002f214)
                  DW_AT_linkage_name	("_ZNSt12__shared_ptr...")
                  DW_AT_specification	(0x00022eef)

But note that this range [0x49c0-0x4a08) IS in the DW_AT_ranges of the CU. So even if there are overlapping address ranges, we need to report them all and then shoe the DIE. I also modified the warning message to let you know that there are ovarlapping DW_AT_ranges in a DIE to make this more clear what is overlapping. So this diff is fixing this incorrect error reporting for "DIE address ranges are not contained in its parent's ranges".



================
Comment at: llvm/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h:58
+  /// ranges were combined.
+  bool union_range(const DWARFAddressRange &RHS) {
+    if (!intersects(RHS))
----------------
dblaikie wrote:
> Probably could use a more explicit name - "union_if_intersecting"?
that works


================
Comment at: llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp:420
+      // more dead stripped address ranges which tend to all be at the same
+      // address: 0 or -1.
+      if (auto PrevRange = RI.insert(Range)) {
----------------
dblaikie wrote:
> Where have you seen -1? Both gold and lld use 0, binutils ld... is more complicated, but I don't think it uses -1? hmm, maybe it does... hmm, at least for ranges it uses 1:  [0x0000000000000001, 0x0000000000000001) which is different from gold and lld but for the address it uses zero:
> 
>                 DW_AT_low_pc    (0x0000000000000000)
>                 DW_AT_high_pc   (0x0000000000000006)
> 
> 
I believe Paul Robinson stated that the Sony linker does this. Paul did I remember correctly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79962





More information about the llvm-commits mailing list