diff options
Diffstat (limited to 'lib/BinaryFormat/Dwarf.cpp')
-rw-r--r-- | lib/BinaryFormat/Dwarf.cpp | 147 |
1 files changed, 129 insertions, 18 deletions
diff --git a/lib/BinaryFormat/Dwarf.cpp b/lib/BinaryFormat/Dwarf.cpp index 86e3b02577fd..5984de73ae63 100644 --- a/lib/BinaryFormat/Dwarf.cpp +++ b/lib/BinaryFormat/Dwarf.cpp @@ -393,16 +393,6 @@ StringRef llvm::dwarf::ArrayOrderString(unsigned Order) { return StringRef(); } -StringRef llvm::dwarf::DiscriminantString(unsigned Discriminant) { - switch (Discriminant) { - case DW_DSC_label: - return "DW_DSC_label"; - case DW_DSC_range: - return "DW_DSC_range"; - } - return StringRef(); -} - StringRef llvm::dwarf::LNStandardString(unsigned Standard) { switch (Standard) { default: @@ -454,6 +444,17 @@ unsigned llvm::dwarf::getMacinfo(StringRef MacinfoString) { .Default(DW_MACINFO_invalid); } +StringRef llvm::dwarf::RangeListEncodingString(unsigned Encoding) { + switch (Encoding) { + default: + return StringRef(); +#define HANDLE_DW_RLE(ID, NAME) \ + case DW_RLE_##NAME: \ + return "DW_RLE_" #NAME; +#include "llvm/BinaryFormat/Dwarf.def" + } +} + StringRef llvm::dwarf::CallFrameString(unsigned Encoding) { switch (Encoding) { default: @@ -498,7 +499,10 @@ StringRef llvm::dwarf::AtomTypeString(unsigned AT) { case DW_ATOM_die_tag: return "DW_ATOM_die_tag"; case DW_ATOM_type_flags: + case DW_ATOM_type_type_flags: return "DW_ATOM_type_flags"; + case DW_ATOM_qual_name_hash: + return "DW_ATOM_qual_name_hash"; } return StringRef(); } @@ -560,13 +564,122 @@ StringRef llvm::dwarf::AttributeValueString(uint16_t Attr, unsigned Val) { return InlineCodeString(Val); case DW_AT_ordering: return ArrayOrderString(Val); - case DW_AT_discr_value: - return DiscriminantString(Val); + case DW_AT_APPLE_runtime_class: + return LanguageString(Val); + } + + return StringRef(); +} + +StringRef llvm::dwarf::AtomValueString(uint16_t Atom, unsigned Val) { + switch (Atom) { + case DW_ATOM_null: + return "NULL"; + case DW_ATOM_die_tag: + return TagString(Val); } return StringRef(); } +StringRef llvm::dwarf::IndexString(unsigned Idx) { + switch (Idx) { + default: + return StringRef(); +#define HANDLE_DW_IDX(ID, NAME) \ + case DW_IDX_##NAME: \ + return "DW_IDX_" #NAME; +#include "llvm/BinaryFormat/Dwarf.def" + } +} + +Optional<uint8_t> llvm::dwarf::getFixedFormByteSize(dwarf::Form Form, + FormParams Params) { + switch (Form) { + case DW_FORM_addr: + if (Params) + return Params.AddrSize; + return None; + + case DW_FORM_block: // ULEB128 length L followed by L bytes. + case DW_FORM_block1: // 1 byte length L followed by L bytes. + case DW_FORM_block2: // 2 byte length L followed by L bytes. + case DW_FORM_block4: // 4 byte length L followed by L bytes. + case DW_FORM_string: // C-string with null terminator. + case DW_FORM_sdata: // SLEB128. + case DW_FORM_udata: // ULEB128. + case DW_FORM_ref_udata: // ULEB128. + case DW_FORM_indirect: // ULEB128. + case DW_FORM_exprloc: // ULEB128 length L followed by L bytes. + case DW_FORM_strx: // ULEB128. + case DW_FORM_addrx: // ULEB128. + case DW_FORM_loclistx: // ULEB128. + case DW_FORM_rnglistx: // ULEB128. + case DW_FORM_GNU_addr_index: // ULEB128. + case DW_FORM_GNU_str_index: // ULEB128. + return None; + + case DW_FORM_ref_addr: + if (Params) + return Params.getRefAddrByteSize(); + return None; + + case DW_FORM_flag: + case DW_FORM_data1: + case DW_FORM_ref1: + case DW_FORM_strx1: + case DW_FORM_addrx1: + return 1; + + case DW_FORM_data2: + case DW_FORM_ref2: + case DW_FORM_strx2: + case DW_FORM_addrx2: + return 2; + + case DW_FORM_strx3: + return 3; + + case DW_FORM_data4: + case DW_FORM_ref4: + case DW_FORM_ref_sup4: + case DW_FORM_strx4: + case DW_FORM_addrx4: + return 4; + + case DW_FORM_strp: + case DW_FORM_GNU_ref_alt: + case DW_FORM_GNU_strp_alt: + case DW_FORM_line_strp: + case DW_FORM_sec_offset: + case DW_FORM_strp_sup: + if (Params) + return Params.getDwarfOffsetByteSize(); + return None; + + case DW_FORM_data8: + case DW_FORM_ref8: + case DW_FORM_ref_sig8: + case DW_FORM_ref_sup8: + return 8; + + case DW_FORM_flag_present: + return 0; + + case DW_FORM_data16: + return 16; + + case DW_FORM_implicit_const: + // The implicit value is stored in the abbreviation as a SLEB128, and + // there no data in debug info. + return 0; + + default: + break; + } + return None; +} + bool llvm::dwarf::isValidFormForVersion(Form F, unsigned Version, bool ExtensionsOk) { if (FormVendor(F) == DWARF_VENDOR_DWARF) { @@ -576,9 +689,7 @@ bool llvm::dwarf::isValidFormForVersion(Form F, unsigned Version, return ExtensionsOk; } -uint32_t llvm::dwarf::djbHash(StringRef Buffer) { - uint32_t H = 5381; - for (char C : Buffer.bytes()) - H = ((H << 5) + H) + C; - return H; -} +constexpr char llvm::dwarf::EnumTraits<Attribute>::Type[]; +constexpr char llvm::dwarf::EnumTraits<Form>::Type[]; +constexpr char llvm::dwarf::EnumTraits<Index>::Type[]; +constexpr char llvm::dwarf::EnumTraits<Tag>::Type[]; |