mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-28 06:24:57 +00:00
DebugInfo: Simplify gnu_pubnames index computation.
Names open to bikeshedding. Could switch back to the constants being unshifted, but this way seems a bit easier to work with. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191025 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -791,37 +791,34 @@ const char *AtomTypeString(unsigned Atom);
|
|||||||
|
|
||||||
// Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
|
// Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
|
||||||
enum GDBIndex {
|
enum GDBIndex {
|
||||||
// The full index looks like this for each symbol:
|
// The gnu_pub* index value looks like:
|
||||||
//
|
//
|
||||||
// 0-23 CU index
|
// 0-3 reserved
|
||||||
// 24-27 reserved
|
// 4-6 symbol kind
|
||||||
// 28-30 symbol kind
|
// 7 0 == global, 1 == static
|
||||||
// 31 0 == global, 1 == static
|
|
||||||
//
|
|
||||||
// where each entry refers to the CU and some attributes about the symbol.
|
|
||||||
|
|
||||||
// Attributes kinds for the index.
|
// 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.
|
// Special value to indicate no attributes are present.
|
||||||
GDB_INDEX_SYMBOL_KIND_NONE = 0,
|
GDB_INDEX_SYMBOL_KIND_NONE = 0,
|
||||||
GDB_INDEX_SYMBOL_KIND_TYPE = 1,
|
GDB_INDEX_SYMBOL_KIND_TYPE = 1 << GDB_INDEX_SYMBOL_KIND_OFFSET,
|
||||||
GDB_INDEX_SYMBOL_KIND_VARIABLE = 2,
|
GDB_INDEX_SYMBOL_KIND_VARIABLE = 2 << GDB_INDEX_SYMBOL_KIND_OFFSET,
|
||||||
GDB_INDEX_SYMBOL_KIND_FUNCTION = 3,
|
GDB_INDEX_SYMBOL_KIND_FUNCTION = 3 << GDB_INDEX_SYMBOL_KIND_OFFSET,
|
||||||
GDB_INDEX_SYMBOL_KIND_OTHER = 4,
|
GDB_INDEX_SYMBOL_KIND_OTHER = 4 << GDB_INDEX_SYMBOL_KIND_OFFSET,
|
||||||
// 3 unused bits.
|
// 3 unused values.
|
||||||
GDB_INDEX_SYMBOL_KIND_UNUSED5 = 5,
|
GDB_INDEX_SYMBOL_KIND_UNUSED5 = 5 << GDB_INDEX_SYMBOL_KIND_OFFSET,
|
||||||
GDB_INDEX_SYMBOL_KIND_UNUSED6 = 6,
|
GDB_INDEX_SYMBOL_KIND_UNUSED6 = 6 << GDB_INDEX_SYMBOL_KIND_OFFSET,
|
||||||
GDB_INDEX_SYMBOL_KIND_UNUSED7 = 7,
|
GDB_INDEX_SYMBOL_KIND_UNUSED7 = 7 << GDB_INDEX_SYMBOL_KIND_OFFSET,
|
||||||
|
|
||||||
// Index values are defined via the set of CUs that define the
|
// Index values are defined via the set of CUs that define the
|
||||||
// symbol. For the pubnames/pubtypes extensions we need the
|
// symbol. For the pubnames/pubtypes extensions we need the
|
||||||
// various shifts and masks.
|
// various shifts and masks.
|
||||||
GDB_INDEX_SYMBOL_STATIC_SHIFT = 31,
|
GDB_INDEX_SYMBOL_STATIC_OFFSET = 7,
|
||||||
GDB_INDEX_SYMBOL_STATIC_MASK = 1,
|
GDB_INDEX_SYMBOL_STATIC_MASK = 1 << GDB_INDEX_SYMBOL_STATIC_OFFSET,
|
||||||
GDB_INDEX_SYMBOL_KIND_SHIFT = 28,
|
GDB_INDEX_SYMBOL_STATIC = 1 << GDB_INDEX_SYMBOL_STATIC_OFFSET,
|
||||||
GDB_INDEX_SYMBOL_KIND_MASK = 7,
|
GDB_INDEX_SYMBOL_NON_STATIC = 0
|
||||||
GDB_INDEX_CU_BITSIZE = 24,
|
|
||||||
GDB_INDEX_CU_MASK = ((1 << GDB_INDEX_CU_BITSIZE) - 1)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// GDBIndexTypeString - Return the string for the specified index type.
|
/// GDBIndexTypeString - Return the string for the specified index type.
|
||||||
|
@ -2323,21 +2323,9 @@ void DwarfDebug::emitAccelTypes() {
|
|||||||
|
|
||||||
/// computeIndexValue - Compute the gdb index value for the DIE and CU.
|
/// computeIndexValue - Compute the gdb index value for the DIE and CU.
|
||||||
static uint8_t computeIndexValue(CompileUnit *CU, DIE *Die) {
|
static uint8_t computeIndexValue(CompileUnit *CU, DIE *Die) {
|
||||||
#define UPDATE_VALUE(CURRENT, VALUE) \
|
uint8_t IsStatic = Die->findAttribute(dwarf::DW_AT_external)
|
||||||
{ \
|
? dwarf::GDB_INDEX_SYMBOL_NON_STATIC
|
||||||
(CURRENT) |= (((VALUE) & dwarf::GDB_INDEX_SYMBOL_KIND_MASK) \
|
: dwarf::GDB_INDEX_SYMBOL_STATIC;
|
||||||
<< dwarf::GDB_INDEX_SYMBOL_KIND_SHIFT); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define UPDATE_STATIC(CURRENT, IS_STATIC) \
|
|
||||||
{ \
|
|
||||||
(CURRENT) |= (((IS_STATIC) & dwarf::GDB_INDEX_SYMBOL_STATIC_MASK) \
|
|
||||||
<< dwarf::GDB_INDEX_SYMBOL_STATIC_SHIFT); \
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute the Attributes for the Die.
|
|
||||||
uint32_t Value = dwarf::GDB_INDEX_SYMBOL_KIND_NONE;
|
|
||||||
bool External = Die->findAttribute(dwarf::DW_AT_external);
|
|
||||||
|
|
||||||
switch (Die->getTag()) {
|
switch (Die->getTag()) {
|
||||||
case dwarf::DW_TAG_class_type:
|
case dwarf::DW_TAG_class_type:
|
||||||
@ -2347,33 +2335,20 @@ static uint8_t computeIndexValue(CompileUnit *CU, DIE *Die) {
|
|||||||
case dwarf::DW_TAG_typedef:
|
case dwarf::DW_TAG_typedef:
|
||||||
case dwarf::DW_TAG_base_type:
|
case dwarf::DW_TAG_base_type:
|
||||||
case dwarf::DW_TAG_subrange_type:
|
case dwarf::DW_TAG_subrange_type:
|
||||||
UPDATE_VALUE(Value, dwarf::GDB_INDEX_SYMBOL_KIND_TYPE);
|
return dwarf::GDB_INDEX_SYMBOL_KIND_TYPE | dwarf::GDB_INDEX_SYMBOL_STATIC;
|
||||||
UPDATE_STATIC(Value, 1);
|
|
||||||
break;
|
|
||||||
case dwarf::DW_TAG_namespace:
|
case dwarf::DW_TAG_namespace:
|
||||||
UPDATE_VALUE(Value, dwarf::GDB_INDEX_SYMBOL_KIND_TYPE);
|
return dwarf::GDB_INDEX_SYMBOL_KIND_TYPE;
|
||||||
break;
|
|
||||||
case dwarf::DW_TAG_subprogram:
|
case dwarf::DW_TAG_subprogram:
|
||||||
UPDATE_VALUE(Value, dwarf::GDB_INDEX_SYMBOL_KIND_FUNCTION);
|
return dwarf::GDB_INDEX_SYMBOL_KIND_FUNCTION | IsStatic;
|
||||||
UPDATE_STATIC(Value, !External);
|
|
||||||
break;
|
|
||||||
case dwarf::DW_TAG_constant:
|
case dwarf::DW_TAG_constant:
|
||||||
case dwarf::DW_TAG_variable:
|
case dwarf::DW_TAG_variable:
|
||||||
UPDATE_VALUE(Value, dwarf::GDB_INDEX_SYMBOL_KIND_VARIABLE);
|
return dwarf::GDB_INDEX_SYMBOL_KIND_VARIABLE | IsStatic;
|
||||||
UPDATE_STATIC(Value, !External);
|
|
||||||
break;
|
|
||||||
case dwarf::DW_TAG_enumerator:
|
case dwarf::DW_TAG_enumerator:
|
||||||
UPDATE_VALUE(Value, dwarf::GDB_INDEX_SYMBOL_KIND_VARIABLE);
|
return dwarf::GDB_INDEX_SYMBOL_KIND_VARIABLE |
|
||||||
UPDATE_STATIC(Value, 1);
|
dwarf::GDB_INDEX_SYMBOL_STATIC;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
return dwarf::GDB_INDEX_SYMBOL_KIND_NONE;
|
||||||
}
|
}
|
||||||
// We don't need to add the CU into the bitmask for two reasons:
|
|
||||||
// a) the pubnames/pubtypes sections are per-cu, and
|
|
||||||
// b) the linker wouldn't understand it anyhow.
|
|
||||||
// so go ahead and make it 1 byte by shifting it down.
|
|
||||||
return Value >> dwarf::GDB_INDEX_CU_BITSIZE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// emitDebugPubNames - Emit visible names into a debug pubnames section.
|
/// emitDebugPubNames - Emit visible names into a debug pubnames section.
|
||||||
|
Reference in New Issue
Block a user