[NFC][MLIR][Linalg] Refactor linalg.matmul tablegen ODS and related C++ code. (#116377)
[llvm-project.git] / llvm / unittests / DebugInfo / DWARF / DWARFDieTest.cpp
blob485ec720ffad6231e91a8b13408a9575e8719d86
1 //===- llvm/unittest/DebugInfo/DWARFDieTest.cpp ---------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/BinaryFormat/Dwarf.h"
10 #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
11 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
12 #include "llvm/ObjectYAML/DWARFEmitter.h"
13 #include "llvm/Testing/Support/Error.h"
14 #include "gtest/gtest.h"
16 using namespace llvm;
17 using namespace llvm::dwarf;
19 namespace {
21 TEST(DWARFDie, getLocations) {
22 const char *yamldata = R"(
23 debug_abbrev:
24 - Table:
25 - Code: 0x00000001
26 Tag: DW_TAG_compile_unit
27 Children: DW_CHILDREN_no
28 Attributes:
29 - Attribute: DW_AT_location
30 Form: DW_FORM_sec_offset
31 - Attribute: DW_AT_data_member_location
32 Form: DW_FORM_exprloc
33 - Attribute: DW_AT_vtable_elem_location
34 Form: DW_FORM_sec_offset
35 - Attribute: DW_AT_call_data_location
36 Form: DW_FORM_sec_offset
37 debug_info:
38 - Version: 5
39 UnitType: DW_UT_compile
40 AddrSize: 4
41 Entries:
42 - AbbrCode: 0x00000001
43 Values:
44 - Value: 12
45 - Value: 0x0000000000000001
46 BlockData: [ 0x47 ]
47 - Value: 20
48 - Value: 25
49 debug_loclists:
50 - AddressSize: 4
51 OffsetEntryCount: 0
52 Lists:
53 - Entries:
54 - Operator: DW_LLE_start_length
55 Values: [ 0x01, 0x02 ]
56 - Operator: DW_LLE_end_of_list
57 - Entries:
58 - Operator: DW_LLE_startx_length
59 Values: [ 0x01, 0x02 ]
60 - Operator: DW_LLE_end_of_list
61 - Entries:
62 - Operator: DW_LLE_start_length
63 Values: [ 0x01, 0x02 ]
64 ## end_of_list intentionally missing.
65 )";
66 Expected<StringMap<std::unique_ptr<MemoryBuffer>>> Sections =
67 DWARFYAML::emitDebugSections(StringRef(yamldata),
68 /*IsLittleEndian=*/true,
69 /*Is64BitAddrSize=*/false);
70 ASSERT_THAT_EXPECTED(Sections, Succeeded());
71 std::unique_ptr<DWARFContext> Ctx =
72 DWARFContext::create(*Sections, 4, /*isLittleEndian=*/true);
73 DWARFCompileUnit *CU = Ctx->getCompileUnitForOffset(0);
74 ASSERT_NE(nullptr, CU);
75 DWARFDie Die = CU->getUnitDIE();
76 ASSERT_TRUE(Die.isValid());
78 EXPECT_THAT_EXPECTED(Die.getLocations(DW_AT_location),
79 HasValue(testing::ElementsAre(DWARFLocationExpression{
80 DWARFAddressRange{1, 3}, {}})));
82 EXPECT_THAT_EXPECTED(Die.getLocations(DW_AT_data_member_location),
83 HasValue(testing::ElementsAre(
84 DWARFLocationExpression{std::nullopt, {0x47}})));
86 EXPECT_THAT_EXPECTED(
87 Die.getLocations(DW_AT_vtable_elem_location),
88 Failed<ErrorInfoBase>(testing::Property(
89 &ErrorInfoBase::message,
90 "unable to resolve indirect address 1 for: DW_LLE_startx_length")));
92 EXPECT_THAT_EXPECTED(
93 Die.getLocations(DW_AT_call_data_location),
94 FailedWithMessage(
95 "unexpected end of data at offset 0x20 while reading [0x20, 0x21)"));
97 EXPECT_THAT_EXPECTED(
98 Die.getLocations(DW_AT_call_data_value),
99 Failed<ErrorInfoBase>(testing::Property(&ErrorInfoBase::message,
100 "No DW_AT_call_data_value")));
103 TEST(DWARFDie, getDeclFile) {
104 const char *yamldata = R"(
105 debug_str:
106 - ''
107 debug_abbrev:
108 - ID: 0
109 Table:
110 - Code: 0x1
111 Tag: DW_TAG_compile_unit
112 Children: DW_CHILDREN_yes
113 Attributes:
114 - Attribute: DW_AT_stmt_list
115 Form: DW_FORM_sec_offset
116 - Code: 0x2
117 Tag: DW_TAG_subprogram
118 Children: DW_CHILDREN_no
119 Attributes:
120 - Attribute: DW_AT_decl_file
121 Form: DW_FORM_data1
122 debug_info:
123 - Length: 0xF
124 Version: 4
125 AbbrevTableID: 0
126 AbbrOffset: 0x0
127 AddrSize: 8
128 Entries:
129 - AbbrCode: 0x1
130 Values:
131 - Value: 0x0
132 - AbbrCode: 0x2
133 Values:
134 - Value: 0x1
135 - AbbrCode: 0x0
136 debug_line:
137 - Length: 42
138 Version: 2
139 PrologueLength: 36
140 MinInstLength: 1
141 DefaultIsStmt: 1
142 LineBase: 251
143 LineRange: 14
144 OpcodeBase: 13
145 StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
146 IncludeDirs:
147 - '/tmp'
148 Files:
149 - Name: main.cpp
150 DirIdx: 1
151 ModTime: 0
152 Length: 0
155 // Given DWARF like this:
157 // 0x0000000b: DW_TAG_compile_unit
158 // DW_AT_stmt_list (0x00000000)
160 // 0x00000010: DW_TAG_subprogram
161 // DW_AT_decl_file ("/tmp/main.cpp")
163 // 0x00000012: NULL
165 // This tests that we can extract the right DW_AT_decl_file from a DIE that
166 // has a DW_AT_decl_file attribute.
168 Expected<StringMap<std::unique_ptr<MemoryBuffer>>> Sections =
169 DWARFYAML::emitDebugSections(StringRef(yamldata),
170 /*IsLittleEndian=*/true,
171 /*Is64BitAddrSize=*/true);
172 ASSERT_THAT_EXPECTED(Sections, Succeeded());
173 std::unique_ptr<DWARFContext> Ctx =
174 DWARFContext::create(*Sections, 4, /*isLittleEndian=*/true);
175 DWARFCompileUnit *CU = Ctx->getCompileUnitForOffset(0);
176 ASSERT_NE(nullptr, CU);
177 DWARFDie Die = CU->getUnitDIE(/*ExtractUnitDIEOnly=*/false);
178 ASSERT_TRUE(Die.isValid());
180 DWARFDie MainDie = Die.getFirstChild();
181 ASSERT_TRUE(MainDie.isValid());
183 std::string DeclFile = MainDie.getDeclFile(
184 DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
186 std::string Ref =
187 ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
188 EXPECT_EQ(DeclFile, Ref);
191 TEST(DWARFDie, getDeclFileAbstractOrigin) {
192 const char *yamldata = R"(
193 debug_str:
194 - ''
195 debug_abbrev:
196 - ID: 0
197 Table:
198 - Code: 0x1
199 Tag: DW_TAG_compile_unit
200 Children: DW_CHILDREN_yes
201 Attributes:
202 - Attribute: DW_AT_stmt_list
203 Form: DW_FORM_sec_offset
204 - Code: 0x2
205 Tag: DW_TAG_subprogram
206 Children: DW_CHILDREN_no
207 Attributes:
208 - Attribute: DW_AT_abstract_origin
209 Form: DW_FORM_ref_addr
210 - Code: 0x3
211 Tag: DW_TAG_subprogram
212 Children: DW_CHILDREN_no
213 Attributes:
214 - Attribute: DW_AT_decl_file
215 Form: DW_FORM_data1
216 debug_info:
217 - Length: 0x14
218 Version: 4
219 AbbrevTableID: 0
220 AbbrOffset: 0x0
221 AddrSize: 8
222 Entries:
223 - AbbrCode: 0x1
224 Values:
225 - Value: 0x0
226 - AbbrCode: 0x2
227 Values:
228 - Value: 0x15
229 - AbbrCode: 0x3
230 Values:
231 - Value: 0x1
232 - AbbrCode: 0x0
233 debug_line:
234 - Length: 42
235 Version: 2
236 PrologueLength: 36
237 MinInstLength: 1
238 DefaultIsStmt: 1
239 LineBase: 251
240 LineRange: 14
241 OpcodeBase: 13
242 StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
243 IncludeDirs:
244 - '/tmp'
245 Files:
246 - Name: main.cpp
247 DirIdx: 1
248 ModTime: 0
249 Length: 0
252 // Given DWARF like this:
254 // 0x0000000b: DW_TAG_compile_unit
255 // DW_AT_stmt_list (0x00000000)
257 // 0x00000010: DW_TAG_subprogram
258 // DW_AT_abstract_origin (0x0000000000000015)
260 // 0x00000015: DW_TAG_subprogram
261 // DW_AT_decl_file ("/tmp/main.cpp")
263 // 0x00000017: NULL
266 // The DIE at 0x00000010 uses a DW_AT_abstract_origin to point to the DIE at
267 // 0x00000015, make sure that DWARFDie::getDeclFile() succeeds by extracting
268 // the right file name of "/tmp/main.cpp".
270 // This tests that when we have a DW_AT_abstract_origin with a compile unit
271 // relative form (DW_FORM_ref4) to another DIE that we get the right
272 // DW_AT_decl_file value.
274 Expected<StringMap<std::unique_ptr<MemoryBuffer>>> Sections =
275 DWARFYAML::emitDebugSections(StringRef(yamldata),
276 /*IsLittleEndian=*/true,
277 /*Is64BitAddrSize=*/true);
278 ASSERT_THAT_EXPECTED(Sections, Succeeded());
279 std::unique_ptr<DWARFContext> Ctx =
280 DWARFContext::create(*Sections, 4, /*isLittleEndian=*/true);
281 DWARFCompileUnit *CU = Ctx->getCompileUnitForOffset(0);
282 ASSERT_NE(nullptr, CU);
283 DWARFDie Die = CU->getUnitDIE(/*ExtractUnitDIEOnly=*/false);
284 ASSERT_TRUE(Die.isValid());
286 DWARFDie MainDie = Die.getFirstChild();
287 ASSERT_TRUE(MainDie.isValid());
289 std::string DeclFile = MainDie.getDeclFile(
290 DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
292 std::string Ref =
293 ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
294 EXPECT_EQ(DeclFile, Ref);
297 TEST(DWARFDie, getDeclFileSpecification) {
298 const char *yamldata = R"(
299 debug_str:
300 - ''
301 debug_abbrev:
302 - ID: 0
303 Table:
304 - Code: 0x1
305 Tag: DW_TAG_compile_unit
306 Children: DW_CHILDREN_yes
307 Attributes:
308 - Attribute: DW_AT_stmt_list
309 Form: DW_FORM_sec_offset
310 - Code: 0x2
311 Tag: DW_TAG_subprogram
312 Children: DW_CHILDREN_no
313 Attributes:
314 - Attribute: DW_AT_specification
315 Form: DW_FORM_ref_addr
316 - Code: 0x3
317 Tag: DW_TAG_subprogram
318 Children: DW_CHILDREN_no
319 Attributes:
320 - Attribute: DW_AT_decl_file
321 Form: DW_FORM_data1
322 debug_info:
323 - Length: 0x14
324 Version: 4
325 AbbrevTableID: 0
326 AbbrOffset: 0x0
327 AddrSize: 8
328 Entries:
329 - AbbrCode: 0x1
330 Values:
331 - Value: 0x0
332 - AbbrCode: 0x2
333 Values:
334 - Value: 0x15
335 - AbbrCode: 0x3
336 Values:
337 - Value: 0x1
338 - AbbrCode: 0x0
339 debug_line:
340 - Length: 42
341 Version: 2
342 PrologueLength: 36
343 MinInstLength: 1
344 DefaultIsStmt: 1
345 LineBase: 251
346 LineRange: 14
347 OpcodeBase: 13
348 StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
349 IncludeDirs:
350 - '/tmp'
351 Files:
352 - Name: main.cpp
353 DirIdx: 1
354 ModTime: 0
355 Length: 0
358 // Given DWARF like this:
360 // 0x0000000b: DW_TAG_compile_unit
361 // DW_AT_stmt_list (0x00000000)
363 // 0x00000010: DW_TAG_subprogram
364 // DW_AT_specification (0x0000000000000015)
366 // 0x00000015: DW_TAG_subprogram
367 // DW_AT_decl_file ("/tmp/main.cpp")
369 // 0x00000017: NULL
371 // The DIE at 0x00000010 uses a DW_AT_specification to point to the DIE at
372 // 0x00000015, make sure that DWARFDie::getDeclFile() succeeds by extracting
373 // the right file name of "/tmp/main.cpp".
375 // This tests that when we have a DW_AT_specification with a compile unit
376 // relative form (DW_FORM_ref4) to another DIE that we get the right
377 // DW_AT_decl_file value.
379 Expected<StringMap<std::unique_ptr<MemoryBuffer>>> Sections =
380 DWARFYAML::emitDebugSections(StringRef(yamldata),
381 /*IsLittleEndian=*/true,
382 /*Is64BitAddrSize=*/true);
383 ASSERT_THAT_EXPECTED(Sections, Succeeded());
384 std::unique_ptr<DWARFContext> Ctx =
385 DWARFContext::create(*Sections, 4, /*isLittleEndian=*/true);
386 DWARFCompileUnit *CU = Ctx->getCompileUnitForOffset(0);
387 ASSERT_NE(nullptr, CU);
388 DWARFDie Die = CU->getUnitDIE(/*ExtractUnitDIEOnly=*/false);
389 ASSERT_TRUE(Die.isValid());
391 DWARFDie MainDie = Die.getFirstChild();
392 ASSERT_TRUE(MainDie.isValid());
394 std::string DeclFile = MainDie.getDeclFile(
395 DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
397 std::string Ref =
398 ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
399 EXPECT_EQ(DeclFile, Ref);
402 TEST(DWARFDie, getDeclFileAbstractOriginAcrossCUBoundary) {
403 const char *yamldata = R"(
404 debug_str:
405 - ''
406 debug_abbrev:
407 - ID: 0
408 Table:
409 - Code: 0x1
410 Tag: DW_TAG_compile_unit
411 Children: DW_CHILDREN_yes
412 - Code: 0x2
413 Tag: DW_TAG_subprogram
414 Children: DW_CHILDREN_no
415 Attributes:
416 - Attribute: DW_AT_abstract_origin
417 Form: DW_FORM_ref_addr
418 - Code: 0x3
419 Tag: DW_TAG_compile_unit
420 Children: DW_CHILDREN_yes
421 Attributes:
422 - Attribute: DW_AT_stmt_list
423 Form: DW_FORM_sec_offset
424 - Code: 0x4
425 Tag: DW_TAG_subprogram
426 Children: DW_CHILDREN_no
427 Attributes:
428 - Attribute: DW_AT_decl_file
429 Form: DW_FORM_data1
430 debug_info:
431 - Length: 0xE
432 Version: 4
433 AbbrevTableID: 0
434 AbbrOffset: 0x0
435 AddrSize: 8
436 Entries:
437 - AbbrCode: 0x1
438 - AbbrCode: 0x2
439 Values:
440 - Value: 0x22
441 - AbbrCode: 0x0
442 - Length: 0xF
443 Version: 4
444 AbbrevTableID: 0
445 AbbrOffset: 0x0
446 AddrSize: 8
447 Entries:
448 - AbbrCode: 0x3
449 Values:
450 - Value: 0x0
451 - AbbrCode: 0x4
452 Values:
453 - Value: 0x1
454 - AbbrCode: 0x0
455 debug_line:
456 - Length: 42
457 Version: 2
458 PrologueLength: 36
459 MinInstLength: 1
460 DefaultIsStmt: 1
461 LineBase: 251
462 LineRange: 14
463 OpcodeBase: 13
464 StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
465 IncludeDirs:
466 - '/tmp'
467 Files:
468 - Name: main.cpp
469 DirIdx: 1
470 ModTime: 0
471 Length: 0
474 // Given DWARF like this:
476 // 0x0000000b: DW_TAG_compile_unit
478 // 0x0000000c: DW_TAG_subprogram
479 // DW_AT_abstract_origin (0x0000000000000022)
481 // 0x00000011: NULL
483 // 0x0000001d: DW_TAG_compile_unit
484 // DW_AT_stmt_list (0x00000000)
486 // 0x00000022: DW_TAG_subprogram
487 // DW_AT_decl_file ("/tmp/main.cpp")
489 // 0x00000024: NULL
491 // This tests that when we have a DW_AT_abstract_origin with a
492 // DW_FORM_ref_addr to another DIE in another compile unit that we use the
493 // right file table when converting the file index of the DW_AT_decl_file.
495 // The DIE at 0x0000000c uses a DW_AT_abstract_origin to point to the DIE at
496 // 0x00000022, make sure that DWARFDie::getDeclFile() succeeds by extracting
497 // the right file name of "/tmp/main.cpp". The DW_AT_decl_file must grab the
498 // file from the line table prologue of the compile unit at offset
499 // 0x0000001d.
501 Expected<StringMap<std::unique_ptr<MemoryBuffer>>> Sections =
502 DWARFYAML::emitDebugSections(StringRef(yamldata),
503 /*IsLittleEndian=*/true,
504 /*Is64BitAddrSize=*/true);
505 ASSERT_THAT_EXPECTED(Sections, Succeeded());
506 std::unique_ptr<DWARFContext> Ctx =
507 DWARFContext::create(*Sections, 4, /*isLittleEndian=*/true);
508 DWARFCompileUnit *CU = Ctx->getCompileUnitForOffset(0);
509 ASSERT_NE(nullptr, CU);
510 DWARFDie Die = CU->getUnitDIE(/*ExtractUnitDIEOnly=*/false);
511 ASSERT_TRUE(Die.isValid());
513 DWARFDie MainDie = Die.getFirstChild();
514 ASSERT_TRUE(MainDie.isValid());
516 std::string DeclFile = MainDie.getDeclFile(
517 DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
519 std::string Ref =
520 ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
521 EXPECT_EQ(DeclFile, Ref);
524 TEST(DWARFDie, getDeclFileSpecificationAcrossCUBoundary) {
525 const char *yamldata = R"(
526 debug_str:
527 - ''
528 debug_abbrev:
529 - ID: 0
530 Table:
531 - Code: 0x1
532 Tag: DW_TAG_compile_unit
533 Children: DW_CHILDREN_yes
534 - Code: 0x2
535 Tag: DW_TAG_subprogram
536 Children: DW_CHILDREN_no
537 Attributes:
538 - Attribute: DW_AT_specification
539 Form: DW_FORM_ref_addr
540 - Code: 0x3
541 Tag: DW_TAG_compile_unit
542 Children: DW_CHILDREN_yes
543 Attributes:
544 - Attribute: DW_AT_stmt_list
545 Form: DW_FORM_sec_offset
546 - Code: 0x4
547 Tag: DW_TAG_subprogram
548 Children: DW_CHILDREN_no
549 Attributes:
550 - Attribute: DW_AT_decl_file
551 Form: DW_FORM_data1
552 debug_info:
553 - Length: 0xE
554 Version: 4
555 AbbrevTableID: 0
556 AbbrOffset: 0x0
557 AddrSize: 8
558 Entries:
559 - AbbrCode: 0x1
560 - AbbrCode: 0x2
561 Values:
562 - Value: 0x22
563 - AbbrCode: 0x0
564 - Length: 0xF
565 Version: 4
566 AbbrevTableID: 0
567 AbbrOffset: 0x0
568 AddrSize: 8
569 Entries:
570 - AbbrCode: 0x3
571 Values:
572 - Value: 0x0
573 - AbbrCode: 0x4
574 Values:
575 - Value: 0x1
576 - AbbrCode: 0x0
577 debug_line:
578 - Length: 42
579 Version: 2
580 PrologueLength: 36
581 MinInstLength: 1
582 DefaultIsStmt: 1
583 LineBase: 251
584 LineRange: 14
585 OpcodeBase: 13
586 StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
587 IncludeDirs:
588 - '/tmp'
589 Files:
590 - Name: main.cpp
591 DirIdx: 1
592 ModTime: 0
593 Length: 0
596 // Given DWARF like this:
598 // 0x0000000b: DW_TAG_compile_unit
600 // 0x0000000c: DW_TAG_subprogram
601 // DW_AT_specification (0x0000000000000022)
603 // 0x00000011: NULL
605 // 0x0000001d: DW_TAG_compile_unit
606 // DW_AT_stmt_list (0x00000000)
608 // 0x00000022: DW_TAG_subprogram
609 // DW_AT_decl_file ("/tmp/main.cpp")
611 // 0x00000024: NULL
613 // This tests that when we have a DW_AT_specification with a
614 // DW_FORM_ref_addr to another DIE in another compile unit that we use the
615 // right file table when converting the file index of the DW_AT_decl_file.
617 // The DIE at 0x0000000c uses a DW_AT_specification to point to the DIE at
618 // 0x00000022, make sure that DWARFDie::getDeclFile() succeeds by extracting
619 // the right file name of "/tmp/main.cpp". The DW_AT_decl_file must grab the
620 // file from the line table prologue of the compile unit at offset
621 // 0x0000001d.
623 Expected<StringMap<std::unique_ptr<MemoryBuffer>>> Sections =
624 DWARFYAML::emitDebugSections(StringRef(yamldata),
625 /*IsLittleEndian=*/true,
626 /*Is64BitAddrSize=*/true);
627 ASSERT_THAT_EXPECTED(Sections, Succeeded());
628 std::unique_ptr<DWARFContext> Ctx =
629 DWARFContext::create(*Sections, 4, /*isLittleEndian=*/true);
630 DWARFCompileUnit *CU = Ctx->getCompileUnitForOffset(0);
631 ASSERT_NE(nullptr, CU);
632 DWARFDie Die = CU->getUnitDIE(/*ExtractUnitDIEOnly=*/false);
633 ASSERT_TRUE(Die.isValid());
635 DWARFDie MainDie = Die.getFirstChild();
636 ASSERT_TRUE(MainDie.isValid());
638 std::string DeclFile = MainDie.getDeclFile(
639 DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
641 std::string Ref =
642 ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
643 EXPECT_EQ(DeclFile, Ref);
646 TEST(DWARFDie, getNameFromTypeUnit) {
647 const char *yamldata = R"(
648 debug_abbrev:
649 - ID: 0
650 Table:
651 - Code: 0x1
652 Tag: DW_TAG_compile_unit
653 Children: DW_CHILDREN_yes
654 - Code: 0x2
655 Tag: DW_TAG_structure_type
656 Children: DW_CHILDREN_no
657 Attributes:
658 - Attribute: DW_AT_signature
659 Form: DW_FORM_ref_sig8
660 - Code: 0x3
661 Tag: DW_TAG_type_unit
662 Children: DW_CHILDREN_yes
663 - Code: 0x4
664 Tag: DW_TAG_structure_type
665 Children: DW_CHILDREN_no
666 Attributes:
667 - Attribute: DW_AT_name
668 Form: DW_FORM_string
669 debug_info:
670 - Version: 5
671 UnitType: DW_UT_compile
672 AbbrevTableID: 0
673 Entries:
674 - AbbrCode: 0x1
675 - AbbrCode: 0x2
676 Values:
677 - Value: 0xdeadbeefbaadf00d
678 - AbbrCode: 0x0
679 - Version: 5
680 UnitType: DW_UT_type
681 AbbrevTableID: 0
682 TypeSignature: 0xdeadbeefbaadf00d
683 TypeOffset: 25
684 Entries:
685 - AbbrCode: 0x3
686 - AbbrCode: 0x4
687 Values:
688 - CStr: "STRUCT"
689 - AbbrCode: 0x0
692 Expected<StringMap<std::unique_ptr<MemoryBuffer>>> Sections =
693 DWARFYAML::emitDebugSections(StringRef(yamldata),
694 /*IsLittleEndian=*/true,
695 /*Is64BitAddrSize=*/true);
696 ASSERT_THAT_EXPECTED(Sections, Succeeded());
697 std::unique_ptr<DWARFContext> Ctx =
698 DWARFContext::create(*Sections, 4, /*isLittleEndian=*/true);
699 DWARFCompileUnit *CU = Ctx->getCompileUnitForOffset(0);
700 ASSERT_NE(nullptr, CU);
701 DWARFDie Die = CU->getUnitDIE(/*ExtractUnitDIEOnly=*/false).getFirstChild();
702 ASSERT_TRUE(Die.isValid());
704 ASSERT_STREQ(Die.getName(DINameKind::ShortName), "STRUCT");
707 } // end anonymous namespace