Index: include/llvm/BinaryFormat/Dwarf.h =================================================================== --- include/llvm/BinaryFormat/Dwarf.h +++ include/llvm/BinaryFormat/Dwarf.h @@ -325,6 +325,13 @@ DW_UT_hi_user = 0xff }; +enum Index { +#define HANDLE_DW_IDX(ID, NAME) DW_IDX_##NAME = ID, +#include "llvm/BinaryFormat/Dwarf.def" + DW_IDX_lo_user = 0x2000, + DW_IDX_hi_user = 0x3fff +}; + inline bool isUnitType(uint8_t UnitType) { switch (UnitType) { case DW_UT_compile: @@ -420,6 +427,7 @@ StringRef AtomTypeString(unsigned Atom); StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind); StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage); +StringRef IndexString(unsigned Idx); /// @} /// \defgroup DwarfConstantsParsing Dwarf constants parsing functions Index: include/llvm/BinaryFormat/Dwarf.def =================================================================== --- include/llvm/BinaryFormat/Dwarf.def +++ include/llvm/BinaryFormat/Dwarf.def @@ -12,15 +12,15 @@ //===----------------------------------------------------------------------===// // TODO: Add other DW-based macros. -#if !(defined HANDLE_DW_TAG || defined HANDLE_DW_AT || \ - defined HANDLE_DW_FORM || defined HANDLE_DW_OP || \ - defined HANDLE_DW_LANG || defined HANDLE_DW_ATE || \ - defined HANDLE_DW_VIRTUALITY || defined HANDLE_DW_DEFAULTED || \ - defined HANDLE_DW_CC || defined HANDLE_DW_LNS || \ - defined HANDLE_DW_LNE || defined HANDLE_DW_LNCT || \ - defined HANDLE_DW_MACRO || defined HANDLE_DW_RLE || \ - defined HANDLE_DW_CFA || defined HANDLE_DW_APPLE_PROPERTY || \ - defined HANDLE_DW_UT || defined HANDLE_DWARF_SECTION) +#if !( \ + defined HANDLE_DW_TAG || defined HANDLE_DW_AT || defined HANDLE_DW_FORM || \ + defined HANDLE_DW_OP || defined HANDLE_DW_LANG || defined HANDLE_DW_ATE || \ + defined HANDLE_DW_VIRTUALITY || defined HANDLE_DW_DEFAULTED || \ + defined HANDLE_DW_CC || defined HANDLE_DW_LNS || defined HANDLE_DW_LNE || \ + defined HANDLE_DW_LNCT || defined HANDLE_DW_MACRO || \ + defined HANDLE_DW_RLE || defined HANDLE_DW_CFA || \ + defined HANDLE_DW_APPLE_PROPERTY || defined HANDLE_DW_UT || \ + defined HANDLE_DWARF_SECTION || defined HANDLE_DW_IDX) #error "Missing macro definition of HANDLE_DW*" #endif @@ -96,6 +96,10 @@ #define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME) #endif +#ifndef HANDLE_DW_IDX +#define HANDLE_DW_IDX(ID, NAME) +#endif + HANDLE_DW_TAG(0x0000, null, 2, DWARF) HANDLE_DW_TAG(0x0001, array_type, 2, DWARF) HANDLE_DW_TAG(0x0002, class_type, 2, DWARF) @@ -839,6 +843,7 @@ HANDLE_DWARF_SECTION(DebugLoc, ".debug_loc", "debug-loc") HANDLE_DWARF_SECTION(DebugFrame, ".debug_frame", "debug-frame") HANDLE_DWARF_SECTION(DebugMacro, ".debug_macro", "debug-macro") +HANDLE_DWARF_SECTION(DebugNames, ".debug_names", "debug-names") HANDLE_DWARF_SECTION(DebugRanges, ".debug_ranges", "debug-ranges") HANDLE_DWARF_SECTION(DebugPubnames, ".debug_pubnames", "debug-pubnames") HANDLE_DWARF_SECTION(DebugPubtypes, ".debug_pubtypes", "debug-pubtypes") @@ -855,6 +860,12 @@ HANDLE_DWARF_SECTION(AppleObjC, ".apple_objc", "apple-objc") HANDLE_DWARF_SECTION(GdbIndex, ".gdb_index", "gdb-index") +HANDLE_DW_IDX(0x01, compile_unit) +HANDLE_DW_IDX(0x02, type_unit) +HANDLE_DW_IDX(0x03, die_offset) +HANDLE_DW_IDX(0x04, parent) +HANDLE_DW_IDX(0x05, type_hash) + #undef HANDLE_DW_TAG #undef HANDLE_DW_AT @@ -874,3 +885,4 @@ #undef HANDLE_DW_APPLE_PROPERTY #undef HANDLE_DW_UT #undef HANDLE_DWARF_SECTION +#undef HANDLE_DW_IDX Index: lib/BinaryFormat/Dwarf.cpp =================================================================== --- lib/BinaryFormat/Dwarf.cpp +++ lib/BinaryFormat/Dwarf.cpp @@ -567,6 +567,17 @@ 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" + } +} + bool llvm::dwarf::isValidFormForVersion(Form F, unsigned Version, bool ExtensionsOk) { if (FormVendor(F) == DWARF_VENDOR_DWARF) {