1# This test verifies that if a DW_TAG_compile_unit has DW_AT_ranges that 2# overlap, that it doesn't end up producing invalid errors claiming a child 3# DW_TAG_subprogram DIE is not in the parant (CU) ranges. Prior to the commit 4# that fixed this, a loop was iterating over all DW_AT_ranges for a DIE and 5# stopping the loop if any intersecting ranges were found. This would cause 6# the DW_TAG_subprogram DIEs, like "stripped2" and "main", to improperly report 7# that they were not contained in the parent's address ranges 8# 9# The DWARF looks like: 10# 0x0000000b: DW_TAG_compile_unit 11# DW_AT_name ("/tmp/main.c") 12# DW_AT_language (DW_LANG_C) 13# DW_AT_low_pc (0x0000000000000000) 14# DW_AT_ranges (0x00000000 15# [0x0000000000002000, 0x0000000000003000) 16# [0x0000000000000000, 0x0000000000000020) 17# [0x0000000000000000, 0x0000000000000030) 18# [0x0000000000001000, 0x0000000000002000)) 19# 20# 0x0000001e: DW_TAG_subprogram 21# DW_AT_name ("stripped1") 22# DW_AT_low_pc (0x0000000000000000) 23# DW_AT_high_pc (0x0000000000000020) 24# 25# 0x0000002f: DW_TAG_subprogram 26# DW_AT_name ("stripped2") 27# DW_AT_low_pc (0x0000000000000000) 28# DW_AT_high_pc (0x0000000000000030) 29# 30# 0x00000044: DW_TAG_subprogram 31# DW_AT_name ("main") 32# DW_AT_low_pc (0x0000000000001000) 33# DW_AT_high_pc (0x0000000000002000) 34# 35# 0x00000055: DW_TAG_subprogram 36# DW_AT_name ("foo") 37# DW_AT_low_pc (0x0000000000002000) 38# DW_AT_high_pc (0x0000000000003000) 39# 40# 0x00000066: NULL 41 42# RUN: yaml2obj %s | not llvm-dwarfdump --verify - | FileCheck %s --implicit-check-not=error: 43 44# CHECK: error: DIE has overlapping ranges in DW_AT_ranges attribute: [0x0000000000000000, 0x0000000000000020) and [0x0000000000000000, 0x0000000000000030) 45 46# CHECK: 0x0000000b: DW_TAG_compile_unit 47# CHECK-NEXT: DW_AT_name ("/tmp/main.c") 48# CHECK-NEXT: DW_AT_language (DW_LANG_C) 49# CHECK-NEXT: DW_AT_low_pc (0x0000000000000000) 50# CHECK-NEXT: DW_AT_ranges (0x00000000 51# CHECK-NEXT: [0x0000000000002000, 0x0000000000003000) 52# CHECK-NEXT: [0x0000000000000000, 0x0000000000000020) 53# CHECK-NEXT: [0x0000000000000000, 0x0000000000000030) 54# CHECK-NEXT: [0x0000000000001000, 0x0000000000002000)) 55 56# CHECK: error: DIEs have overlapping address ranges: 57# CHECK: 0x0000002f: DW_TAG_subprogram 58# CHECK-NEXT: DW_AT_name ("stripped2") 59# CHECK-NEXT: DW_AT_low_pc (0x0000000000000000) 60# CHECK-NEXT: DW_AT_high_pc (0x0000000000000030) 61 62# CHECK: 0x0000001e: DW_TAG_subprogram 63# CHECK-NEXT: DW_AT_name ("stripped1") 64# CHECK-NEXT: DW_AT_low_pc (0x0000000000000000) 65# CHECK-NEXT: DW_AT_high_pc (0x0000000000000020) 66 67# CHECK: Verifying .debug_info references... 68 69--- !mach-o 70FileHeader: 71 magic: 0xFEEDFACF 72 cputype: 0x01000007 73 cpusubtype: 0x00000003 74 filetype: 0x00000001 75 ncmds: 4 76 sizeofcmds: 464 77 flags: 0x00002000 78 reserved: 0x00000000 79LoadCommands: 80 - cmd: LC_SEGMENT_64 81 cmdsize: 392 82 segname: '' 83 vmaddr: 0 84 vmsize: 261 85 fileoff: 528 86 filesize: 261 87 maxprot: 7 88 initprot: 7 89 nsects: 4 90 flags: 0 91 Sections: 92 - sectname: __debug_abbrev 93 segname: __DWARF 94 addr: 0x0000000000000000 95 size: 36 96 offset: 0x00000210 97 align: 0 98 reloff: 0x00000000 99 nreloc: 0 100 flags: 0x00000000 101 reserved1: 0x00000000 102 reserved2: 0x00000000 103 reserved3: 0x00000000 104 - sectname: __debug_info 105 segname: __DWARF 106 addr: 0x0000000000000024 107 size: 103 108 offset: 0x00000234 109 align: 0 110 reloff: 0x00000000 111 nreloc: 0 112 flags: 0x00000000 113 reserved1: 0x00000000 114 reserved2: 0x00000000 115 reserved3: 0x00000000 116 - sectname: __debug_ranges 117 segname: __DWARF 118 addr: 0x000000000000008B 119 size: 80 120 offset: 0x0000029B 121 align: 0 122 reloff: 0x00000000 123 nreloc: 0 124 flags: 0x00000000 125 reserved1: 0x00000000 126 reserved2: 0x00000000 127 reserved3: 0x00000000 128 - sectname: __debug_str 129 segname: __DWARF 130 addr: 0x00000000000000DB 131 size: 42 132 offset: 0x000002EB 133 align: 0 134 reloff: 0x00000000 135 nreloc: 0 136 flags: 0x00000000 137 reserved1: 0x00000000 138 reserved2: 0x00000000 139 reserved3: 0x00000000 140 - cmd: LC_SYMTAB 141 cmdsize: 24 142 symoff: 0 143 nsyms: 0 144 stroff: 792 145 strsize: 8 146 - cmd: LC_BUILD_VERSION 147 cmdsize: 32 148 platform: 1 149 minos: 658944 150 sdk: 658944 151 ntools: 1 152 Tools: 153 - tool: 3 154 version: 34734080 155 - cmd: LC_DATA_IN_CODE 156 cmdsize: 16 157 dataoff: 792 158 datasize: 0 159LinkEditData: 160 StringTable: 161 - ' ' 162 - '' 163 - '' 164 - '' 165 - '' 166 - '' 167 - '' 168DWARF: 169 debug_str: 170 - '' 171 - '/tmp/main.c' 172 - stripped1 173 - stripped2 174 - main 175 - foo 176 debug_abbrev: 177 - Table: 178 - Code: 0x00000001 179 Tag: DW_TAG_compile_unit 180 Children: DW_CHILDREN_yes 181 Attributes: 182 - Attribute: DW_AT_name 183 Form: DW_FORM_strp 184 - Attribute: DW_AT_language 185 Form: DW_FORM_data2 186 - Attribute: DW_AT_low_pc 187 Form: DW_FORM_addr 188 - Attribute: DW_AT_ranges 189 Form: DW_FORM_sec_offset 190 - Code: 0x00000002 191 Tag: DW_TAG_subprogram 192 Children: DW_CHILDREN_no 193 Attributes: 194 - Attribute: DW_AT_name 195 Form: DW_FORM_strp 196 - Attribute: DW_AT_low_pc 197 Form: DW_FORM_addr 198 - Attribute: DW_AT_high_pc 199 Form: DW_FORM_data4 200 - Code: 0x00000003 201 Tag: DW_TAG_subprogram 202 Children: DW_CHILDREN_no 203 Attributes: 204 - Attribute: DW_AT_name 205 Form: DW_FORM_strp 206 - Attribute: DW_AT_low_pc 207 Form: DW_FORM_addr 208 - Attribute: DW_AT_high_pc 209 Form: DW_FORM_addr 210 debug_ranges: 211 - Offset: 0x00000000 212 AddrSize: 0x08 213 Entries: 214 - LowOffset: 0x0000000000002000 215 HighOffset: 0x0000000000003000 216 - LowOffset: 0x0000000000000000 217 HighOffset: 0x0000000000000020 218 - LowOffset: 0x0000000000000000 219 HighOffset: 0x0000000000000030 220 - LowOffset: 0x0000000000001000 221 HighOffset: 0x0000000000002000 222 debug_info: 223 - Version: 4 224 AddrSize: 8 225 Entries: 226 - AbbrCode: 0x00000001 227 Values: 228 - Value: 0x0000000000000001 229 - Value: 0x0000000000000002 230 - Value: 0x0000000000000000 231 - Value: 0x0000000000000000 232 - AbbrCode: 0x00000002 233 Values: 234 - Value: 0x000000000000000D 235 - Value: 0x0000000000000000 236 - Value: 0x0000000000000020 237 - AbbrCode: 0x00000003 238 Values: 239 - Value: 0x0000000000000017 240 - Value: 0x0000000000000000 241 - Value: 0x0000000000000030 242 - AbbrCode: 0x00000002 243 Values: 244 - Value: 0x0000000000000021 245 - Value: 0x0000000000001000 246 - Value: 0x0000000000001000 247 - AbbrCode: 0x00000002 248 Values: 249 - Value: 0x0000000000000026 250 - Value: 0x0000000000002000 251 - Value: 0x0000000000001000 252 - AbbrCode: 0x00000000 253... 254