1//===-- llvm/BinaryFormat/Dwarf.cpp - Dwarf Framework ------------*- C++-*-===// 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 7//===----------------------------------------------------------------------===// 9// This file contains support for generic dwarf information. 11//===----------------------------------------------------------------------===// 25#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR, KIND) \ 27 return "DW_TAG_" #NAME;
28#include "llvm/BinaryFormat/Dwarf.def" 34#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR, KIND) \ 35 .Case("DW_TAG_" #NAME, DW_TAG_##NAME)
36#include "llvm/BinaryFormat/Dwarf.def" 44#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR, KIND) \ 47#include "llvm/BinaryFormat/Dwarf.def" 55#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR, KIND) \ 57 return DWARF_VENDOR_##VENDOR; 58#include "llvm/BinaryFormat/Dwarf.def" 65return"DW_CHILDREN_no";
67return"DW_CHILDREN_yes";
76#define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) \ 78 return "DW_AT_" #NAME;
79#include "llvm/BinaryFormat/Dwarf.def" 87#define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) \ 90#include "llvm/BinaryFormat/Dwarf.def" 98#define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) \ 100 return DWARF_VENDOR_##VENDOR; 101#include "llvm/BinaryFormat/Dwarf.def" 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" 120#define HANDLE_DW_FORM(ID, NAME, VERSION, VENDOR) \ 121 case DW_FORM_##NAME: \ 123#include "llvm/BinaryFormat/Dwarf.def" 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" 142#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \ 144 return "DW_OP_" #NAME;
145#include "llvm/BinaryFormat/Dwarf.def" 147return"DW_OP_LLVM_convert";
149return"DW_OP_LLVM_fragment";
151return"DW_OP_LLVM_tag_offset";
153return"DW_OP_LLVM_entry_value";
155return"DW_OP_LLVM_implicit_pointer";
157return"DW_OP_LLVM_arg";
159return"DW_OP_LLVM_extract_bits_sext";
161return"DW_OP_LLVM_extract_bits_zext";
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" 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" 195#define HANDLE_DW_OP_LLVM_USEROP(ID, NAME) .Case(#NAME, DW_OP_LLVM_##NAME) 196#include "llvm/BinaryFormat/Dwarf.def" 198assert(E &&
"unhandled DWARF operation string with LLVM user op");
203unsigned SubOpEncoding) {
204assert(OpEncoding == DW_OP_LLVM_user);
211assert(OpEncoding == DW_OP_LLVM_user);
219#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \ 222#include "llvm/BinaryFormat/Dwarf.def" 230#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \ 232 if (OPERANDS == -1) \ 233 return std::nullopt; \ 235#include "llvm/BinaryFormat/Dwarf.def" 243#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \ 246 return std::nullopt; \ 248#include "llvm/BinaryFormat/Dwarf.def" 256#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \ 258 return DWARF_VENDOR_##VENDOR; 259#include "llvm/BinaryFormat/Dwarf.def" 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" 276#define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) \ 277 .Case("DW_ATE_" #NAME, DW_ATE_##NAME)
278#include "llvm/BinaryFormat/Dwarf.def" 286#define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) \ 287 case DW_ATE_##NAME: \ 289#include "llvm/BinaryFormat/Dwarf.def" 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" 307return"DW_DS_unsigned";
309return"DW_DS_leading_overpunch";
311return"DW_DS_trailing_overpunch";
313return"DW_DS_leading_separate";
315return"DW_DS_trailing_separate";
323return"DW_END_default";
327return"DW_END_little";
329return"DW_END_lo_user";
331return"DW_END_hi_user";
338// Accessibility codes 340return"DW_ACCESS_public";
342return"DW_ACCESS_protected";
344return"DW_ACCESS_private";
350switch (DefaultedEncodings) {
351// Defaulted Member Encodings codes 353return"DW_DEFAULTED_no";
354case DW_DEFAULTED_in_class:
355return"DW_DEFAULTED_in_class";
356case DW_DEFAULTED_out_of_class:
357return"DW_DEFAULTED_out_of_class";
367return"DW_VIS_exported";
369return"DW_VIS_qualified";
378#define HANDLE_DW_VIRTUALITY(ID, NAME) \ 379 case DW_VIRTUALITY_##NAME: \ 380 return "DW_VIRTUALITY_" #NAME;
381#include "llvm/BinaryFormat/Dwarf.def" 387#define HANDLE_DW_VIRTUALITY(ID, NAME) \ 388 .Case("DW_VIRTUALITY_" #NAME, DW_VIRTUALITY_##NAME)
389#include "llvm/BinaryFormat/Dwarf.def" 397#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \ 398 case DW_LANG_##NAME: \ 399 return "DW_LANG_" #NAME;
400#include "llvm/BinaryFormat/Dwarf.def" 406#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \ 407 .Case("DW_LANG_" #NAME, DW_LANG_##NAME)
408#include "llvm/BinaryFormat/Dwarf.def" 416#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \ 417 case DW_LANG_##NAME: \ 419#include "llvm/BinaryFormat/Dwarf.def" 427#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \ 428 case DW_LANG_##NAME: \ 429 return DWARF_VENDOR_##VENDOR; 430#include "llvm/BinaryFormat/Dwarf.def" 434std::optional<unsigned>
439#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \ 440 case DW_LANG_##NAME: \ 442#include "llvm/BinaryFormat/Dwarf.def" 448#define HANDLE_DW_LNAME(ID, NAME, DESC, LOWER_BOUND) \ 449 case DW_LNAME_##NAME: \ 451#include "llvm/BinaryFormat/Dwarf.def" 459return"DW_ID_case_sensitive";
461return"DW_ID_up_case";
463return"DW_ID_down_case";
465return"DW_ID_case_insensitive";
474#define HANDLE_DW_CC(ID, NAME) \ 476 return "DW_CC_" #NAME;
477#include "llvm/BinaryFormat/Dwarf.def" 483#define HANDLE_DW_CC(ID, NAME) .Case("DW_CC_" #NAME, DW_CC_##NAME)
484#include "llvm/BinaryFormat/Dwarf.def" 491return"DW_INL_not_inlined";
493return"DW_INL_inlined";
495return"DW_INL_declared_not_inlined";
497return"DW_INL_declared_inlined";
505return"DW_ORD_row_major";
507return"DW_ORD_col_major";
516#define HANDLE_DW_LNS(ID, NAME) \ 517 case DW_LNS_##NAME: \ 518 return "DW_LNS_" #NAME;
519#include "llvm/BinaryFormat/Dwarf.def" 527#define HANDLE_DW_LNE(ID, NAME) \ 528 case DW_LNE_##NAME: \ 529 return "DW_LNE_" #NAME;
530#include "llvm/BinaryFormat/Dwarf.def" 536// Macinfo Type Encodings 538return"DW_MACINFO_define";
540return"DW_MACINFO_undef";
542return"DW_MACINFO_start_file";
544return"DW_MACINFO_end_file";
546return"DW_MACINFO_vendor_ext";
548return"DW_MACINFO_invalid";
567#define HANDLE_DW_MACRO(ID, NAME) \ 568 case DW_MACRO_##NAME: \ 569 return "DW_MACRO_" #NAME;
570#include "llvm/BinaryFormat/Dwarf.def" 578#define HANDLE_DW_MACRO_GNU(ID, NAME) \ 579 case DW_MACRO_GNU_##NAME: \ 580 return "DW_MACRO_GNU_" #NAME;
581#include "llvm/BinaryFormat/Dwarf.def" 587#define HANDLE_DW_MACRO(ID, NAME) .Case("DW_MACRO_" #NAME, ID)
588#include "llvm/BinaryFormat/Dwarf.def" 595#define HANDLE_DW_RLE(ID, NAME) \ 596 case DW_RLE_##NAME: \ 597 return "DW_RLE_" #NAME;
598#include "llvm/BinaryFormat/Dwarf.def" 606#define HANDLE_DW_LLE(ID, NAME) \ 607 case DW_LLE_##NAME: \ 608 return "DW_LLE_" #NAME;
609#include "llvm/BinaryFormat/Dwarf.def" 616#define SELECT_AARCH64 (Arch == llvm::Triple::aarch64_be || Arch == llvm::Triple::aarch64) 617#define SELECT_MIPS64 Arch == llvm::Triple::mips64 618#define SELECT_SPARC (Arch == llvm::Triple::sparc || Arch == llvm::Triple::sparcv9) 619#define SELECT_X86 (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64) 620#define HANDLE_DW_CFA(ID, NAME) 621#define HANDLE_DW_CFA_PRED(ID, NAME, PRED) \ 622 if (ID == Encoding && PRED) \ 623 return "DW_CFA_" #NAME;
624#include "llvm/BinaryFormat/Dwarf.def" 629#define HANDLE_DW_CFA_PRED(ID, NAME, PRED) 630#define HANDLE_DW_CFA(ID, NAME) \ 631 case DW_CFA_##NAME: \ 632 return "DW_CFA_" #NAME;
633#include "llvm/BinaryFormat/Dwarf.def" 646#define HANDLE_DW_APPLE_PROPERTY(ID, NAME) \ 647 case DW_APPLE_PROPERTY_##NAME: \ 648 return "DW_APPLE_PROPERTY_" #NAME;
649#include "llvm/BinaryFormat/Dwarf.def" 657#define HANDLE_DW_UT(ID, NAME) \ 659 return "DW_UT_" #NAME;
660#include "llvm/BinaryFormat/Dwarf.def" 669return"DW_ATOM_die_offset";
671return"DW_ATOM_cu_offset";
673return"DW_ATOM_die_tag";
676return"DW_ATOM_type_flags";
678return"DW_ATOM_qual_name_hash";
718case DW_AT_accessibility:
720case DW_AT_virtuality:
726case DW_AT_decimal_sign:
730case DW_AT_visibility:
732case DW_AT_identifier_case:
734case DW_AT_calling_convention:
740case DW_AT_APPLE_runtime_class:
764#define HANDLE_DW_IDX(ID, NAME) \ 765 case DW_IDX_##NAME: \ 766 return "DW_IDX_" #NAME;
767#include "llvm/BinaryFormat/Dwarf.def" 779case DW_FORM_block:
// ULEB128 length L followed by L bytes. 780case DW_FORM_block1:
// 1 byte length L followed by L bytes. 781case DW_FORM_block2:
// 2 byte length L followed by L bytes. 782case DW_FORM_block4:
// 4 byte length L followed by L bytes. 783case DW_FORM_string:
// C-string with null terminator. 784case DW_FORM_sdata:
// SLEB128. 785case DW_FORM_udata:
// ULEB128. 786case DW_FORM_ref_udata:
// ULEB128. 787case DW_FORM_indirect:
// ULEB128. 788case DW_FORM_exprloc:
// ULEB128 length L followed by L bytes. 789case DW_FORM_strx:
// ULEB128. 790case DW_FORM_addrx:
// ULEB128. 791case DW_FORM_loclistx:
// ULEB128. 792case DW_FORM_rnglistx:
// ULEB128. 793case DW_FORM_GNU_addr_index:
// ULEB128. 794case DW_FORM_GNU_str_index:
// ULEB128. 797case DW_FORM_ref_addr:
821case DW_FORM_ref_sup4:
827case DW_FORM_GNU_ref_alt:
828case DW_FORM_GNU_strp_alt:
829case DW_FORM_line_strp:
830case DW_FORM_sec_offset:
831case DW_FORM_strp_sup:
838case DW_FORM_ref_sig8:
839case DW_FORM_ref_sup8:
842case DW_FORM_flag_present:
848case DW_FORM_implicit_const:
849// The implicit value is stored in the abbreviation as a SLEB128, and 850// there no data in debug info. 863return FV > 0 && FV <= Version;
886#define HANDLE_DW_RLE(ID, NAME) \ 887 case DW_RLE_##NAME: \ 888 return "DW_RLE_" #NAME;
889#include "llvm/BinaryFormat/Dwarf.def" Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static unsigned getLlvmUserOperationEncoding(StringRef LlvmUserOperationEncodingString)
static StringRef LlvmUserOperationEncodingString(unsigned Encoding)
This file contains constants used for implementing Dwarf debug support.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
This class represents an Operation in the Expression.
StringRef - Represent a constant reference to a string, i.e.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
StringRef LNExtendedString(unsigned Encoding)
StringRef RangeListEncodingString(unsigned Encoding)
StringRef CaseString(unsigned Case)
StringRef VisibilityString(unsigned Visibility)
StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage)
StringRef AttributeString(unsigned Attribute)
StringRef CallFrameString(unsigned Encoding, Triple::ArchType Arch)
StringRef FormEncodingString(unsigned Encoding)
StringRef ArrayOrderString(unsigned Order)
StringRef MacroString(unsigned Encoding)
StringRef LocListEncodingString(unsigned Encoding)
StringRef IndexString(unsigned Idx)
StringRef RLEString(unsigned RLE)
StringRef SubOperationEncodingString(unsigned OpEncoding, unsigned SubOpEncoding)
StringRef LanguageString(unsigned Language)
StringRef DecimalSignString(unsigned Sign)
StringRef VirtualityString(unsigned Virtuality)
StringRef AttributeEncodingString(unsigned Encoding)
StringRef ChildrenString(unsigned Children)
StringRef ApplePropertyString(unsigned)
StringRef AtomTypeString(unsigned Atom)
StringRef FormatString(DwarfFormat Format)
StringRef GnuMacroString(unsigned Encoding)
StringRef EndianityString(unsigned Endian)
StringRef ConventionString(unsigned Convention)
StringRef MacinfoString(unsigned Encoding)
StringRef OperationEncodingString(unsigned Encoding)
StringRef UnitTypeString(unsigned)
StringRef InlineCodeString(unsigned Code)
StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind)
StringRef TagString(unsigned Tag)
StringRef LNStandardString(unsigned Standard)
StringRef AccessibilityString(unsigned Access)
StringRef DefaultedMemberString(unsigned DefaultedEncodings)
unsigned getSubOperationEncoding(unsigned OpEncoding, StringRef SubOperationEncodingString)
unsigned getOperationEncoding(StringRef OperationEncodingString)
unsigned getAttributeEncoding(StringRef EncodingString)
unsigned getTag(StringRef TagString)
unsigned getCallingConvention(StringRef LanguageString)
unsigned getLanguage(StringRef LanguageString)
unsigned getVirtuality(StringRef VirtualityString)
unsigned getMacro(StringRef MacroString)
unsigned getMacinfo(StringRef MacinfoString)
unsigned AttributeEncodingVendor(TypeKind E)
unsigned FormVendor(Form F)
unsigned AttributeVendor(Attribute A)
unsigned OperationVendor(LocationAtom O)
unsigned TagVendor(Tag T)
unsigned LanguageVendor(SourceLanguage L)
unsigned OperationVersion(LocationAtom O)
unsigned AttributeVersion(Attribute A)
unsigned LanguageVersion(SourceLanguage L)
unsigned AttributeEncodingVersion(TypeKind E)
unsigned TagVersion(Tag T)
unsigned FormVersion(Form F)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ DW_INL_declared_not_inlined
@ DW_INL_declared_inlined
std::optional< unsigned > LanguageLowerBound(SourceLanguage L)
StringRef AtomValueString(uint16_t Atom, unsigned Val)
Returns the symbolic string representing Val when used as a value for atom Atom.
std::optional< unsigned > OperationArity(LocationAtom O)
The arity of the given LocationAtom.
@ DW_OP_LLVM_entry_value
Only used in LLVM metadata.
@ DW_OP_LLVM_implicit_pointer
Only used in LLVM metadata.
@ DW_OP_LLVM_extract_bits_zext
Only used in LLVM metadata.
@ DW_OP_LLVM_tag_offset
Only used in LLVM metadata.
@ DW_OP_LLVM_fragment
Only used in LLVM metadata.
@ DW_OP_LLVM_arg
Only used in LLVM metadata.
@ DW_OP_LLVM_convert
Only used in LLVM metadata.
@ DW_OP_LLVM_extract_bits_sext
Only used in LLVM metadata.
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
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...
std::optional< uint8_t > getFixedFormByteSize(dwarf::Form Form, FormParams Params)
Get the fixed byte size for a given form.
StringRef AttributeValueString(uint16_t Attr, unsigned Val)
Returns the symbolic string representing Val when used as a value for attribute Attr.
std::optional< unsigned > OperationOperands(LocationAtom O)
The number of operands for the given LocationAtom.
@ DW_DS_trailing_separate
@ DW_DS_trailing_overpunch
@ DW_DS_leading_overpunch
llvm::StringRef LanguageDescription(SourceLanguageName name)
@ DW_ATOM_die_offset
Marker as the end of a list of atoms.
@ DW_ATOM_type_type_flags
@ DW_TAG_invalid
LLVM mock tags (see also llvm/BinaryFormat/Dwarf.def).
@ DW_MACINFO_invalid
Macinfo type for invalid results.
@ DW_VIRTUALITY_invalid
Virtuality for invalid results.
@ DWARF_VENDOR_DWARF
Identifiers we use to distinguish vendor extensions.
This is an optimization pass for GlobalISel generic memory operations.
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
uint8_t getDwarfOffsetByteSize() const
The size of a reference is determined by the DWARF 32/64-bit format.
uint8_t getRefAddrByteSize() const
The definition of the size of form DW_FORM_ref_addr depends on the version.