[PATCH] D136395: Add the ability to verify the .debug_aranges section.

Alexander Yermolovich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 31 14:09:31 PDT 2022


ayermolo added a comment.

OK, Got to the bottom of this.
To refresh memory this is for these two types of verify errors:
error: .debug_aranges[0x00000000] compile unit range [0x0000000000000600 - 0x000000000000063f) not in .debug_aranges.
error: .debug_aranges[0x00000000] compile unit @ 0x00000000 line table sequence [0-5) has row[0] with address 0x0000000000000600 that is not in .debug_aranges.

The binary was build with -g1 and debug info profiling is not enabled.
When machine function is processed things diverge here:
https://github.com/llvm/llvm-project/blob/a3a9fffea1bfd14ea509007cbf4f9fdb4d602c7c/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp#L2223

For ones that have Abstract Scopes it fall through creates a DIE and aranges entry. For others it just adds it to the ranges in CU.

So should it always add to aranges?

Repurposed one of the tests

  namespace test {
   extern int a;
  }
  using test::a;
  int GlobalConst = 42;
  int Global;
  struct S {
    static const int constant = 24;
    int (*fn)(int);
  } s;
  int __attribute__((always_inline)) square(int i) { return i * i; }
  int cube(int i) {
    int squared = square(i);
    return squared*i;
  }
  
  int main(){
    return 0;
  }



  0x0000000b: DW_TAG_compile_unit [1] *
                DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000000] = "clang version 16.0.0")
                DW_AT_language [DW_FORM_data2]  (DW_LANG_C_plus_plus_14)
                DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000086] = "example.cpp")
                DW_AT_stmt_list [DW_FORM_sec_offset]  (0x00000000)
                DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x00000092] = "examples")
                DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
                DW_AT_ranges [DW_FORM_sec_offset] (0x00000000
                   [0x0000000000000600, 0x0000000000000610)
                   [0x0000000000000610, 0x0000000000000630)
                   [0x0000000000000630, 0x000000000000063f))
  
  0x0000002a:   DW_TAG_subprogram [2]   (0x0000000b)
                  DW_AT_name [DW_FORM_strp] ( .debug_str[0x000000c1] = "square")
                  DW_AT_inline [DW_FORM_data1]  (DW_INL_inlined)
  
  0x00000030:   DW_TAG_subprogram [3] * (0x0000000b)
                  DW_AT_low_pc [DW_FORM_addr] (0x0000000000000610)
                  DW_AT_high_pc [DW_FORM_data4] (0x00000020)
                  DW_AT_name [DW_FORM_strp] ( .debug_str[0x000000c8] = "cube")
  
  0x00000041:     DW_TAG_inlined_subroutine [4]   (0x00000030)
                    DW_AT_abstract_origin [DW_FORM_ref4]  (cu + 0x002a => {0x0000002a} "square")
                    DW_AT_low_pc [DW_FORM_addr] (0x000000000000061d)
                    DW_AT_high_pc [DW_FORM_data4] (0x00000007)
                    DW_AT_call_file [DW_FORM_data1] ("example.cpp")
                    DW_AT_call_line [DW_FORM_data1] (13)
                    DW_AT_call_column [DW_FORM_data1] (0x11)
  
  0x00000055:     NULL
  
  0x00000056:   NULL



> .debug_aranges contents:
> Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00
> [0x0000000000000610, 0x0000000000000630)




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136395



More information about the llvm-commits mailing list