LLVM 23.0.0git
Dwarf.cpp
Go to the documentation of this file.
1//===-- llvm/BinaryFormat/Dwarf.cpp - Dwarf Framework ------------*- C++-*-===//
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//===----------------------------------------------------------------------===//
8//
9// This file contains support for generic dwarf information.
10//
11//===----------------------------------------------------------------------===//
12
17
18using namespace llvm;
19using namespace dwarf;
20
22 switch (Tag) {
23 default:
24 return StringRef();
25#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR, KIND) \
26 case DW_TAG_##NAME: \
27 return "DW_TAG_" #NAME;
28#include "llvm/BinaryFormat/Dwarf.def"
29 }
30}
31
34#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR, KIND) \
35 .Case("DW_TAG_" #NAME, DW_TAG_##NAME)
36#include "llvm/BinaryFormat/Dwarf.def"
38}
39
41 switch (Tag) {
42 default:
43 return 0;
44#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR, KIND) \
45 case DW_TAG_##NAME: \
46 return VERSION;
47#include "llvm/BinaryFormat/Dwarf.def"
48 }
49}
50
52 switch (Tag) {
53 default:
54 return 0;
55#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR, KIND) \
56 case DW_TAG_##NAME: \
57 return DWARF_VENDOR_##VENDOR;
58#include "llvm/BinaryFormat/Dwarf.def"
59 }
60}
61
63 switch (Children) {
64 case DW_CHILDREN_no:
65 return "DW_CHILDREN_no";
66 case DW_CHILDREN_yes:
67 return "DW_CHILDREN_yes";
68 }
69 return StringRef();
70}
71
73 switch (Attribute) {
74 default:
75 return StringRef();
76#define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) \
77 case DW_AT_##NAME: \
78 return "DW_AT_" #NAME;
79#include "llvm/BinaryFormat/Dwarf.def"
80 }
81}
82
84 switch (Attribute) {
85 default:
86 return 0;
87#define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) \
88 case DW_AT_##NAME: \
89 return VERSION;
90#include "llvm/BinaryFormat/Dwarf.def"
91 }
92}
93
95 switch (Attribute) {
96 default:
97 return 0;
98#define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) \
99 case DW_AT_##NAME: \
100 return DWARF_VENDOR_##VENDOR;
101#include "llvm/BinaryFormat/Dwarf.def"
102 }
103}
104
106 switch (Encoding) {
107 default:
108 return StringRef();
109#define HANDLE_DW_FORM(ID, NAME, VERSION, VENDOR) \
110 case DW_FORM_##NAME: \
111 return "DW_FORM_" #NAME;
112#include "llvm/BinaryFormat/Dwarf.def"
113 }
114}
115
117 switch (Form) {
118 default:
119 return 0;
120#define HANDLE_DW_FORM(ID, NAME, VERSION, VENDOR) \
121 case DW_FORM_##NAME: \
122 return VERSION;
123#include "llvm/BinaryFormat/Dwarf.def"
124 }
125}
126
128 switch (Form) {
129 default:
130 return 0;
131#define HANDLE_DW_FORM(ID, NAME, VERSION, VENDOR) \
132 case DW_FORM_##NAME: \
133 return DWARF_VENDOR_##VENDOR;
134#include "llvm/BinaryFormat/Dwarf.def"
135 }
136}
137
139 switch (Encoding) {
140 default:
141 return StringRef();
142#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \
143 case DW_OP_##NAME: \
144 return "DW_OP_" #NAME;
145#include "llvm/BinaryFormat/Dwarf.def"
147 return "DW_OP_LLVM_convert";
149 return "DW_OP_LLVM_fragment";
151 return "DW_OP_LLVM_tag_offset";
153 return "DW_OP_LLVM_entry_value";
155 return "DW_OP_LLVM_implicit_pointer";
156 case DW_OP_LLVM_arg:
157 return "DW_OP_LLVM_arg";
159 return "DW_OP_LLVM_extract_bits_sext";
161 return "DW_OP_LLVM_extract_bits_zext";
162 }
163}
164
167#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \
168 .Case("DW_OP_" #NAME, DW_OP_##NAME)
169#include "llvm/BinaryFormat/Dwarf.def"
170 .Case("DW_OP_LLVM_convert", DW_OP_LLVM_convert)
171 .Case("DW_OP_LLVM_fragment", DW_OP_LLVM_fragment)
172 .Case("DW_OP_LLVM_tag_offset", DW_OP_LLVM_tag_offset)
173 .Case("DW_OP_LLVM_entry_value", DW_OP_LLVM_entry_value)
174 .Case("DW_OP_LLVM_implicit_pointer", DW_OP_LLVM_implicit_pointer)
175 .Case("DW_OP_LLVM_arg", DW_OP_LLVM_arg)
176 .Case("DW_OP_LLVM_extract_bits_sext", DW_OP_LLVM_extract_bits_sext)
177 .Case("DW_OP_LLVM_extract_bits_zext", DW_OP_LLVM_extract_bits_zext)
178 .Default(0);
179}
180
182 switch (Encoding) {
183 default:
184 llvm_unreachable("unhandled DWARF operation with LLVM user op");
185#define HANDLE_DW_OP_LLVM_USEROP(ID, NAME) \
186 case DW_OP_LLVM_##NAME: \
187 return "DW_OP_LLVM_" #NAME;
188#include "llvm/BinaryFormat/Dwarf.def"
189 }
190}
191
192static unsigned
195#define HANDLE_DW_OP_LLVM_USEROP(ID, NAME) .Case(#NAME, DW_OP_LLVM_##NAME)
196#include "llvm/BinaryFormat/Dwarf.def"
197 .Default(0);
198 assert(E && "unhandled DWARF operation string with LLVM user op");
199 return E;
200}
201
203 unsigned SubOpEncoding) {
204 assert(OpEncoding == DW_OP_LLVM_user);
205 return LlvmUserOperationEncodingString(SubOpEncoding);
206}
207
208unsigned
214
216 switch (Op) {
217 default:
218 return 0;
219#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \
220 case DW_OP_##NAME: \
221 return VERSION;
222#include "llvm/BinaryFormat/Dwarf.def"
223 }
224}
225
227 switch (Op) {
228 default:
229 return std::nullopt;
230#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \
231 case DW_OP_##NAME: \
232 if (OPERANDS == -1) \
233 return std::nullopt; \
234 return OPERANDS;
235#include "llvm/BinaryFormat/Dwarf.def"
236 }
237}
238
240 switch (Op) {
241 default:
242 return std::nullopt;
243#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \
244 case DW_OP_##NAME: \
245 if (ARITY == -1) \
246 return std::nullopt; \
247 return ARITY;
248#include "llvm/BinaryFormat/Dwarf.def"
249 }
250}
251
253 switch (Op) {
254 default:
255 return 0;
256#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \
257 case DW_OP_##NAME: \
258 return DWARF_VENDOR_##VENDOR;
259#include "llvm/BinaryFormat/Dwarf.def"
260 }
261}
262
264 switch (Encoding) {
265 default:
266 return StringRef();
267#define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) \
268 case DW_ATE_##NAME: \
269 return "DW_ATE_" #NAME;
270#include "llvm/BinaryFormat/Dwarf.def"
271 }
272}
273
275 return StringSwitch<unsigned>(EncodingString)
276#define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) \
277 .Case("DW_ATE_" #NAME, DW_ATE_##NAME)
278#include "llvm/BinaryFormat/Dwarf.def"
279 .Default(0);
280}
281
283 switch (ATE) {
284 default:
285 return 0;
286#define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) \
287 case DW_ATE_##NAME: \
288 return VERSION;
289#include "llvm/BinaryFormat/Dwarf.def"
290 }
291}
292
294 switch (ATE) {
295 default:
296 return 0;
297#define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) \
298 case DW_ATE_##NAME: \
299 return DWARF_VENDOR_##VENDOR;
300#include "llvm/BinaryFormat/Dwarf.def"
301 }
302}
303
305 switch (Sign) {
306 case DW_DS_unsigned:
307 return "DW_DS_unsigned";
309 return "DW_DS_leading_overpunch";
311 return "DW_DS_trailing_overpunch";
313 return "DW_DS_leading_separate";
315 return "DW_DS_trailing_separate";
316 }
317 return StringRef();
318}
319
321 switch (Endian) {
322 case DW_END_default:
323 return "DW_END_default";
324 case DW_END_big:
325 return "DW_END_big";
326 case DW_END_little:
327 return "DW_END_little";
328 case DW_END_lo_user:
329 return "DW_END_lo_user";
330 case DW_END_hi_user:
331 return "DW_END_hi_user";
332 }
333 return StringRef();
334}
335
337 switch (Access) {
338 // Accessibility codes
339 case DW_ACCESS_public:
340 return "DW_ACCESS_public";
342 return "DW_ACCESS_protected";
344 return "DW_ACCESS_private";
345 }
346 return StringRef();
347}
348
349StringRef llvm::dwarf::DefaultedMemberString(unsigned DefaultedEncodings) {
350 switch (DefaultedEncodings) {
351 // Defaulted Member Encodings codes
352 case DW_DEFAULTED_no:
353 return "DW_DEFAULTED_no";
354 case DW_DEFAULTED_in_class:
355 return "DW_DEFAULTED_in_class";
356 case DW_DEFAULTED_out_of_class:
357 return "DW_DEFAULTED_out_of_class";
358 }
359 return StringRef();
360}
361
363 switch (Visibility) {
364 case DW_VIS_local:
365 return "DW_VIS_local";
366 case DW_VIS_exported:
367 return "DW_VIS_exported";
368 case DW_VIS_qualified:
369 return "DW_VIS_qualified";
370 }
371 return StringRef();
372}
373
375 switch (Virtuality) {
376 default:
377 return StringRef();
378#define HANDLE_DW_VIRTUALITY(ID, NAME) \
379 case DW_VIRTUALITY_##NAME: \
380 return "DW_VIRTUALITY_" #NAME;
381#include "llvm/BinaryFormat/Dwarf.def"
382 }
383}
384
387#define HANDLE_DW_VIRTUALITY(ID, NAME) \
388 .Case("DW_VIRTUALITY_" #NAME, DW_VIRTUALITY_##NAME)
389#include "llvm/BinaryFormat/Dwarf.def"
391}
392
394 switch (EnumKind) {
395 default:
396 return StringRef();
397#define HANDLE_DW_APPLE_ENUM_KIND(ID, NAME) \
398 case DW_APPLE_ENUM_KIND_##NAME: \
399 return "DW_APPLE_ENUM_KIND_" #NAME;
400#include "llvm/BinaryFormat/Dwarf.def"
401 }
402}
403
406#define HANDLE_DW_APPLE_ENUM_KIND(ID, NAME) \
407 .Case("DW_APPLE_ENUM_KIND_" #NAME, DW_APPLE_ENUM_KIND_##NAME)
408#include "llvm/BinaryFormat/Dwarf.def"
410}
411
413 switch (Language) {
414 default:
415 return StringRef();
416#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
417 case DW_LANG_##NAME: \
418 return "DW_LANG_" #NAME;
419#include "llvm/BinaryFormat/Dwarf.def"
420 }
421}
422
425#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
426 .Case("DW_LANG_" #NAME, DW_LANG_##NAME)
427#include "llvm/BinaryFormat/Dwarf.def"
428 .Default(0);
429}
430
432 switch (Lang) {
433 default:
434 return 0;
435#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
436 case DW_LANG_##NAME: \
437 return VERSION;
438#include "llvm/BinaryFormat/Dwarf.def"
439 }
440}
441
443 switch (Lang) {
444 default:
445 return 0;
446#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
447 case DW_LANG_##NAME: \
448 return DWARF_VENDOR_##VENDOR;
449#include "llvm/BinaryFormat/Dwarf.def"
450 }
451}
452
453std::optional<unsigned>
455 switch (Lang) {
456 default:
457 return std::nullopt;
458#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
459 case DW_LANG_##NAME: \
460 return LOWER_BOUND;
461#include "llvm/BinaryFormat/Dwarf.def"
462 }
463}
464
466 switch (lname) {
467#define HANDLE_DW_LNAME(ID, NAME, DESC, LOWER_BOUND) \
468 case DW_LNAME_##NAME: \
469 return DESC;
470#include "llvm/BinaryFormat/Dwarf.def"
471 }
472 return "Unknown";
473}
474
477 switch (Name) {
478 // YYYY
479 case DW_LNAME_Ada: {
480 if (Version <= 1983)
481 return "Ada 83";
482 if (Version <= 1995)
483 return "Ada 95";
484 if (Version <= 2005)
485 return "Ada 2005";
486 if (Version <= 2012)
487 return "Ada 2012";
488 } break;
489
490 case DW_LNAME_Cobol: {
491 if (Version <= 1974)
492 return "COBOL-74";
493 if (Version <= 1985)
494 return "COBOL-85";
495 } break;
496
497 case DW_LNAME_Fortran: {
498 if (Version <= 1977)
499 return "FORTRAN 77";
500 if (Version <= 1990)
501 return "FORTRAN 90";
502 if (Version <= 1995)
503 return "Fortran 95";
504 if (Version <= 2003)
505 return "Fortran 2003";
506 if (Version <= 2008)
507 return "Fortran 2008";
508 if (Version <= 2018)
509 return "Fortran 2018";
510 } break;
511
512 // YYYYMM
513 case DW_LNAME_C: {
514 if (Version == 0)
515 break;
516 if (Version <= 198912)
517 return "C89";
518 if (Version <= 199901)
519 return "C99";
520 if (Version <= 201112)
521 return "C11";
522 if (Version <= 201710)
523 return "C17";
524 } break;
525
526 case DW_LNAME_C_plus_plus: {
527 if (Version == 0)
528 break;
529 if (Version <= 199711)
530 return "C++98";
531 if (Version <= 200310)
532 return "C++03";
533 if (Version <= 201103)
534 return "C++11";
535 if (Version <= 201402)
536 return "C++14";
537 if (Version <= 201703)
538 return "C++17";
539 if (Version <= 202002)
540 return "C++20";
541 } break;
542
543 case DW_LNAME_ObjC_plus_plus:
544 case DW_LNAME_ObjC:
545 case DW_LNAME_Move:
546 case DW_LNAME_SYCL:
547 case DW_LNAME_BLISS:
548 case DW_LNAME_Crystal:
549 case DW_LNAME_D:
550 case DW_LNAME_Dylan:
551 case DW_LNAME_Go:
552 case DW_LNAME_Haskell:
553 case DW_LNAME_HIP:
554 case DW_LNAME_HLSL:
555 case DW_LNAME_Java:
556 case DW_LNAME_Julia:
557 case DW_LNAME_Kotlin:
558 case DW_LNAME_Modula2:
559 case DW_LNAME_Modula3:
560 case DW_LNAME_OCaml:
561 case DW_LNAME_OpenCL_C:
562 case DW_LNAME_Pascal:
563 case DW_LNAME_PLI:
564 case DW_LNAME_Python:
565 case DW_LNAME_RenderScript:
566 case DW_LNAME_Rust:
567 case DW_LNAME_Swift:
568 case DW_LNAME_UPC:
569 case DW_LNAME_Zig:
570 case DW_LNAME_Assembly:
571 case DW_LNAME_C_sharp:
572 case DW_LNAME_Mojo:
573 case DW_LNAME_GLSL:
574 case DW_LNAME_GLSL_ES:
575 case DW_LNAME_OpenCL_CPP:
576 case DW_LNAME_CPP_for_OpenCL:
577 case DW_LNAME_Ruby:
578 case DW_LNAME_Hylo:
579 case DW_LNAME_Metal:
580 break;
581 }
582
583 // Fallback to un-versioned name.
584 return LanguageDescription(Name);
585}
586
588 switch (Lang) {
589#define HANDLE_DW_LNAME(ID, NAME, DESC, LOWER_BOUND) \
590 case DW_LNAME_##NAME: \
591 return "DW_LNAME_" #NAME;
592#include "llvm/BinaryFormat/Dwarf.def"
593 }
594
595 return {};
596}
597
598unsigned
601#define HANDLE_DW_LNAME(ID, NAME, DESC, LOWER_BOUND) \
602 .Case("DW_LNAME_" #NAME, DW_LNAME_##NAME)
603#include "llvm/BinaryFormat/Dwarf.def"
604 .Default(0);
605}
606
608 switch (Case) {
610 return "DW_ID_case_sensitive";
611 case DW_ID_up_case:
612 return "DW_ID_up_case";
613 case DW_ID_down_case:
614 return "DW_ID_down_case";
616 return "DW_ID_case_insensitive";
617 }
618 return StringRef();
619}
620
622 switch (CC) {
623 default:
624 return StringRef();
625#define HANDLE_DW_CC(ID, NAME) \
626 case DW_CC_##NAME: \
627 return "DW_CC_" #NAME;
628#include "llvm/BinaryFormat/Dwarf.def"
629 }
630}
631
633 return StringSwitch<unsigned>(CCString)
634#define HANDLE_DW_CC(ID, NAME) .Case("DW_CC_" #NAME, DW_CC_##NAME)
635#include "llvm/BinaryFormat/Dwarf.def"
636 .Default(0);
637}
638
640 switch (Code) {
642 return "DW_INL_not_inlined";
643 case DW_INL_inlined:
644 return "DW_INL_inlined";
646 return "DW_INL_declared_not_inlined";
648 return "DW_INL_declared_inlined";
649 }
650 return StringRef();
651}
652
654 switch (Order) {
655 case DW_ORD_row_major:
656 return "DW_ORD_row_major";
657 case DW_ORD_col_major:
658 return "DW_ORD_col_major";
659 }
660 return StringRef();
661}
662
664 switch (Standard) {
665 default:
666 return StringRef();
667#define HANDLE_DW_LNS(ID, NAME) \
668 case DW_LNS_##NAME: \
669 return "DW_LNS_" #NAME;
670#include "llvm/BinaryFormat/Dwarf.def"
671 }
672}
673
675 switch (Encoding) {
676 default:
677 return StringRef();
678#define HANDLE_DW_LNE(ID, NAME) \
679 case DW_LNE_##NAME: \
680 return "DW_LNE_" #NAME;
681#include "llvm/BinaryFormat/Dwarf.def"
682 }
683}
684
686 switch (Encoding) {
687 // Macinfo Type Encodings
689 return "DW_MACINFO_define";
690 case DW_MACINFO_undef:
691 return "DW_MACINFO_undef";
693 return "DW_MACINFO_start_file";
695 return "DW_MACINFO_end_file";
697 return "DW_MACINFO_vendor_ext";
699 return "DW_MACINFO_invalid";
700 }
701 return StringRef();
702}
703
706 .Case("DW_MACINFO_define", DW_MACINFO_define)
707 .Case("DW_MACINFO_undef", DW_MACINFO_undef)
708 .Case("DW_MACINFO_start_file", DW_MACINFO_start_file)
709 .Case("DW_MACINFO_end_file", DW_MACINFO_end_file)
710 .Case("DW_MACINFO_vendor_ext", DW_MACINFO_vendor_ext)
712}
713
715 switch (Encoding) {
716 default:
717 return StringRef();
718#define HANDLE_DW_MACRO(ID, NAME) \
719 case DW_MACRO_##NAME: \
720 return "DW_MACRO_" #NAME;
721#include "llvm/BinaryFormat/Dwarf.def"
722 }
723}
724
726 switch (Encoding) {
727 default:
728 return StringRef();
729#define HANDLE_DW_MACRO_GNU(ID, NAME) \
730 case DW_MACRO_GNU_##NAME: \
731 return "DW_MACRO_GNU_" #NAME;
732#include "llvm/BinaryFormat/Dwarf.def"
733 }
734}
735
738#define HANDLE_DW_MACRO(ID, NAME) .Case("DW_MACRO_" #NAME, ID)
739#include "llvm/BinaryFormat/Dwarf.def"
741}
743 switch (Encoding) {
744 default:
745 return StringRef();
746#define HANDLE_DW_RLE(ID, NAME) \
747 case DW_RLE_##NAME: \
748 return "DW_RLE_" #NAME;
749#include "llvm/BinaryFormat/Dwarf.def"
750 }
751}
752
754 switch (Encoding) {
755 default:
756 return StringRef();
757#define HANDLE_DW_LLE(ID, NAME) \
758 case DW_LLE_##NAME: \
759 return "DW_LLE_" #NAME;
760#include "llvm/BinaryFormat/Dwarf.def"
761 }
762}
763
765 Triple::ArchType Arch) {
767#define SELECT_AARCH64 (Arch == llvm::Triple::aarch64_be || Arch == llvm::Triple::aarch64)
768#define SELECT_MIPS64 Arch == llvm::Triple::mips64
769#define SELECT_SPARC (Arch == llvm::Triple::sparc || Arch == llvm::Triple::sparcv9)
770#define SELECT_X86 (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64)
771#define HANDLE_DW_CFA(ID, NAME)
772#define HANDLE_DW_CFA_PRED(ID, NAME, PRED) \
773 if (ID == Encoding && PRED) \
774 return "DW_CFA_" #NAME;
775#include "llvm/BinaryFormat/Dwarf.def"
776
777 switch (Encoding) {
778 default:
779 return StringRef();
780#define HANDLE_DW_CFA_PRED(ID, NAME, PRED)
781#define HANDLE_DW_CFA(ID, NAME) \
782 case DW_CFA_##NAME: \
783 return "DW_CFA_" #NAME;
784#include "llvm/BinaryFormat/Dwarf.def"
785
786#undef SELECT_X86
787#undef SELECT_SPARC
788#undef SELECT_MIPS64
789#undef SELECT_AARCH64
790 }
791}
792
794 switch (Prop) {
795 default:
796 return StringRef();
797#define HANDLE_DW_APPLE_PROPERTY(ID, NAME) \
798 case DW_APPLE_PROPERTY_##NAME: \
799 return "DW_APPLE_PROPERTY_" #NAME;
800#include "llvm/BinaryFormat/Dwarf.def"
801 }
802}
803
805 switch (UT) {
806 default:
807 return StringRef();
808#define HANDLE_DW_UT(ID, NAME) \
809 case DW_UT_##NAME: \
810 return "DW_UT_" #NAME;
811#include "llvm/BinaryFormat/Dwarf.def"
812 }
813}
814
816 switch (AT) {
818 return "DW_ATOM_null";
820 return "DW_ATOM_die_offset";
822 return "DW_ATOM_cu_offset";
823 case DW_ATOM_die_tag:
824 return "DW_ATOM_die_tag";
827 return "DW_ATOM_type_flags";
829 return "DW_ATOM_qual_name_hash";
830 }
831 return StringRef();
832}
833
835 switch (Kind) {
836 case GIEK_NONE:
837 return "NONE";
838 case GIEK_TYPE:
839 return "TYPE";
840 case GIEK_VARIABLE:
841 return "VARIABLE";
842 case GIEK_FUNCTION:
843 return "FUNCTION";
844 case GIEK_OTHER:
845 return "OTHER";
846 case GIEK_UNUSED5:
847 return "UNUSED5";
848 case GIEK_UNUSED6:
849 return "UNUSED6";
850 case GIEK_UNUSED7:
851 return "UNUSED7";
852 }
853 llvm_unreachable("Unknown GDBIndexEntryKind value");
854}
855
858 switch (Linkage) {
859 case GIEL_EXTERNAL:
860 return "EXTERNAL";
861 case GIEL_STATIC:
862 return "STATIC";
863 }
864 llvm_unreachable("Unknown GDBIndexEntryLinkage value");
865}
866
868 switch (Attr) {
869 case DW_AT_accessibility:
870 return AccessibilityString(Val);
871 case DW_AT_virtuality:
872 return VirtualityString(Val);
873 case DW_AT_language:
874 return LanguageString(Val);
875 case DW_AT_encoding:
876 return AttributeEncodingString(Val);
877 case DW_AT_decimal_sign:
878 return DecimalSignString(Val);
879 case DW_AT_endianity:
880 return EndianityString(Val);
881 case DW_AT_visibility:
882 return VisibilityString(Val);
883 case DW_AT_identifier_case:
884 return CaseString(Val);
885 case DW_AT_calling_convention:
886 return ConventionString(Val);
887 case DW_AT_inline:
888 return InlineCodeString(Val);
889 case DW_AT_ordering:
890 return ArrayOrderString(Val);
891 case DW_AT_APPLE_runtime_class:
892 return LanguageString(Val);
893 case DW_AT_defaulted:
894 return DefaultedMemberString(Val);
895 case DW_AT_APPLE_enum_kind:
896 return EnumKindString(Val);
897 case DW_AT_language_name:
898 return SourceLanguageNameString(static_cast<SourceLanguageName>(Val));
899 }
900
901 return StringRef();
902}
903
905 switch (Atom) {
906 case DW_ATOM_null:
907 return "NULL";
908 case DW_ATOM_die_tag:
909 return TagString(Val);
910 }
911
912 return StringRef();
913}
914
916 switch (Idx) {
917 default:
918 return StringRef();
919#define HANDLE_DW_IDX(ID, NAME) \
920 case DW_IDX_##NAME: \
921 return "DW_IDX_" #NAME;
922#include "llvm/BinaryFormat/Dwarf.def"
923 }
924}
925
927 FormParams Params) {
928 switch (Form) {
929 case DW_FORM_addr:
930 if (Params)
931 return Params.AddrSize;
932 return std::nullopt;
933
934 case DW_FORM_block: // ULEB128 length L followed by L bytes.
935 case DW_FORM_block1: // 1 byte length L followed by L bytes.
936 case DW_FORM_block2: // 2 byte length L followed by L bytes.
937 case DW_FORM_block4: // 4 byte length L followed by L bytes.
938 case DW_FORM_string: // C-string with null terminator.
939 case DW_FORM_sdata: // SLEB128.
940 case DW_FORM_udata: // ULEB128.
941 case DW_FORM_ref_udata: // ULEB128.
942 case DW_FORM_indirect: // ULEB128.
943 case DW_FORM_exprloc: // ULEB128 length L followed by L bytes.
944 case DW_FORM_strx: // ULEB128.
945 case DW_FORM_addrx: // ULEB128.
946 case DW_FORM_loclistx: // ULEB128.
947 case DW_FORM_rnglistx: // ULEB128.
948 case DW_FORM_GNU_addr_index: // ULEB128.
949 case DW_FORM_GNU_str_index: // ULEB128.
950 return std::nullopt;
951
952 case DW_FORM_ref_addr:
953 if (Params)
954 return Params.getRefAddrByteSize();
955 return std::nullopt;
956
957 case DW_FORM_flag:
958 case DW_FORM_data1:
959 case DW_FORM_ref1:
960 case DW_FORM_strx1:
961 case DW_FORM_addrx1:
962 return 1;
963
964 case DW_FORM_data2:
965 case DW_FORM_ref2:
966 case DW_FORM_strx2:
967 case DW_FORM_addrx2:
968 return 2;
969
970 case DW_FORM_strx3:
971 case DW_FORM_addrx3:
972 return 3;
973
974 case DW_FORM_data4:
975 case DW_FORM_ref4:
976 case DW_FORM_ref_sup4:
977 case DW_FORM_strx4:
978 case DW_FORM_addrx4:
979 return 4;
980
981 case DW_FORM_strp:
982 case DW_FORM_GNU_ref_alt:
983 case DW_FORM_GNU_strp_alt:
984 case DW_FORM_line_strp:
985 case DW_FORM_sec_offset:
986 case DW_FORM_strp_sup:
987 if (Params)
988 return Params.getDwarfOffsetByteSize();
989 return std::nullopt;
990
991 case DW_FORM_data8:
992 case DW_FORM_ref8:
993 case DW_FORM_ref_sig8:
994 case DW_FORM_ref_sup8:
995 return 8;
996
997 case DW_FORM_flag_present:
998 return 0;
999
1000 case DW_FORM_data16:
1001 return 16;
1002
1003 case DW_FORM_implicit_const:
1004 // The implicit value is stored in the abbreviation as a SLEB128, and
1005 // there no data in debug info.
1006 return 0;
1007
1008 default:
1009 break;
1010 }
1011 return std::nullopt;
1012}
1013
1015 bool ExtensionsOk) {
1017 unsigned FV = FormVersion(F);
1018 return FV > 0 && FV <= Version;
1019 }
1020 return ExtensionsOk;
1021}
1022
1024 switch (Format) {
1025 case DWARF32:
1026 return "DWARF32";
1027 case DWARF64:
1028 return "DWARF64";
1029 }
1030 return StringRef();
1031}
1032
1034 return FormatString(IsDWARF64 ? DWARF64 : DWARF32);
1035}
1036
1038 switch (RLE) {
1039 default:
1040 return StringRef();
1041#define HANDLE_DW_RLE(ID, NAME) \
1042 case DW_RLE_##NAME: \
1043 return "DW_RLE_" #NAME;
1044#include "llvm/BinaryFormat/Dwarf.def"
1045 }
1046}
1047
1049 switch (AS) {
1050#define HANDLE_DW_ASPACE(ID, NAME) \
1051 case DW_ASPACE_LLVM_##NAME: \
1052 return "DW_ASPACE_LLVM_" #NAME;
1053#define HANDLE_DW_ASPACE_PRED(ID, NAME, PRED)
1054#include "llvm/BinaryFormat/Dwarf.def"
1055 default:
1056 break;
1057 }
1058
1059 bool SELECT_AMDGPU = TT.isAMDGPU();
1060#define HANDLE_DW_ASPACE(ID, NAME)
1061#define HANDLE_DW_ASPACE_PRED(ID, NAME, PRED) \
1062 if (DW_ASPACE_LLVM_##NAME == AS && PRED) \
1063 return "DW_ASPACE_LLVM_" #NAME;
1064#include "llvm/BinaryFormat/Dwarf.def"
1065
1066 return "";
1067}
1068
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
DXIL Resource Access
static unsigned getLlvmUserOperationEncoding(StringRef LlvmUserOperationEncodingString)
Definition Dwarf.cpp:193
static StringRef LlvmUserOperationEncodingString(unsigned Encoding)
Definition Dwarf.cpp:181
This file contains constants used for implementing Dwarf debug support.
#define F(x, y, z)
Definition MD5.cpp:54
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
@ UnknownArch
Definition Triple.h:50
LLVM_ABI StringRef LNExtendedString(unsigned Encoding)
Definition Dwarf.cpp:674
LLVM_ABI StringRef RangeListEncodingString(unsigned Encoding)
Definition Dwarf.cpp:742
LLVM_ABI StringRef CaseString(unsigned Case)
Definition Dwarf.cpp:607
LLVM_ABI StringRef SourceLanguageNameString(SourceLanguageName Lang)
Definition Dwarf.cpp:587
LLVM_ABI StringRef VisibilityString(unsigned Visibility)
Definition Dwarf.cpp:362
LLVM_ABI StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage)
Definition Dwarf.cpp:857
LLVM_ABI StringRef AttributeString(unsigned Attribute)
Definition Dwarf.cpp:72
LLVM_ABI StringRef CallFrameString(unsigned Encoding, Triple::ArchType Arch)
Definition Dwarf.cpp:764
LLVM_ABI StringRef FormEncodingString(unsigned Encoding)
Definition Dwarf.cpp:105
LLVM_ABI StringRef ArrayOrderString(unsigned Order)
Definition Dwarf.cpp:653
LLVM_ABI StringRef MacroString(unsigned Encoding)
Definition Dwarf.cpp:714
LLVM_ABI StringRef EnumKindString(unsigned EnumKind)
Definition Dwarf.cpp:393
LLVM_ABI StringRef LocListEncodingString(unsigned Encoding)
Definition Dwarf.cpp:753
LLVM_ABI StringRef IndexString(unsigned Idx)
Definition Dwarf.cpp:915
LLVM_ABI StringRef RLEString(unsigned RLE)
Definition Dwarf.cpp:1037
LLVM_ABI StringRef SubOperationEncodingString(unsigned OpEncoding, unsigned SubOpEncoding)
Definition Dwarf.cpp:202
LLVM_ABI StringRef LanguageString(unsigned Language)
Definition Dwarf.cpp:412
LLVM_ABI StringRef DecimalSignString(unsigned Sign)
Definition Dwarf.cpp:304
LLVM_ABI StringRef VirtualityString(unsigned Virtuality)
Definition Dwarf.cpp:374
LLVM_ABI StringRef AttributeEncodingString(unsigned Encoding)
Definition Dwarf.cpp:263
LLVM_ABI StringRef AddressSpaceString(unsigned AS, const llvm::Triple &TT)
Definition Dwarf.cpp:1048
LLVM_ABI StringRef ChildrenString(unsigned Children)
Definition Dwarf.cpp:62
LLVM_ABI StringRef ApplePropertyString(unsigned)
Definition Dwarf.cpp:793
LLVM_ABI StringRef AtomTypeString(unsigned Atom)
Definition Dwarf.cpp:815
LLVM_ABI StringRef FormatString(DwarfFormat Format)
Definition Dwarf.cpp:1023
LLVM_ABI StringRef GnuMacroString(unsigned Encoding)
Definition Dwarf.cpp:725
LLVM_ABI StringRef EndianityString(unsigned Endian)
Definition Dwarf.cpp:320
LLVM_ABI StringRef ConventionString(unsigned Convention)
Definition Dwarf.cpp:621
LLVM_ABI StringRef MacinfoString(unsigned Encoding)
Definition Dwarf.cpp:685
LLVM_ABI StringRef OperationEncodingString(unsigned Encoding)
Definition Dwarf.cpp:138
LLVM_ABI StringRef UnitTypeString(unsigned)
Definition Dwarf.cpp:804
LLVM_ABI StringRef InlineCodeString(unsigned Code)
Definition Dwarf.cpp:639
LLVM_ABI StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind)
Definition Dwarf.cpp:834
LLVM_ABI StringRef TagString(unsigned Tag)
Definition Dwarf.cpp:21
LLVM_ABI StringRef LNStandardString(unsigned Standard)
Definition Dwarf.cpp:663
LLVM_ABI StringRef AccessibilityString(unsigned Access)
Definition Dwarf.cpp:336
LLVM_ABI StringRef DefaultedMemberString(unsigned DefaultedEncodings)
Definition Dwarf.cpp:349
LLVM_ABI unsigned getSourceLanguageName(StringRef SourceLanguageNameString)
Definition Dwarf.cpp:599
LLVM_ABI unsigned getSubOperationEncoding(unsigned OpEncoding, StringRef SubOperationEncodingString)
Definition Dwarf.cpp:209
LLVM_ABI unsigned getOperationEncoding(StringRef OperationEncodingString)
Definition Dwarf.cpp:165
LLVM_ABI unsigned getAttributeEncoding(StringRef EncodingString)
Definition Dwarf.cpp:274
LLVM_ABI unsigned getTag(StringRef TagString)
Definition Dwarf.cpp:32
LLVM_ABI unsigned getCallingConvention(StringRef LanguageString)
Definition Dwarf.cpp:632
LLVM_ABI unsigned getLanguage(StringRef LanguageString)
Definition Dwarf.cpp:423
LLVM_ABI unsigned getVirtuality(StringRef VirtualityString)
Definition Dwarf.cpp:385
LLVM_ABI unsigned getEnumKind(StringRef EnumKindString)
Definition Dwarf.cpp:404
LLVM_ABI unsigned getMacro(StringRef MacroString)
Definition Dwarf.cpp:736
LLVM_ABI unsigned getMacinfo(StringRef MacinfoString)
Definition Dwarf.cpp:704
LLVM_ABI unsigned AttributeEncodingVendor(TypeKind E)
Definition Dwarf.cpp:293
LLVM_ABI unsigned FormVendor(Form F)
Definition Dwarf.cpp:127
LLVM_ABI unsigned AttributeVendor(Attribute A)
Definition Dwarf.cpp:94
LLVM_ABI unsigned OperationVendor(LocationAtom O)
Definition Dwarf.cpp:252
LLVM_ABI unsigned TagVendor(Tag T)
Definition Dwarf.cpp:51
LLVM_ABI unsigned LanguageVendor(SourceLanguage L)
Definition Dwarf.cpp:442
LLVM_ABI unsigned OperationVersion(LocationAtom O)
Definition Dwarf.cpp:215
LLVM_ABI unsigned AttributeVersion(Attribute A)
Definition Dwarf.cpp:83
LLVM_ABI unsigned LanguageVersion(SourceLanguage L)
Definition Dwarf.cpp:431
LLVM_ABI unsigned AttributeEncodingVersion(TypeKind E)
Definition Dwarf.cpp:282
LLVM_ABI unsigned TagVersion(Tag T)
Definition Dwarf.cpp:40
LLVM_ABI unsigned FormVersion(Form F)
Definition Dwarf.cpp:116
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Calculates the starting offsets for various sections within the .debug_names section.
Definition Dwarf.h:35
@ DW_INL_not_inlined
Definition Dwarf.h:776
@ DW_INL_declared_not_inlined
Definition Dwarf.h:778
@ DW_INL_inlined
Definition Dwarf.h:777
@ DW_INL_declared_inlined
Definition Dwarf.h:779
@ DW_ACCESS_private
Definition Dwarf.h:187
@ DW_ACCESS_protected
Definition Dwarf.h:186
@ DW_ACCESS_public
Definition Dwarf.h:185
Attribute
Attributes.
Definition Dwarf.h:125
LLVM_ABI std::optional< unsigned > LanguageLowerBound(SourceLanguage L)
Definition Dwarf.cpp:454
LLVM_ABI StringRef AtomValueString(uint16_t Atom, unsigned Val)
Returns the symbolic string representing Val when used as a value for atom Atom.
Definition Dwarf.cpp:904
SourceLanguageName
Definition Dwarf.h:223
LLVM_ABI std::optional< unsigned > OperationArity(LocationAtom O)
The arity of the given LocationAtom.
Definition Dwarf.cpp:239
@ DW_VIS_local
Definition Dwarf.h:192
@ DW_VIS_exported
Definition Dwarf.h:193
@ DW_VIS_qualified
Definition Dwarf.h:194
@ DW_ORD_row_major
Definition Dwarf.h:784
@ DW_ORD_col_major
Definition Dwarf.h:785
@ DW_END_lo_user
Definition Dwarf.h:179
@ DW_END_hi_user
Definition Dwarf.h:180
@ DW_OP_LLVM_entry_value
Only used in LLVM metadata.
Definition Dwarf.h:147
@ DW_OP_LLVM_implicit_pointer
Only used in LLVM metadata.
Definition Dwarf.h:148
@ DW_OP_LLVM_extract_bits_zext
Only used in LLVM metadata.
Definition Dwarf.h:151
@ DW_OP_LLVM_tag_offset
Only used in LLVM metadata.
Definition Dwarf.h:146
@ DW_OP_LLVM_fragment
Only used in LLVM metadata.
Definition Dwarf.h:144
@ DW_OP_LLVM_arg
Only used in LLVM metadata.
Definition Dwarf.h:149
@ DW_OP_LLVM_convert
Only used in LLVM metadata.
Definition Dwarf.h:145
@ DW_OP_LLVM_extract_bits_sext
Only used in LLVM metadata.
Definition Dwarf.h:150
@ DW_ID_down_case
Definition Dwarf.h:756
@ DW_ID_case_insensitive
Definition Dwarf.h:757
@ DW_ID_case_sensitive
Definition Dwarf.h:754
@ DW_ID_up_case
Definition Dwarf.h:755
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
Definition Dwarf.h:93
@ DWARF64
Definition Dwarf.h:93
@ DWARF32
Definition Dwarf.h:93
LLVM_ABI bool isValidFormForVersion(Form F, unsigned Version, bool ExtensionsOk=true)
Tells whether the specified form is defined in the specified version, or is an extension if extension...
Definition Dwarf.cpp:1014
@ DW_MACINFO_undef
Definition Dwarf.h:818
@ DW_MACINFO_start_file
Definition Dwarf.h:819
@ DW_MACINFO_end_file
Definition Dwarf.h:820
@ DW_MACINFO_define
Definition Dwarf.h:817
@ DW_MACINFO_vendor_ext
Definition Dwarf.h:821
LLVM_ABI std::optional< uint8_t > getFixedFormByteSize(dwarf::Form Form, FormParams Params)
Get the fixed byte size for a given form.
Definition Dwarf.cpp:926
GDBIndexEntryKind
Definition Dwarf.h:971
@ GIEK_NONE
Definition Dwarf.h:972
@ GIEK_UNUSED7
Definition Dwarf.h:979
@ GIEK_TYPE
Definition Dwarf.h:973
@ GIEK_UNUSED6
Definition Dwarf.h:978
@ GIEK_OTHER
Definition Dwarf.h:976
@ GIEK_FUNCTION
Definition Dwarf.h:975
@ GIEK_UNUSED5
Definition Dwarf.h:977
@ GIEK_VARIABLE
Definition Dwarf.h:974
@ DW_CHILDREN_no
Definition Dwarf.h:865
@ DW_CHILDREN_yes
Definition Dwarf.h:866
LLVM_ABI StringRef AttributeValueString(uint16_t Attr, unsigned Val)
Returns the symbolic string representing Val when used as a value for attribute Attr.
Definition Dwarf.cpp:867
LLVM_ABI std::optional< unsigned > OperationOperands(LocationAtom O)
The number of operands for the given LocationAtom.
Definition Dwarf.cpp:226
@ DW_DS_leading_separate
Definition Dwarf.h:171
@ DW_DS_trailing_separate
Definition Dwarf.h:172
@ DW_DS_trailing_overpunch
Definition Dwarf.h:170
@ DW_DS_leading_overpunch
Definition Dwarf.h:169
@ DW_DS_unsigned
Definition Dwarf.h:168
LLVM_ABI llvm::StringRef LanguageDescription(SourceLanguageName name)
Returns a version-independent language name.
Definition Dwarf.cpp:465
@ DW_ATOM_type_flags
Definition Dwarf.h:944
@ DW_ATOM_null
Definition Dwarf.h:939
@ DW_ATOM_die_tag
Definition Dwarf.h:943
@ DW_ATOM_qual_name_hash
Definition Dwarf.h:947
@ DW_ATOM_die_offset
Marker as the end of a list of atoms.
Definition Dwarf.h:940
@ DW_ATOM_type_type_flags
Definition Dwarf.h:946
@ DW_ATOM_cu_offset
Definition Dwarf.h:941
@ DW_TAG_invalid
LLVM mock tags (see also llvm/BinaryFormat/Dwarf.def).
Definition Dwarf.h:48
@ DW_MACINFO_invalid
Macinfo type for invalid results.
Definition Dwarf.h:50
@ DW_APPLE_ENUM_KIND_invalid
Enum kind for invalid results.
Definition Dwarf.h:51
@ DW_VIRTUALITY_invalid
Virtuality for invalid results.
Definition Dwarf.h:49
@ DWARF_VENDOR_DWARF
Identifiers we use to distinguish vendor extensions.
Definition Dwarf.h:71
GDBIndexEntryLinkage
Definition Dwarf.h:982
@ GIEL_EXTERNAL
Definition Dwarf.h:982
@ GIEL_STATIC
Definition Dwarf.h:982
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
FunctionAddr VTableAddr uintptr_t uintptr_t Version
Definition InstrProf.h:302
DWARFExpression::Operation Op
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
Definition Dwarf.h:1110
uint8_t getDwarfOffsetByteSize() const
The size of a reference is determined by the DWARF 32/64-bit format.
Definition Dwarf.h:1128
uint8_t getRefAddrByteSize() const
The definition of the size of form DW_FORM_ref_addr depends on the version.
Definition Dwarf.h:1121