summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Expression/DWARFExpression.h2
-rw-r--r--lldb/source/Expression/DWARFExpression.cpp48
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp1
-rw-r--r--lldb/test/lang/c/const_variables/Makefile2
4 files changed, 48 insertions, 5 deletions
diff --git a/lldb/include/lldb/Expression/DWARFExpression.h b/lldb/include/lldb/Expression/DWARFExpression.h
index 79213b8a53e..4f299ef9e20 100644
--- a/lldb/include/lldb/Expression/DWARFExpression.h
+++ b/lldb/include/lldb/Expression/DWARFExpression.h
@@ -442,7 +442,7 @@ protected:
DataExtractor m_data; ///< A data extractor capable of reading opcode bytes
DWARFCompileUnit* m_dwarf_cu; ///< The DWARF compile unit this expression belongs to. It is used
///< to evaluate values indexing into the .debug_addr section (e.g.
- ///< DW_OP_GNU_addr_index
+ ///< DW_OP_GNU_addr_index, DW_OP_GNU_const_index)
lldb::RegisterKind m_reg_kind; ///< One of the defines that starts with LLDB_REGKIND_
lldb::addr_t m_loclist_slide; ///< A value used to slide the location list offsets so that
///< they are relative to the object that owns the location list
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 81dd3c25cee..5a0b3bcc97f 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -199,6 +199,7 @@ DW_OP_value_to_name (uint32_t val)
case 0x99: return "DW_OP_call4";
case 0x9a: return "DW_OP_call_ref";
case 0xfb: return "DW_OP_GNU_addr_index";
+ case 0xfc: return "DW_OP_GNU_const_index";
// case DW_OP_APPLE_array_ref: return "DW_OP_APPLE_array_ref";
// case DW_OP_APPLE_extern: return "DW_OP_APPLE_extern";
case DW_OP_APPLE_uninit: return "DW_OP_APPLE_uninit";
@@ -637,6 +638,9 @@ DWARFExpression::DumpLocation (Stream *s, lldb::offset_t offset, lldb::offset_t
case DW_OP_GNU_addr_index: // 0xfb
s->Printf("DW_OP_GNU_addr_index(0x%" PRIx64 ")", m_data.GetULEB128(&offset));
break;
+ case DW_OP_GNU_const_index: // 0xfc
+ s->Printf("DW_OP_GNU_const_index(0x%" PRIx64 ")", m_data.GetULEB128(&offset));
+ break;
case DW_OP_GNU_push_tls_address:
s->PutCString("DW_OP_GNU_push_tls_address"); // 0xe0
break;
@@ -1040,9 +1044,10 @@ GetOpcodeDataSize (const DataExtractor &data, const lldb::offset_t data_offset,
case DW_OP_regx: // 0x90 1 ULEB128 register
case DW_OP_fbreg: // 0x91 1 SLEB128 offset
case DW_OP_piece: // 0x93 1 ULEB128 size of piece addressed
- case DW_OP_GNU_addr_index: // 0xfb 1 ULEB128 index
+ case DW_OP_GNU_addr_index: // 0xfb 1 ULEB128 index
+ case DW_OP_GNU_const_index: // 0xfc 1 ULEB128 index
data.Skip_LEB128(&offset);
- return offset - data_offset;
+ return offset - data_offset;
// All opcodes that have a 2 ULEB (signed or unsigned) arguments
case DW_OP_bregx: // 0x92 2 ULEB128 register followed by SLEB128 offset
@@ -3022,7 +3027,7 @@ DWARFExpression::Evaluate
if (!dwarf_cu)
{
if (error_ptr)
- error_ptr->SetErrorString ("DW_OP_GNU_addr_index found without a compile being specified");
+ error_ptr->SetErrorString ("DW_OP_GNU_addr_index found without a compile unit being specified");
return false;
}
uint64_t index = opcodes.GetULEB128(&offset);
@@ -3035,6 +3040,43 @@ DWARFExpression::Evaluate
}
break;
+ //----------------------------------------------------------------------
+ // OPCODE: DW_OP_GNU_const_index
+ // OPERANDS: 1
+ // ULEB128: index to the .debug_addr section
+ // DESCRIPTION: Pushes an constant with the size of a machine address to
+ // the stack from the .debug_addr section with the base address specified
+ // by the DW_AT_addr_base attribute and the 0 based index is the ULEB128
+ // encoded index.
+ //----------------------------------------------------------------------
+ case DW_OP_GNU_const_index:
+ {
+ if (!dwarf_cu)
+ {
+ if (error_ptr)
+ error_ptr->SetErrorString ("DW_OP_GNU_const_index found without a compile unit being specified");
+ return false;
+ }
+ uint64_t index = opcodes.GetULEB128(&offset);
+ uint32_t index_size = dwarf_cu->GetAddressByteSize();
+ dw_offset_t addr_base = dwarf_cu->GetAddrBase();
+ lldb::offset_t offset = addr_base + index * index_size;
+ const DWARFDataExtractor& debug_addr = dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data();
+ switch (index_size)
+ {
+ case 4:
+ stack.push_back(Scalar(debug_addr.GetU32(&offset)));
+ break;
+ case 8:
+ stack.push_back(Scalar(debug_addr.GetU64(&offset)));
+ break;
+ default:
+ assert(false && "Unhandled index size");
+ return false;
+ }
+ }
+ break;
+
default:
if (log)
log->Printf("Unhandled opcode %s in DWARFExpression.", DW_OP_value_to_name(op));
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp
index c8bcec5d0f9..481fc2f6864 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp
@@ -150,6 +150,7 @@ print_dwarf_exp_op (Stream &s,
case DW_OP_regx:
size = 128; break;
case DW_OP_GNU_addr_index:
+ case DW_OP_GNU_const_index:
size = 128; break;
default:
s.Printf("UNKNOWN ONE-OPERAND OPCODE, #%u", opcode);
diff --git a/lldb/test/lang/c/const_variables/Makefile b/lldb/test/lang/c/const_variables/Makefile
index 58d04f07b66..51adad1d062 100644
--- a/lldb/test/lang/c/const_variables/Makefile
+++ b/lldb/test/lang/c/const_variables/Makefile
@@ -2,6 +2,6 @@ LEVEL = ../../../make
C_SOURCES := main.c functions.c
-CFLAGS ?= -g -O3
+CFLAGS_EXTRAS += -O3
include $(LEVEL)/Makefile.rules
OpenPOWER on IntegriCloud