xref: /llvm-project/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/odr-recursive-dependence.test (revision f1fdfe6888f93b9f6dfb4689e1f3206de584ff5b)
1## This test checks output of dsymutil for the incorrect DWARF.
2## CU1 has a type which references type in CU2. This referenced
3## type references the same type in CU1 back. There is a recursive
4## dependence between these two types. dsymutil should report a error,
5## remove CU1 and CU2, put only CU3 into the output.
6
7# RUN: yaml2obj %s -o %t.o
8# RUN: echo '---' > %t2.map
9# RUN: echo "triple:          'x86_64-apple-darwin'" >> %t2.map
10# RUN: echo 'objects:'  >> %t2.map
11# RUN: echo " -  filename: '%t.o'" >> %t2.map
12# RUN: echo '    symbols:' >> %t2.map
13# RUN: echo '      - { sym: __Z3foov, objAddr: 0x0, binAddr: 0x10000, size: 0x10 }' >> %t2.map
14# RUN: echo '...' >> %t2.map
15# RUN: dsymutil --linker parallel -y %t2.map --num-threads 1 -f -o %t1.out 2>&1 \
16# RUN:   | FileCheck --check-prefix ERROR %s
17# RUN: llvm-dwarfdump -a %t1.out | FileCheck %s
18
19# ERROR: error: Cann't parse input DWARF. Recursive dependence.
20# ERROR: while processing CU1
21# ERROR: error: Cann't resolve DIE reference
22# ERROR: while processing CU2
23
24# CHECK: file format Mach-O 64-bit x86-64
25# CHECK: .debug_info contents:
26# CHECK: Compile Unit:
27# CHECK: DW_TAG_compile_unit
28# CHECK: DW_AT_name{{.*}}"__artificial_type_unit"
29# CHECK: 0x[[CLASS1:[0-9a-f]*]]: DW_TAG_class_type{{.*[[:space:]].*}}DW_AT_name{{.*}}"class1"
30
31# CHECK: Compile Unit:
32# CHECK: DW_TAG_compile_unit
33# CHECK-NOT: "CU1"
34# CHECK-NOT: "CU2"
35# CHECK: DW_AT_name{{.*}}"CU3"
36# CHECK-NOT: DW_TAG_class_type
37# CHECK: DW_TAG_variable
38# CHECK: DW_AT_name{{.*}}"var3"
39# CHECK: DW_AT_const_value
40# CHECK: DW_AT_type (0x00000000[[CLASS1]]
41
42# CHECK-NOT: Compile Unit:
43
44--- !mach-o
45FileHeader:
46  magic:      0xFEEDFACF
47  cputype:    0x01000007
48  cpusubtype: 0x00000003
49  filetype:   0x00000001
50  ncmds:      2
51  sizeofcmds: 376
52  flags:      0x00002000
53  reserved:   0x00000000
54LoadCommands:
55  - cmd:      LC_SEGMENT_64
56    cmdsize:  232
57    segname:  ''
58    vmaddr:   0x00
59    vmsize:   0x300
60    fileoff:  0x300
61    filesize: 0x300
62    maxprot:  7
63    initprot: 7
64    nsects:   2
65    flags:    0
66    Sections:
67      - sectname:  __debug_abbrev
68        segname:   __DWARF
69        addr:      0x000000000000000F
70        size:      0x5a
71        offset:    0x00000380
72        align:     0
73        reloff:    0x00000000
74        nreloc:    0
75        flags:     0x02000000
76        reserved1: 0x00000000
77        reserved2: 0x00000000
78        reserved3: 0x00000000
79      - sectname:  __debug_info
80        segname:   __DWARF
81        addr:      0x000000000000100
82        size:      0x8d
83        offset:    0x00000410
84        align:     0
85        reloff:    0x00000600
86        nreloc:    1
87        flags:     0x02000000
88        reserved1: 0x00000000
89        reserved2: 0x00000000
90        reserved3: 0x00000000
91        relocations:
92          - address:         0x1FC
93            symbolnum:       1
94            pcrel:           true
95            length:          3
96            extern:          true
97            type:            0
98            scattered:       false
99            value:           0
100  - cmd:             LC_SYMTAB
101    cmdsize:         24
102    symoff:          0x700
103    nsyms:           2
104    stroff:          0x720
105    strsize:         10
106LinkEditData:
107  NameList:
108    - n_strx:          1
109      n_type:          0x0F
110      n_sect:          1
111      n_desc:          0
112      n_value:         0
113    - n_strx:          1
114      n_type:          0x0F
115      n_sect:          1
116      n_desc:          0
117      n_value:         0
118  StringTable:
119    - ''
120    - '__Z3foov'
121    - ''
122DWARF:
123  debug_abbrev:
124    - Table:
125      - Tag:      DW_TAG_compile_unit
126        Children: DW_CHILDREN_yes
127        Attributes:
128          - Attribute: DW_AT_producer
129            Form:      DW_FORM_string
130          - Attribute: DW_AT_language
131            Form:      DW_FORM_data2
132          - Attribute: DW_AT_name
133            Form:      DW_FORM_string
134      - Tag:      DW_TAG_pointer_type
135        Children: DW_CHILDREN_no
136        Attributes:
137          - Attribute: DW_AT_type
138            Form:      DW_FORM_ref_addr
139      - Tag:      DW_TAG_variable
140        Children: DW_CHILDREN_no
141        Attributes:
142          - Attribute: DW_AT_name
143            Form:      DW_FORM_string
144          - Attribute: DW_AT_const_value
145            Form:      DW_FORM_data4
146          - Attribute: DW_AT_type
147            Form:      DW_FORM_ref4
148    - Table:
149      - Tag:      DW_TAG_compile_unit
150        Children: DW_CHILDREN_yes
151        Attributes:
152          - Attribute: DW_AT_producer
153            Form:      DW_FORM_string
154          - Attribute: DW_AT_language
155            Form:      DW_FORM_data2
156          - Attribute: DW_AT_name
157            Form:      DW_FORM_string
158      - Tag:      DW_TAG_pointer_type
159        Children: DW_CHILDREN_no
160        Attributes:
161          - Attribute: DW_AT_type
162            Form:      DW_FORM_ref_addr
163      - Tag:      DW_TAG_variable
164        Children: DW_CHILDREN_no
165        Attributes:
166          - Attribute: DW_AT_name
167            Form:      DW_FORM_string
168          - Attribute: DW_AT_const_value
169            Form:      DW_FORM_data4
170          - Attribute: DW_AT_type
171            Form:      DW_FORM_ref4
172    - Table:
173      - Tag:      DW_TAG_compile_unit
174        Children: DW_CHILDREN_yes
175        Attributes:
176          - Attribute: DW_AT_producer
177            Form:      DW_FORM_string
178          - Attribute: DW_AT_language
179            Form:      DW_FORM_data2
180          - Attribute: DW_AT_name
181            Form:      DW_FORM_string
182      - Tag:      DW_TAG_class_type
183        Children: DW_CHILDREN_no
184        Attributes:
185          - Attribute: DW_AT_name
186            Form:      DW_FORM_string
187      - Tag:      DW_TAG_variable
188        Children: DW_CHILDREN_no
189        Attributes:
190          - Attribute: DW_AT_name
191            Form:      DW_FORM_string
192          - Attribute: DW_AT_const_value
193            Form:      DW_FORM_data4
194          - Attribute: DW_AT_type
195            Form:      DW_FORM_ref4
196  debug_info:
197    - Version: 4
198      Entries:
199        - AbbrCode: 1
200          Values:
201            - CStr: by_hand
202            - Value:  0x04
203            - CStr: CU1
204        - AbbrCode: 2
205          Values:
206            - Value:  0x48
207        - AbbrCode: 3
208          Values:
209            - CStr: var1
210            - Value:  0x00000000
211            - Value:  0x0000001a
212        - AbbrCode: 0
213    - Version: 4
214      Entries:
215        - AbbrCode: 1
216          Values:
217            - CStr: by_hand
218            - Value:  0x04
219            - CStr: CU2
220        - AbbrCode: 2
221          Values:
222            - Value: 0x1a
223        - AbbrCode: 3
224          Values:
225            - CStr: var2
226            - Value:  0x00000000
227            - Value:  0x0000001a
228        - AbbrCode: 0
229    - Version: 4
230      Entries:
231        - AbbrCode: 1
232          Values:
233            - CStr: by_hand
234            - Value:  0x04
235            - CStr: CU3
236        - AbbrCode: 2
237          Values:
238            - CStr: class1
239        - AbbrCode: 3
240          Values:
241            - CStr: var3
242            - Value:  0x00000000
243            - Value:  0x0000001a
244        - AbbrCode: 0
245...
246