|
| 1 | +#--- comments.txt |
| 2 | + |
| 3 | +# This test verifies several scenarios with DW_TAG_subprogram address ranges: |
| 4 | +# 1. Two subprograms can have identical ranges (shown with foo2 and foo3 having same low_pc/high_pc) |
| 5 | +# This is valid and can happen when ICF (Identical Code Folding) merges functions. |
| 6 | +# 2. Two subprograms can have overlapping ranges when using DW_AT_ranges |
| 7 | +# (shown with func1_with_ranges and func2_with_ranges sharing range 0x5000-0x6000) |
| 8 | +# This is also valid and can occur with -fbasic-block-sections=all |
| 9 | +# 3. The test also verifies that non-identical overlapping ranges are correctly flagged as errors: |
| 10 | +# - When modifying just the first range's high offset from 0x6000 to 0x5999, it creates an invalid subrange overlap |
| 11 | +# - When modifying just the first instance of DW_AT_high_pc 0x77 to 0x66, it creates an invalid function overlap |
| 12 | +# The test ensures llvm-dwarfdump --verify correctly validates these cases by: |
| 13 | +# a) Accepting valid identical overlapping ranges |
| 14 | +# b) Rejecting invalid non-identical overlapping ranges |
| 15 | + |
| 16 | +# Need to use split-file in order for `sed` calls below to work correctly |
| 17 | +# RUN: split-file %s %t |
| 18 | +# RUN: yaml2obj %t/test.yaml | llvm-dwarfdump --error-display=details --verify - | FileCheck %s |
| 19 | +# CHECK: No errors. |
| 20 | + |
| 21 | +# RUN: sed -e '1,/HighOffset: 0x6000/s/HighOffset: 0x6000/HighOffset: 0x5999/' %t/test.yaml | yaml2obj | not llvm-dwarfdump --error-display=details --verify - | FileCheck %s --check-prefix=CHECK-RANGES |
| 22 | +# CHECK-RANGES: error: DIEs have overlapping address ranges |
| 23 | + |
| 24 | +# RUN: sed -e '1,/Value: 0x77/s/Value: 0x77/Value: 0x66/' %t/test.yaml | yaml2obj | not llvm-dwarfdump --error-display=details --verify - | FileCheck %s --check-prefix=CHECK-HIGH-PC |
| 25 | +# CHECK-HIGH-PC: error: DIEs have overlapping address ranges |
| 26 | + |
| 27 | +# RUN: sed -e '1,/LowOffset: 0x880111/s/LowOffset: 0x880111/LowOffset: 0x880112/' %t/test.yaml | yaml2obj | not llvm-dwarfdump --error-display=details --verify - | FileCheck %s --check-prefix=CHECK-LEX-BLOCK |
| 28 | +# CHECK-LEX-BLOCK: DIE has overlapping ranges in DW_AT_ranges attribute |
| 29 | + |
| 30 | +#--- test.yaml |
| 31 | +--- !ELF |
| 32 | +FileHeader: |
| 33 | + Class: ELFCLASS64 |
| 34 | + Data: ELFDATA2LSB |
| 35 | + Type: ET_REL |
| 36 | + Machine: EM_X86_64 |
| 37 | +DWARF: |
| 38 | + debug_abbrev: |
| 39 | + - Table: |
| 40 | + - Tag: DW_TAG_compile_unit |
| 41 | + Children: DW_CHILDREN_yes |
| 42 | + Attributes: |
| 43 | + - Attribute: DW_AT_producer |
| 44 | + Form: DW_FORM_string |
| 45 | + - Attribute: DW_AT_language |
| 46 | + Form: DW_FORM_data2 |
| 47 | + - Attribute: DW_AT_name |
| 48 | + Form: DW_FORM_string |
| 49 | + - Attribute: DW_AT_low_pc |
| 50 | + Form: DW_FORM_addr |
| 51 | + - Attribute: DW_AT_high_pc |
| 52 | + Form: DW_FORM_data8 |
| 53 | + - Tag: DW_TAG_subprogram |
| 54 | + Children: DW_CHILDREN_no |
| 55 | + Attributes: |
| 56 | + - Attribute: DW_AT_name |
| 57 | + Form: DW_FORM_string |
| 58 | + - Attribute: DW_AT_low_pc |
| 59 | + Form: DW_FORM_addr |
| 60 | + - Attribute: DW_AT_high_pc |
| 61 | + Form: DW_FORM_data8 |
| 62 | + - Tag: DW_TAG_subprogram |
| 63 | + Children: DW_CHILDREN_no |
| 64 | + Attributes: |
| 65 | + - Attribute: DW_AT_name |
| 66 | + Form: DW_FORM_string |
| 67 | + - Attribute: DW_AT_ranges |
| 68 | + Form: DW_FORM_sec_offset |
| 69 | + - Tag: DW_TAG_base_type |
| 70 | + Children: DW_CHILDREN_no |
| 71 | + Attributes: |
| 72 | + - Attribute: DW_AT_name |
| 73 | + Form: DW_FORM_string |
| 74 | + - Tag: DW_TAG_lexical_block |
| 75 | + Children: DW_CHILDREN_no |
| 76 | + Attributes: |
| 77 | + - Attribute: DW_AT_ranges |
| 78 | + Form: DW_FORM_sec_offset |
| 79 | + debug_ranges: |
| 80 | + - Offset: 0x0 |
| 81 | + AddrSize: 0x8 |
| 82 | + Entries: |
| 83 | + - LowOffset: 0x1000 |
| 84 | + HighOffset: 0x2000 |
| 85 | + - LowOffset: 0x3000 |
| 86 | + HighOffset: 0x4000 |
| 87 | + - LowOffset: 0x5000 # Overlaps with 2nd range below |
| 88 | + HighOffset: 0x6000 |
| 89 | + - LowOffset: 0x0 |
| 90 | + HighOffset: 0x0 |
| 91 | + - Offset: 0x50 |
| 92 | + AddrSize: 0x8 |
| 93 | + Entries: |
| 94 | + - LowOffset: 0x2500 |
| 95 | + HighOffset: 0x2800 |
| 96 | + - LowOffset: 0x5000 # Overlaps with 3rd range above |
| 97 | + HighOffset: 0x6000 |
| 98 | + - LowOffset: 0x7000 |
| 99 | + HighOffset: 0x8000 |
| 100 | + - LowOffset: 0x0 |
| 101 | + HighOffset: 0x0 |
| 102 | + - Offset: 0xA0 # Added Range List #3 for lexical block |
| 103 | + AddrSize: 0x8 |
| 104 | + Entries: |
| 105 | + - LowOffset: 0x880111 |
| 106 | + HighOffset: 0x881222 |
| 107 | + - LowOffset: 0x882333 |
| 108 | + HighOffset: 0x883444 |
| 109 | + - LowOffset: 0x880111 # Overlaps with 1st range in the same list |
| 110 | + HighOffset: 0x881222 |
| 111 | + - LowOffset: 0x0 # End of list |
| 112 | + HighOffset: 0x0 |
| 113 | + debug_info: |
| 114 | + - Version: 4 |
| 115 | + Entries: |
| 116 | + - AbbrCode: 1 |
| 117 | + Values: |
| 118 | + - CStr: by_hand |
| 119 | + - Value: 0x04 |
| 120 | + - CStr: CU1 |
| 121 | + - Value: 0x1000 |
| 122 | + - Value: 0x100 |
| 123 | + - AbbrCode: 4 |
| 124 | + Values: |
| 125 | + - CStr: int |
| 126 | + - AbbrCode: 2 |
| 127 | + Values: |
| 128 | + - CStr: foo1 |
| 129 | + - Value: 0x1000 |
| 130 | + - Value: 0x10 |
| 131 | + - AbbrCode: 2 |
| 132 | + Values: |
| 133 | + - CStr: foo2 |
| 134 | + - Value: 0x0 # Overlaps with 'foo3' below |
| 135 | + - Value: 0x77 |
| 136 | + - AbbrCode: 2 |
| 137 | + Values: |
| 138 | + - CStr: foo3 |
| 139 | + - Value: 0x0 # Overlaps with 'foo2' above |
| 140 | + - Value: 0x77 |
| 141 | + - AbbrCode: 3 |
| 142 | + Values: |
| 143 | + - CStr: func1_with_ranges |
| 144 | + - Value: 0x0 |
| 145 | + - AbbrCode: 3 |
| 146 | + Values: |
| 147 | + - CStr: func2_with_ranges |
| 148 | + - Value: 0x50 |
| 149 | + - AbbrCode: 5 # Added lexical block using ranges |
| 150 | + Values: |
| 151 | + - Value: 0xA0 # Range list index in debug_ranges |
| 152 | + - AbbrCode: 0 |
| 153 | +... |
0 commit comments