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

Greg Clayton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 20 16:56:38 PDT 2022


clayborg created this revision.
clayborg added reviewers: labath, JDevlieghere, yinghuitan, echristo, dblaikie.
Herald added subscribers: cmtice, hiraditya.
Herald added a reviewer: jhenderson.
Herald added a project: All.
clayborg requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

.debug_aranges is a DWARF index that maps addresses back to compile units. This index should contain a full list of address ranges for the compile unit. This fix verifies:

- If the DW_TAG_compile_unit has a DW_AT_ranges or a DW_AT_low_pc/DW_AT_high_pc:
  - all addresses from a DW_TAG_compile_unit's DW_AT_ranges are contained in the .debug_aranges index
  - all address ranges from the .debug_aranges for a compile unit are contained in the DW_AT_ranges of the DW_TAG_compile_unit
- if the DW_TAG_compile_unit doesn't have a DW_AT_ranges or a DW__AT_low_pc/DW_AT_high_pc:
  - verify all ranges from any DW_TAG_subprogram DIEs are all contained in the .debug_aranges.
- Run through all .debug_line line table entries from each compile unit and make sure that the .debug_aranges contains ranges for any row addresses and also verify if the CU DW_AT_ranges/low/high pc or subprogram ranges contain the address.

Below are example errors.

When a compile unit has a DW_AT_ranges or DW_AT_low_pc/high_pc that isn't in the .debug_aranges data for that compile unit:

  error: .debug_aranges[0x00000000] compile unit range [0x0000000000001000 - 0x0000000000002000) not in .debug_aranges.

When the .debug_aranges has a range that isn't in the compile unit's has a DW_AT_ranges or DW_AT_low_pc/high_pc:

  error: .debug_aranges[0x00000000][1] range [0x0000000000010000 - 0x0000000000011000) not in compile unit @ 0x00000000 ranges.

When the .debug_aranges has a range that isn't in any of the compile unit's DW_TAG_subprogram's ranges and the compile unit has no DW_AT_ranges or DW_AT_low_pc/high_pc:

  error: .debug_aranges[0x00000000][1] range [0x0000000000010000 - 0x0000000000011000) not in compile unit @ 0x00000000 subprogram ranges.

When we have line table rows that have addresses that don't exist in the .debug_aranges and/or the compile unit's ranges:

  error: .debug_aranges[0x00000000] compile unit @ 0x00000000 line table sequence [0-2) has row[1] with address 0x0000000000002010 that is not in .debug_aranges nor in compile unit subprogram ranges.
  error: .debug_aranges[0x00000000] compile unit @ 0x00000000 line table sequence [0-2) has row[1] with address 0x0000000000002010 that is not in .debug_aranges nor in compile unit ranges.
  error: .debug_aranges[0x00000000] compile unit @ 0x00000000 line table sequence [0-2) has row[1] with address 0x0000000000002010 that is not in .debug_aranges.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136395

Files:
  llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/test/tools/llvm-dwarfdump/X86/verify_debug_aranges_cu_range_missing.yaml
  llvm/test/tools/llvm-dwarfdump/X86/verify_debug_aranges_line_row_not_in_aranges.yaml
  llvm/test/tools/llvm-dwarfdump/X86/verify_debug_aranges_line_row_not_in_aranges_or_cu_ranges.yaml
  llvm/test/tools/llvm-dwarfdump/X86/verify_debug_aranges_line_row_not_in_aranges_or_cu_subprogram.yaml
  llvm/test/tools/llvm-dwarfdump/X86/verify_debug_aranges_missing_cu_range.yaml
  llvm/test/tools/llvm-dwarfdump/X86/verify_debug_aranges_missing_cu_subprogram.yaml

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136395.469412.patch
Type: text/x-patch
Size: 40522 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221020/355d7354/attachment-0001.bin>


More information about the llvm-commits mailing list