Home | History | Annotate | Download | only in Support
      1 //===-- llvm/Support/Dwarf.h ---Dwarf Constants------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // \file
     11 // \brief This file contains constants used for implementing Dwarf
     12 // debug support.
     13 //
     14 // For details on the Dwarf specfication see the latest DWARF Debugging
     15 // Information Format standard document on http://www.dwarfstd.org. This
     16 // file often includes support for non-released standard features.
     17 //
     18 //===----------------------------------------------------------------------===//
     19 
     20 #ifndef LLVM_SUPPORT_DWARF_H
     21 #define LLVM_SUPPORT_DWARF_H
     22 
     23 #include "llvm/ADT/StringRef.h"
     24 #include "llvm/Support/Compiler.h"
     25 #include "llvm/Support/DataTypes.h"
     26 
     27 namespace llvm {
     28 
     29 namespace dwarf {
     30 
     31 //===----------------------------------------------------------------------===//
     32 // Dwarf constants as gleaned from the DWARF Debugging Information Format V.4
     33 // reference manual http://www.dwarfstd.org/.
     34 //
     35 
     36 // Do not mix the following two enumerations sets.  DW_TAG_invalid changes the
     37 // enumeration base type.
     38 
     39 enum LLVMConstants : uint32_t {
     40   // LLVM mock tags (see also llvm/Support/Dwarf.def).
     41   DW_TAG_invalid = ~0U,        // Tag for invalid results.
     42   DW_VIRTUALITY_invalid = ~0U, // Virtuality for invalid results.
     43   DW_MACINFO_invalid = ~0U,    // Macinfo type for invalid results.
     44 
     45   // Other constants.
     46   DWARF_VERSION = 4,       // Default dwarf version we output.
     47   DW_PUBTYPES_VERSION = 2, // Section version number for .debug_pubtypes.
     48   DW_PUBNAMES_VERSION = 2, // Section version number for .debug_pubnames.
     49   DW_ARANGES_VERSION = 2   // Section version number for .debug_aranges.
     50 };
     51 
     52 // Special ID values that distinguish a CIE from a FDE in DWARF CFI.
     53 // Not inside an enum because a 64-bit value is needed.
     54 const uint32_t DW_CIE_ID = UINT32_MAX;
     55 const uint64_t DW64_CIE_ID = UINT64_MAX;
     56 
     57 enum Tag : uint16_t {
     58 #define HANDLE_DW_TAG(ID, NAME) DW_TAG_##NAME = ID,
     59 #include "llvm/Support/Dwarf.def"
     60   DW_TAG_lo_user = 0x4080,
     61   DW_TAG_hi_user = 0xffff,
     62   DW_TAG_user_base = 0x1000 // Recommended base for user tags.
     63 };
     64 
     65 inline bool isType(Tag T) {
     66   switch (T) {
     67   case DW_TAG_array_type:
     68   case DW_TAG_class_type:
     69   case DW_TAG_interface_type:
     70   case DW_TAG_enumeration_type:
     71   case DW_TAG_pointer_type:
     72   case DW_TAG_reference_type:
     73   case DW_TAG_rvalue_reference_type:
     74   case DW_TAG_string_type:
     75   case DW_TAG_structure_type:
     76   case DW_TAG_subroutine_type:
     77   case DW_TAG_union_type:
     78   case DW_TAG_ptr_to_member_type:
     79   case DW_TAG_set_type:
     80   case DW_TAG_subrange_type:
     81   case DW_TAG_base_type:
     82   case DW_TAG_const_type:
     83   case DW_TAG_file_type:
     84   case DW_TAG_packed_type:
     85   case DW_TAG_volatile_type:
     86   case DW_TAG_typedef:
     87     return true;
     88   default:
     89     return false;
     90   }
     91 }
     92 
     93 enum Attribute : uint16_t {
     94   // Attributes
     95   DW_AT_sibling = 0x01,
     96   DW_AT_location = 0x02,
     97   DW_AT_name = 0x03,
     98   DW_AT_ordering = 0x09,
     99   DW_AT_byte_size = 0x0b,
    100   DW_AT_bit_offset = 0x0c,
    101   DW_AT_bit_size = 0x0d,
    102   DW_AT_stmt_list = 0x10,
    103   DW_AT_low_pc = 0x11,
    104   DW_AT_high_pc = 0x12,
    105   DW_AT_language = 0x13,
    106   DW_AT_discr = 0x15,
    107   DW_AT_discr_value = 0x16,
    108   DW_AT_visibility = 0x17,
    109   DW_AT_import = 0x18,
    110   DW_AT_string_length = 0x19,
    111   DW_AT_common_reference = 0x1a,
    112   DW_AT_comp_dir = 0x1b,
    113   DW_AT_const_value = 0x1c,
    114   DW_AT_containing_type = 0x1d,
    115   DW_AT_default_value = 0x1e,
    116   DW_AT_inline = 0x20,
    117   DW_AT_is_optional = 0x21,
    118   DW_AT_lower_bound = 0x22,
    119   DW_AT_producer = 0x25,
    120   DW_AT_prototyped = 0x27,
    121   DW_AT_return_addr = 0x2a,
    122   DW_AT_start_scope = 0x2c,
    123   DW_AT_bit_stride = 0x2e,
    124   DW_AT_upper_bound = 0x2f,
    125   DW_AT_abstract_origin = 0x31,
    126   DW_AT_accessibility = 0x32,
    127   DW_AT_address_class = 0x33,
    128   DW_AT_artificial = 0x34,
    129   DW_AT_base_types = 0x35,
    130   DW_AT_calling_convention = 0x36,
    131   DW_AT_count = 0x37,
    132   DW_AT_data_member_location = 0x38,
    133   DW_AT_decl_column = 0x39,
    134   DW_AT_decl_file = 0x3a,
    135   DW_AT_decl_line = 0x3b,
    136   DW_AT_declaration = 0x3c,
    137   DW_AT_discr_list = 0x3d,
    138   DW_AT_encoding = 0x3e,
    139   DW_AT_external = 0x3f,
    140   DW_AT_frame_base = 0x40,
    141   DW_AT_friend = 0x41,
    142   DW_AT_identifier_case = 0x42,
    143   DW_AT_macro_info = 0x43,
    144   DW_AT_namelist_item = 0x44,
    145   DW_AT_priority = 0x45,
    146   DW_AT_segment = 0x46,
    147   DW_AT_specification = 0x47,
    148   DW_AT_static_link = 0x48,
    149   DW_AT_type = 0x49,
    150   DW_AT_use_location = 0x4a,
    151   DW_AT_variable_parameter = 0x4b,
    152   DW_AT_virtuality = 0x4c,
    153   DW_AT_vtable_elem_location = 0x4d,
    154   DW_AT_allocated = 0x4e,
    155   DW_AT_associated = 0x4f,
    156   DW_AT_data_location = 0x50,
    157   DW_AT_byte_stride = 0x51,
    158   DW_AT_entry_pc = 0x52,
    159   DW_AT_use_UTF8 = 0x53,
    160   DW_AT_extension = 0x54,
    161   DW_AT_ranges = 0x55,
    162   DW_AT_trampoline = 0x56,
    163   DW_AT_call_column = 0x57,
    164   DW_AT_call_file = 0x58,
    165   DW_AT_call_line = 0x59,
    166   DW_AT_description = 0x5a,
    167   DW_AT_binary_scale = 0x5b,
    168   DW_AT_decimal_scale = 0x5c,
    169   DW_AT_small = 0x5d,
    170   DW_AT_decimal_sign = 0x5e,
    171   DW_AT_digit_count = 0x5f,
    172   DW_AT_picture_string = 0x60,
    173   DW_AT_mutable = 0x61,
    174   DW_AT_threads_scaled = 0x62,
    175   DW_AT_explicit = 0x63,
    176   DW_AT_object_pointer = 0x64,
    177   DW_AT_endianity = 0x65,
    178   DW_AT_elemental = 0x66,
    179   DW_AT_pure = 0x67,
    180   DW_AT_recursive = 0x68,
    181   DW_AT_signature = 0x69,
    182   DW_AT_main_subprogram = 0x6a,
    183   DW_AT_data_bit_offset = 0x6b,
    184   DW_AT_const_expr = 0x6c,
    185   DW_AT_enum_class = 0x6d,
    186   DW_AT_linkage_name = 0x6e,
    187 
    188   // New in DWARF 5:
    189   DW_AT_string_length_bit_size = 0x6f,
    190   DW_AT_string_length_byte_size = 0x70,
    191   DW_AT_rank = 0x71,
    192   DW_AT_str_offsets_base = 0x72,
    193   DW_AT_addr_base = 0x73,
    194   DW_AT_ranges_base = 0x74,
    195   DW_AT_dwo_id = 0x75,
    196   DW_AT_dwo_name = 0x76,
    197   DW_AT_reference = 0x77,
    198   DW_AT_rvalue_reference = 0x78,
    199   DW_AT_macros = 0x79,
    200 
    201   DW_AT_lo_user = 0x2000,
    202   DW_AT_hi_user = 0x3fff,
    203 
    204   DW_AT_MIPS_loop_begin = 0x2002,
    205   DW_AT_MIPS_tail_loop_begin = 0x2003,
    206   DW_AT_MIPS_epilog_begin = 0x2004,
    207   DW_AT_MIPS_loop_unroll_factor = 0x2005,
    208   DW_AT_MIPS_software_pipeline_depth = 0x2006,
    209   DW_AT_MIPS_linkage_name = 0x2007,
    210   DW_AT_MIPS_stride = 0x2008,
    211   DW_AT_MIPS_abstract_name = 0x2009,
    212   DW_AT_MIPS_clone_origin = 0x200a,
    213   DW_AT_MIPS_has_inlines = 0x200b,
    214   DW_AT_MIPS_stride_byte = 0x200c,
    215   DW_AT_MIPS_stride_elem = 0x200d,
    216   DW_AT_MIPS_ptr_dopetype = 0x200e,
    217   DW_AT_MIPS_allocatable_dopetype = 0x200f,
    218   DW_AT_MIPS_assumed_shape_dopetype = 0x2010,
    219 
    220   // This one appears to have only been implemented by Open64 for
    221   // fortran and may conflict with other extensions.
    222   DW_AT_MIPS_assumed_size = 0x2011,
    223 
    224   // GNU extensions
    225   DW_AT_sf_names = 0x2101,
    226   DW_AT_src_info = 0x2102,
    227   DW_AT_mac_info = 0x2103,
    228   DW_AT_src_coords = 0x2104,
    229   DW_AT_body_begin = 0x2105,
    230   DW_AT_body_end = 0x2106,
    231   DW_AT_GNU_vector = 0x2107,
    232   DW_AT_GNU_template_name = 0x2110,
    233 
    234   DW_AT_GNU_odr_signature = 0x210f,
    235   DW_AT_GNU_macros = 0x2119,
    236 
    237   // Extensions for Fission proposal.
    238   DW_AT_GNU_dwo_name = 0x2130,
    239   DW_AT_GNU_dwo_id = 0x2131,
    240   DW_AT_GNU_ranges_base = 0x2132,
    241   DW_AT_GNU_addr_base = 0x2133,
    242   DW_AT_GNU_pubnames = 0x2134,
    243   DW_AT_GNU_pubtypes = 0x2135,
    244   DW_AT_GNU_discriminator = 0x2136,
    245 
    246   // Borland extensions.
    247   DW_AT_BORLAND_property_read = 0x3b11,
    248   DW_AT_BORLAND_property_write = 0x3b12,
    249   DW_AT_BORLAND_property_implements = 0x3b13,
    250   DW_AT_BORLAND_property_index = 0x3b14,
    251   DW_AT_BORLAND_property_default = 0x3b15,
    252   DW_AT_BORLAND_Delphi_unit = 0x3b20,
    253   DW_AT_BORLAND_Delphi_class = 0x3b21,
    254   DW_AT_BORLAND_Delphi_record = 0x3b22,
    255   DW_AT_BORLAND_Delphi_metaclass = 0x3b23,
    256   DW_AT_BORLAND_Delphi_constructor = 0x3b24,
    257   DW_AT_BORLAND_Delphi_destructor = 0x3b25,
    258   DW_AT_BORLAND_Delphi_anonymous_method = 0x3b26,
    259   DW_AT_BORLAND_Delphi_interface = 0x3b27,
    260   DW_AT_BORLAND_Delphi_ABI = 0x3b28,
    261   DW_AT_BORLAND_Delphi_return = 0x3b29,
    262   DW_AT_BORLAND_Delphi_frameptr = 0x3b30,
    263   DW_AT_BORLAND_closure = 0x3b31,
    264 
    265   // LLVM project extensions.
    266   DW_AT_LLVM_include_path = 0x3e00,
    267   DW_AT_LLVM_config_macros = 0x3e01,
    268   DW_AT_LLVM_isysroot = 0x3e02,
    269 
    270   // Apple extensions.
    271   DW_AT_APPLE_optimized = 0x3fe1,
    272   DW_AT_APPLE_flags = 0x3fe2,
    273   DW_AT_APPLE_isa = 0x3fe3,
    274   DW_AT_APPLE_block = 0x3fe4,
    275   DW_AT_APPLE_major_runtime_vers = 0x3fe5,
    276   DW_AT_APPLE_runtime_class = 0x3fe6,
    277   DW_AT_APPLE_omit_frame_ptr = 0x3fe7,
    278   DW_AT_APPLE_property_name = 0x3fe8,
    279   DW_AT_APPLE_property_getter = 0x3fe9,
    280   DW_AT_APPLE_property_setter = 0x3fea,
    281   DW_AT_APPLE_property_attribute = 0x3feb,
    282   DW_AT_APPLE_objc_complete_type = 0x3fec,
    283   DW_AT_APPLE_property = 0x3fed
    284 };
    285 
    286 enum Form : uint16_t {
    287   // Attribute form encodings
    288   DW_FORM_addr = 0x01,
    289   DW_FORM_block2 = 0x03,
    290   DW_FORM_block4 = 0x04,
    291   DW_FORM_data2 = 0x05,
    292   DW_FORM_data4 = 0x06,
    293   DW_FORM_data8 = 0x07,
    294   DW_FORM_string = 0x08,
    295   DW_FORM_block = 0x09,
    296   DW_FORM_block1 = 0x0a,
    297   DW_FORM_data1 = 0x0b,
    298   DW_FORM_flag = 0x0c,
    299   DW_FORM_sdata = 0x0d,
    300   DW_FORM_strp = 0x0e,
    301   DW_FORM_udata = 0x0f,
    302   DW_FORM_ref_addr = 0x10,
    303   DW_FORM_ref1 = 0x11,
    304   DW_FORM_ref2 = 0x12,
    305   DW_FORM_ref4 = 0x13,
    306   DW_FORM_ref8 = 0x14,
    307   DW_FORM_ref_udata = 0x15,
    308   DW_FORM_indirect = 0x16,
    309   DW_FORM_sec_offset = 0x17,
    310   DW_FORM_exprloc = 0x18,
    311   DW_FORM_flag_present = 0x19,
    312   DW_FORM_ref_sig8 = 0x20,
    313 
    314   // Extensions for Fission proposal
    315   DW_FORM_GNU_addr_index = 0x1f01,
    316   DW_FORM_GNU_str_index = 0x1f02,
    317 
    318   // Alternate debug sections proposal (output of "dwz" tool).
    319   DW_FORM_GNU_ref_alt = 0x1f20,
    320   DW_FORM_GNU_strp_alt = 0x1f21
    321 };
    322 
    323 enum LocationAtom {
    324 #define HANDLE_DW_OP(ID, NAME) DW_OP_##NAME = ID,
    325 #include "llvm/Support/Dwarf.def"
    326   DW_OP_lo_user = 0xe0,
    327   DW_OP_hi_user = 0xff
    328 };
    329 
    330 enum TypeKind {
    331 #define HANDLE_DW_ATE(ID, NAME) DW_ATE_##NAME = ID,
    332 #include "llvm/Support/Dwarf.def"
    333   DW_ATE_lo_user = 0x80,
    334   DW_ATE_hi_user = 0xff
    335 };
    336 
    337 enum DecimalSignEncoding {
    338   // Decimal sign attribute values
    339   DW_DS_unsigned = 0x01,
    340   DW_DS_leading_overpunch = 0x02,
    341   DW_DS_trailing_overpunch = 0x03,
    342   DW_DS_leading_separate = 0x04,
    343   DW_DS_trailing_separate = 0x05
    344 };
    345 
    346 enum EndianityEncoding {
    347   // Endianity attribute values
    348   DW_END_default = 0x00,
    349   DW_END_big = 0x01,
    350   DW_END_little = 0x02,
    351   DW_END_lo_user = 0x40,
    352   DW_END_hi_user = 0xff
    353 };
    354 
    355 enum AccessAttribute {
    356   // Accessibility codes
    357   DW_ACCESS_public = 0x01,
    358   DW_ACCESS_protected = 0x02,
    359   DW_ACCESS_private = 0x03
    360 };
    361 
    362 enum VisibilityAttribute {
    363   // Visibility codes
    364   DW_VIS_local = 0x01,
    365   DW_VIS_exported = 0x02,
    366   DW_VIS_qualified = 0x03
    367 };
    368 
    369 enum VirtualityAttribute {
    370 #define HANDLE_DW_VIRTUALITY(ID, NAME) DW_VIRTUALITY_##NAME = ID,
    371 #include "llvm/Support/Dwarf.def"
    372   DW_VIRTUALITY_max = 0x02
    373 };
    374 
    375 enum SourceLanguage {
    376 #define HANDLE_DW_LANG(ID, NAME) DW_LANG_##NAME = ID,
    377 #include "llvm/Support/Dwarf.def"
    378   DW_LANG_lo_user = 0x8000,
    379   DW_LANG_hi_user = 0xffff
    380 };
    381 
    382 enum CaseSensitivity {
    383   // Identifier case codes
    384   DW_ID_case_sensitive = 0x00,
    385   DW_ID_up_case = 0x01,
    386   DW_ID_down_case = 0x02,
    387   DW_ID_case_insensitive = 0x03
    388 };
    389 
    390 enum CallingConvention {
    391   // Calling convention codes
    392   DW_CC_normal = 0x01,
    393   DW_CC_program = 0x02,
    394   DW_CC_nocall = 0x03,
    395   DW_CC_lo_user = 0x40,
    396   DW_CC_GNU_borland_fastcall_i386 = 0x41,
    397   DW_CC_BORLAND_safecall = 0xb0,
    398   DW_CC_BORLAND_stdcall = 0xb1,
    399   DW_CC_BORLAND_pascal = 0xb2,
    400   DW_CC_BORLAND_msfastcall = 0xb3,
    401   DW_CC_BORLAND_msreturn = 0xb4,
    402   DW_CC_BORLAND_thiscall = 0xb5,
    403   DW_CC_BORLAND_fastcall = 0xb6,
    404   DW_CC_hi_user = 0xff
    405 };
    406 
    407 enum InlineAttribute {
    408   // Inline codes
    409   DW_INL_not_inlined = 0x00,
    410   DW_INL_inlined = 0x01,
    411   DW_INL_declared_not_inlined = 0x02,
    412   DW_INL_declared_inlined = 0x03
    413 };
    414 
    415 enum ArrayDimensionOrdering {
    416   // Array ordering
    417   DW_ORD_row_major = 0x00,
    418   DW_ORD_col_major = 0x01
    419 };
    420 
    421 enum DiscriminantList {
    422   // Discriminant descriptor values
    423   DW_DSC_label = 0x00,
    424   DW_DSC_range = 0x01
    425 };
    426 
    427 enum LineNumberOps {
    428   // Line Number Standard Opcode Encodings
    429   DW_LNS_extended_op = 0x00,
    430   DW_LNS_copy = 0x01,
    431   DW_LNS_advance_pc = 0x02,
    432   DW_LNS_advance_line = 0x03,
    433   DW_LNS_set_file = 0x04,
    434   DW_LNS_set_column = 0x05,
    435   DW_LNS_negate_stmt = 0x06,
    436   DW_LNS_set_basic_block = 0x07,
    437   DW_LNS_const_add_pc = 0x08,
    438   DW_LNS_fixed_advance_pc = 0x09,
    439   DW_LNS_set_prologue_end = 0x0a,
    440   DW_LNS_set_epilogue_begin = 0x0b,
    441   DW_LNS_set_isa = 0x0c
    442 };
    443 
    444 enum LineNumberExtendedOps {
    445   // Line Number Extended Opcode Encodings
    446   DW_LNE_end_sequence = 0x01,
    447   DW_LNE_set_address = 0x02,
    448   DW_LNE_define_file = 0x03,
    449   DW_LNE_set_discriminator = 0x04,
    450   DW_LNE_lo_user = 0x80,
    451   DW_LNE_hi_user = 0xff
    452 };
    453 
    454 enum MacinfoRecordType {
    455   // Macinfo Type Encodings
    456   DW_MACINFO_define = 0x01,
    457   DW_MACINFO_undef = 0x02,
    458   DW_MACINFO_start_file = 0x03,
    459   DW_MACINFO_end_file = 0x04,
    460   DW_MACINFO_vendor_ext = 0xff
    461 };
    462 
    463 enum MacroEntryType {
    464   // Macro Information Entry Type Encodings
    465   DW_MACRO_define = 0x01,
    466   DW_MACRO_undef = 0x02,
    467   DW_MACRO_start_file = 0x03,
    468   DW_MACRO_end_file = 0x04,
    469   DW_MACRO_define_indirect = 0x05,
    470   DW_MACRO_undef_indirect = 0x06,
    471   DW_MACRO_transparent_include = 0x07,
    472   DW_MACRO_define_indirect_sup = 0x08,
    473   DW_MACRO_undef_indirect_sup = 0x09,
    474   DW_MACRO_transparent_include_sup = 0x0a,
    475   DW_MACRO_define_indirectx = 0x0b,
    476   DW_MACRO_undef_indirectx = 0x0c,
    477   DW_MACRO_lo_user = 0xe0,
    478   DW_MACRO_hi_user = 0xff
    479 };
    480 
    481 enum CallFrameInfo {
    482   // Call frame instruction encodings
    483   DW_CFA_extended = 0x00,
    484   DW_CFA_nop = 0x00,
    485   DW_CFA_advance_loc = 0x40,
    486   DW_CFA_offset = 0x80,
    487   DW_CFA_restore = 0xc0,
    488   DW_CFA_set_loc = 0x01,
    489   DW_CFA_advance_loc1 = 0x02,
    490   DW_CFA_advance_loc2 = 0x03,
    491   DW_CFA_advance_loc4 = 0x04,
    492   DW_CFA_offset_extended = 0x05,
    493   DW_CFA_restore_extended = 0x06,
    494   DW_CFA_undefined = 0x07,
    495   DW_CFA_same_value = 0x08,
    496   DW_CFA_register = 0x09,
    497   DW_CFA_remember_state = 0x0a,
    498   DW_CFA_restore_state = 0x0b,
    499   DW_CFA_def_cfa = 0x0c,
    500   DW_CFA_def_cfa_register = 0x0d,
    501   DW_CFA_def_cfa_offset = 0x0e,
    502   DW_CFA_def_cfa_expression = 0x0f,
    503   DW_CFA_expression = 0x10,
    504   DW_CFA_offset_extended_sf = 0x11,
    505   DW_CFA_def_cfa_sf = 0x12,
    506   DW_CFA_def_cfa_offset_sf = 0x13,
    507   DW_CFA_val_offset = 0x14,
    508   DW_CFA_val_offset_sf = 0x15,
    509   DW_CFA_val_expression = 0x16,
    510   DW_CFA_MIPS_advance_loc8 = 0x1d,
    511   DW_CFA_GNU_window_save = 0x2d,
    512   DW_CFA_GNU_args_size = 0x2e,
    513   DW_CFA_lo_user = 0x1c,
    514   DW_CFA_hi_user = 0x3f
    515 };
    516 
    517 enum Constants {
    518   // Children flag
    519   DW_CHILDREN_no = 0x00,
    520   DW_CHILDREN_yes = 0x01,
    521 
    522   DW_EH_PE_absptr = 0x00,
    523   DW_EH_PE_omit = 0xff,
    524   DW_EH_PE_uleb128 = 0x01,
    525   DW_EH_PE_udata2 = 0x02,
    526   DW_EH_PE_udata4 = 0x03,
    527   DW_EH_PE_udata8 = 0x04,
    528   DW_EH_PE_sleb128 = 0x09,
    529   DW_EH_PE_sdata2 = 0x0A,
    530   DW_EH_PE_sdata4 = 0x0B,
    531   DW_EH_PE_sdata8 = 0x0C,
    532   DW_EH_PE_signed = 0x08,
    533   DW_EH_PE_pcrel = 0x10,
    534   DW_EH_PE_textrel = 0x20,
    535   DW_EH_PE_datarel = 0x30,
    536   DW_EH_PE_funcrel = 0x40,
    537   DW_EH_PE_aligned = 0x50,
    538   DW_EH_PE_indirect = 0x80
    539 };
    540 
    541 // Constants for debug_loc.dwo in the DWARF5 Split Debug Info Proposal
    542 enum LocationListEntry : unsigned char {
    543   DW_LLE_end_of_list_entry,
    544   DW_LLE_base_address_selection_entry,
    545   DW_LLE_start_end_entry,
    546   DW_LLE_start_length_entry,
    547   DW_LLE_offset_pair_entry
    548 };
    549 
    550 /// Contstants for the DW_APPLE_PROPERTY_attributes attribute.
    551 /// Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind.
    552 enum ApplePropertyAttributes {
    553   // Apple Objective-C Property Attributes
    554   DW_APPLE_PROPERTY_readonly = 0x01,
    555   DW_APPLE_PROPERTY_getter = 0x02,
    556   DW_APPLE_PROPERTY_assign = 0x04,
    557   DW_APPLE_PROPERTY_readwrite = 0x08,
    558   DW_APPLE_PROPERTY_retain = 0x10,
    559   DW_APPLE_PROPERTY_copy = 0x20,
    560   DW_APPLE_PROPERTY_nonatomic = 0x40,
    561   DW_APPLE_PROPERTY_setter = 0x80,
    562   DW_APPLE_PROPERTY_atomic = 0x100,
    563   DW_APPLE_PROPERTY_weak =   0x200,
    564   DW_APPLE_PROPERTY_strong = 0x400,
    565   DW_APPLE_PROPERTY_unsafe_unretained = 0x800
    566 };
    567 
    568 // Constants for the DWARF5 Accelerator Table Proposal
    569 enum AcceleratorTable {
    570   // Data layout descriptors.
    571   DW_ATOM_null = 0u,       // Marker as the end of a list of atoms.
    572   DW_ATOM_die_offset = 1u, // DIE offset in the debug_info section.
    573   DW_ATOM_cu_offset = 2u, // Offset of the compile unit header that contains the
    574                           // item in question.
    575   DW_ATOM_die_tag = 3u,   // A tag entry.
    576   DW_ATOM_type_flags = 4u, // Set of flags for a type.
    577 
    578   // DW_ATOM_type_flags values.
    579 
    580   // Always set for C++, only set for ObjC if this is the @implementation for a
    581   // class.
    582   DW_FLAG_type_implementation = 2u,
    583 
    584   // Hash functions.
    585 
    586   // Daniel J. Bernstein hash.
    587   DW_hash_function_djb = 0u
    588 };
    589 
    590 // Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
    591 enum GDBIndexEntryKind {
    592   GIEK_NONE,
    593   GIEK_TYPE,
    594   GIEK_VARIABLE,
    595   GIEK_FUNCTION,
    596   GIEK_OTHER,
    597   GIEK_UNUSED5,
    598   GIEK_UNUSED6,
    599   GIEK_UNUSED7
    600 };
    601 
    602 enum GDBIndexEntryLinkage {
    603   GIEL_EXTERNAL,
    604   GIEL_STATIC
    605 };
    606 
    607 /// \defgroup DwarfConstantsDumping Dwarf constants dumping functions
    608 ///
    609 /// All these functions map their argument's value back to the
    610 /// corresponding enumerator name or return nullptr if the value isn't
    611 /// known.
    612 ///
    613 /// @{
    614 const char *TagString(unsigned Tag);
    615 const char *ChildrenString(unsigned Children);
    616 const char *AttributeString(unsigned Attribute);
    617 const char *FormEncodingString(unsigned Encoding);
    618 const char *OperationEncodingString(unsigned Encoding);
    619 const char *AttributeEncodingString(unsigned Encoding);
    620 const char *DecimalSignString(unsigned Sign);
    621 const char *EndianityString(unsigned Endian);
    622 const char *AccessibilityString(unsigned Access);
    623 const char *VisibilityString(unsigned Visibility);
    624 const char *VirtualityString(unsigned Virtuality);
    625 const char *LanguageString(unsigned Language);
    626 const char *CaseString(unsigned Case);
    627 const char *ConventionString(unsigned Convention);
    628 const char *InlineCodeString(unsigned Code);
    629 const char *ArrayOrderString(unsigned Order);
    630 const char *DiscriminantString(unsigned Discriminant);
    631 const char *LNStandardString(unsigned Standard);
    632 const char *LNExtendedString(unsigned Encoding);
    633 const char *MacinfoString(unsigned Encoding);
    634 const char *CallFrameString(unsigned Encoding);
    635 const char *ApplePropertyString(unsigned);
    636 const char *AtomTypeString(unsigned Atom);
    637 const char *GDBIndexEntryKindString(GDBIndexEntryKind Kind);
    638 const char *GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage);
    639 /// @}
    640 
    641 /// \defgroup DwarfConstantsParsing Dwarf constants parsing functions
    642 ///
    643 /// These functions map their strings back to the corresponding enumeration
    644 /// value or return 0 if there is none, except for these exceptions:
    645 ///
    646 /// \li \a getTag() returns \a DW_TAG_invalid on invalid input.
    647 /// \li \a getVirtuality() returns \a DW_VIRTUALITY_invalid on invalid input.
    648 /// \li \a getMacinfo() returns \a DW_MACINFO_invalid on invalid input.
    649 ///
    650 /// @{
    651 unsigned getTag(StringRef TagString);
    652 unsigned getOperationEncoding(StringRef OperationEncodingString);
    653 unsigned getVirtuality(StringRef VirtualityString);
    654 unsigned getLanguage(StringRef LanguageString);
    655 unsigned getAttributeEncoding(StringRef EncodingString);
    656 unsigned getMacinfo(StringRef MacinfoString);
    657 /// @}
    658 
    659 /// \brief Returns the symbolic string representing Val when used as a value
    660 /// for attribute Attr.
    661 const char *AttributeValueString(uint16_t Attr, unsigned Val);
    662 
    663 /// \brief Decsribes an entry of the various gnu_pub* debug sections.
    664 ///
    665 /// The gnu_pub* kind looks like:
    666 ///
    667 /// 0-3  reserved
    668 /// 4-6  symbol kind
    669 /// 7    0 == global, 1 == static
    670 ///
    671 /// A gdb_index descriptor includes the above kind, shifted 24 bits up with the
    672 /// offset of the cu within the debug_info section stored in those 24 bits.
    673 struct PubIndexEntryDescriptor {
    674   GDBIndexEntryKind Kind;
    675   GDBIndexEntryLinkage Linkage;
    676   PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Linkage)
    677       : Kind(Kind), Linkage(Linkage) {}
    678   /* implicit */ PubIndexEntryDescriptor(GDBIndexEntryKind Kind)
    679       : Kind(Kind), Linkage(GIEL_EXTERNAL) {}
    680   explicit PubIndexEntryDescriptor(uint8_t Value)
    681       : Kind(static_cast<GDBIndexEntryKind>((Value & KIND_MASK) >>
    682                                             KIND_OFFSET)),
    683         Linkage(static_cast<GDBIndexEntryLinkage>((Value & LINKAGE_MASK) >>
    684                                                   LINKAGE_OFFSET)) {}
    685   uint8_t toBits() { return Kind << KIND_OFFSET | Linkage << LINKAGE_OFFSET; }
    686 
    687 private:
    688   enum {
    689     KIND_OFFSET = 4,
    690     KIND_MASK = 7 << KIND_OFFSET,
    691     LINKAGE_OFFSET = 7,
    692     LINKAGE_MASK = 1 << LINKAGE_OFFSET
    693   };
    694 };
    695 
    696 } // End of namespace dwarf
    697 
    698 } // End of namespace llvm
    699 
    700 #endif
    701