## This test checks that .debug_rnglists table correclty handled
## and transformed into the DW_FORM_sec_offset form in case
## --no-update. Or correctly preservedi in --update case.
## cat dwarf5-rnglists.c
##
## #include <stdio.h>
##
## int g1;
##
## int main ( int argv, char** argc ) {
##
## if ( argv > 10 ) {
## volatile int a = 0x4;
##
## if ( g1 ) {
## volatile int b = 0;
## return b;
## }
##
## volatile int c = 7;
## } else if ( g1 ) {
## volatile int a = 0x5;
## }
##
## return 0;
## }
## $ clang -gdwarf-5 dwarf5-rnglists.c -c -O2 -o dwarf5-rnglists.o
## $ clang -gdwarf-5 dwarf5-rnglists.o -o dwarf5-rnglists
#RUN: dsymutil -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix DWARF-CHECK
#RUN: dsymutil --update -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix UPD-DWARF-CHECK
#RUN: dsymutil --linker parallel -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix DWARF-CHECK
#RUN: dsymutil --linker parallel --update -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix UPD-DWARF-CHECK
#CHECK: No errors.
#DWARF-CHECK: DW_TAG_compile_unit
#DWARF-CHECK: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008)
#DWARF-CHECK: DW_TAG_lexical_block
#DWARF-CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x0000000c
#DWARF-CHECK: [0x0000000100000f79, 0x0000000100000f96)
#DWARF-CHECK: [0x0000000100000fad, 0x0000000100000fb4))
#DWARF-CHECK: .debug_rnglists contents:
#DWARF-CHECK: 0x00000000: range list header: length = 0x00000011, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
#DWARF-CHECK: ranges:
#DWARF-CHECK: 0x0000000c: [DW_RLE_base_addressx]: 0x0000000000000003
#DWARF-CHECK: 0x0000000e: [DW_RLE_offset_pair ]: 0x0000000000000000, 0x000000000000001d
#DWARF-CHECK: 0x00000011: [DW_RLE_offset_pair ]: 0x0000000000000034, 0x000000000000003b
#DWARF-CHECK: 0x00000014: [DW_RLE_end_of_list ]
#
#UPD-DWARF-CHECK: DW_TAG_compile_unit
#UPD-DWARF-CHECK: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008)
#UPD-DWARF-CHECK: DW_TAG_lexical_block
#UPD-DWARF-CHECK: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000010
#UPD-DWARF-CHECK: [0x0000000000000009, 0x0000000000000026)
#UPD-DWARF-CHECK: [0x000000000000003d, 0x0000000000000044))
#UPD-DWARF-CHECK: .debug_addr contents:
#UPD-DWARF-CHECK: 0x00000000: Address table header: length = 0x00000024, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00
#UPD-DWARF-CHECK: Addrs: [
#UPD-DWARF-CHECK: 0x0000000000000000
#UPD-DWARF-CHECK: 0x0000000000000000
#UPD-DWARF-CHECK: 0x000000000000001c
#UPD-DWARF-CHECK: 0x0000000000000034
#UPD-DWARF-CHECK: ]
#UPD-DWARF-CHECK: .debug_rnglists contents:
#UPD-DWARF-CHECK: 0x00000000: range list header: length = 0x00000013, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000001
#UPD-DWARF-CHECK: offsets: [
#UPD-DWARF-CHECK: 0x00000004 => 0x00000010
#UPD-DWARF-CHECK: ]
#UPD-DWARF-CHECK: ranges:
#UPD-DWARF-CHECK: 0x00000010: [DW_RLE_offset_pair]: 0x0000000000000009, 0x0000000000000026 => [0x0000000000000009, 0x0000000000000026)
#UPD-DWARF-CHECK: 0x00000013: [DW_RLE_offset_pair]: 0x000000000000003d, 0x0000000000000044 => [0x000000000000003d, 0x0000000000000044)
#UPD-DWARF-CHECK: 0x00000016: [DW_RLE_end_of_list]
---
triple: 'x86_64-apple-darwin'
objects:
- filename: 'dwarf5-rnglists.o'
timestamp: 1676048242
symbols:
- { sym: _main, objAddr: 0x0, binAddr: 0x100000F70, size: 0x48 }
- { sym: _g1, binAddr: 0x100001000, size: 0x0 }