summaryrefslogtreecommitdiff
path: root/include/llvm/Support
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-09-19 20:40:26 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-09-19 20:40:26 +0000
commit9599f51559c692bb20092da23e3a34b2cc841e03 (patch)
tree914e0f1830ead47b57983b1fb6c961032f374539 /include/llvm/Support
parentf2144ed4399c6414a4f35b10c2fcc9782f32fbf3 (diff)
downloadllvm-9599f51559c692bb20092da23e3a34b2cc841e03.tar.gz
llvm-9599f51559c692bb20092da23e3a34b2cc841e03.tar.bz2
llvm-9599f51559c692bb20092da23e3a34b2cc841e03.tar.xz
Unshift the GDB index/GNU pubnames constants modified in r191025
Based on code review feedback from Eric Christopher, unshifting these constants as they can appear in the gdb_index itself, shifted a further 24 bits. This means that keeping them preshifted is a bit inflexible, so let's not do that. Given the motivation, wrap up some nicer enums, more type safety, and some utility functions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191035 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support')
-rw-r--r--include/llvm/Support/Dwarf.h73
1 files changed, 42 insertions, 31 deletions
diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h
index f06c4801fd..9f969728cf 100644
--- a/include/llvm/Support/Dwarf.h
+++ b/include/llvm/Support/Dwarf.h
@@ -790,39 +790,50 @@ enum AcceleratorTable {
const char *AtomTypeString(unsigned Atom);
// Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
-enum GDBIndex {
- // The gnu_pub* index value looks like:
- //
- // 0-3 reserved
- // 4-6 symbol kind
- // 7 0 == global, 1 == static
-
- // Attributes kinds for the index.
- GDB_INDEX_SYMBOL_KIND_OFFSET = 4,
- GDB_INDEX_SYMBOL_KIND_MASK = 7 << GDB_INDEX_SYMBOL_KIND_OFFSET,
-
- // Special value to indicate no attributes are present.
- GDB_INDEX_SYMBOL_KIND_NONE = 0,
- GDB_INDEX_SYMBOL_KIND_TYPE = 1 << GDB_INDEX_SYMBOL_KIND_OFFSET,
- GDB_INDEX_SYMBOL_KIND_VARIABLE = 2 << GDB_INDEX_SYMBOL_KIND_OFFSET,
- GDB_INDEX_SYMBOL_KIND_FUNCTION = 3 << GDB_INDEX_SYMBOL_KIND_OFFSET,
- GDB_INDEX_SYMBOL_KIND_OTHER = 4 << GDB_INDEX_SYMBOL_KIND_OFFSET,
- // 3 unused values.
- GDB_INDEX_SYMBOL_KIND_UNUSED5 = 5 << GDB_INDEX_SYMBOL_KIND_OFFSET,
- GDB_INDEX_SYMBOL_KIND_UNUSED6 = 6 << GDB_INDEX_SYMBOL_KIND_OFFSET,
- GDB_INDEX_SYMBOL_KIND_UNUSED7 = 7 << GDB_INDEX_SYMBOL_KIND_OFFSET,
-
- // Index values are defined via the set of CUs that define the
- // symbol. For the pubnames/pubtypes extensions we need the
- // various shifts and masks.
- GDB_INDEX_SYMBOL_STATIC_OFFSET = 7,
- GDB_INDEX_SYMBOL_STATIC_MASK = 1 << GDB_INDEX_SYMBOL_STATIC_OFFSET,
- GDB_INDEX_SYMBOL_STATIC = 1 << GDB_INDEX_SYMBOL_STATIC_OFFSET,
- GDB_INDEX_SYMBOL_NON_STATIC = 0
+enum GDBIndexEntryKind {
+ GIEK_NONE,
+ GIEK_TYPE,
+ GIEK_VARIABLE,
+ GIEK_FUNCTION,
+ GIEK_OTHER,
+ GIEK_UNUSED5,
+ GIEK_UNUSED6,
+ GIEK_UNUSED7,
};
-/// GDBIndexTypeString - Return the string for the specified index type.
-const char *GDBIndexTypeString(unsigned Kind);
+enum GDBIndexEntryLinkage {
+ GIEL_EXTERNAL,
+ GIEL_STATIC
+};
+
+/// The gnu_pub* kind looks like:
+///
+/// 0-3 reserved
+/// 4-6 symbol kind
+/// 7 0 == global, 1 == static
+///
+/// A gdb_index descriptor includes the above kind, shifted 24 bits up with the
+/// offset of the cu within the debug_info section stored in those 24 bits.
+struct PubIndexEntryDescriptor {
+ GDBIndexEntryKind Kind;
+ bool Static;
+ PubIndexEntryDescriptor(GDBIndexEntryKind Kind, bool Static)
+ : Kind(Kind), Static(Static) {}
+ /* implicit */ PubIndexEntryDescriptor(GDBIndexEntryKind Kind)
+ : Kind(Kind), Static(false) {}
+ explicit PubIndexEntryDescriptor(uint8_t Value)
+ : Kind(static_cast<GDBIndexEntryKind>((Value & KIND_MASK) >>
+ KIND_OFFSET)),
+ Static(Value & STATIC_MASK) {}
+ uint8_t toBits() {
+ return Kind << KIND_OFFSET | Static << STATIC_OFFSET;
+ }
+private:
+ const uint8_t KIND_OFFSET = 4;
+ const uint8_t KIND_MASK = 7 << KIND_OFFSET;
+ const uint8_t STATIC_OFFSET = 7;
+ const uint8_t STATIC_MASK = 1 << STATIC_OFFSET;
+};
} // End of namespace dwarf