Add support for DW_OP_push_object_address in dwarf expressions

Additionally fix the type of some dwarf expression where we had a
confusion between scalar and load address types after a dereference.

Differential revision: http://reviews.llvm.org/D17604

llvm-svn: 262014
This commit is contained in:
Tamas Berghammer 2016-02-26 14:21:10 +00:00
parent 38f912ea00
commit 5b42c7aa25
8 changed files with 64 additions and 22 deletions

View File

@ -282,6 +282,7 @@ public:
ClangExpressionDeclMap *decl_map,
lldb::addr_t loclist_base_load_addr,
const Value* initial_value_ptr,
const Value* object_address_ptr,
Value& result,
Error *error_ptr) const;
@ -296,6 +297,7 @@ public:
RegisterContext *reg_ctx,
lldb::addr_t loclist_base_load_addr,
const Value* initial_value_ptr,
const Value* object_address_ptr,
Value& result,
Error *error_ptr) const;
@ -370,6 +372,7 @@ public:
const lldb::offset_t length,
const lldb::RegisterKind reg_set,
const Value* initial_value_ptr,
const Value* object_address_ptr,
Value& result,
Error *error_ptr);

View File

@ -164,7 +164,15 @@ ValueObjectVariable::UpdateValue ()
loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (target);
}
Value old_value(m_value);
if (expr.Evaluate (&exe_ctx, NULL, NULL, NULL, loclist_base_load_addr, NULL, m_value, &m_error))
if (expr.Evaluate (&exe_ctx,
nullptr,
nullptr,
nullptr,
loclist_base_load_addr,
nullptr,
nullptr,
m_value,
&m_error))
{
m_resolved_value = m_value;
m_value.SetContext(Value::eContextTypeVariable, variable);

View File

@ -1108,12 +1108,21 @@ DWARFExpression::Evaluate
ClangExpressionDeclMap *decl_map,
lldb::addr_t loclist_base_load_addr,
const Value* initial_value_ptr,
const Value* object_address_ptr,
Value& result,
Error *error_ptr
) const
{
ExecutionContext exe_ctx (exe_scope);
return Evaluate(&exe_ctx, expr_locals, decl_map, NULL, loclist_base_load_addr, initial_value_ptr, result, error_ptr);
return Evaluate(&exe_ctx,
expr_locals,
decl_map,
nullptr,
loclist_base_load_addr,
initial_value_ptr,
object_address_ptr,
result,
error_ptr);
}
bool
@ -1125,6 +1134,7 @@ DWARFExpression::Evaluate
RegisterContext *reg_ctx,
lldb::addr_t loclist_base_load_addr,
const Value* initial_value_ptr,
const Value* object_address_ptr,
Value& result,
Error *error_ptr
) const
@ -1189,6 +1199,7 @@ DWARFExpression::Evaluate
length,
m_reg_kind,
initial_value_ptr,
object_address_ptr,
result,
error_ptr);
}
@ -1212,6 +1223,7 @@ DWARFExpression::Evaluate
m_data.GetByteSize(),
m_reg_kind,
initial_value_ptr,
object_address_ptr,
result,
error_ptr);
}
@ -1232,6 +1244,7 @@ DWARFExpression::Evaluate
const lldb::offset_t opcodes_length,
const lldb::RegisterKind reg_kind,
const Value* initial_value_ptr,
const Value* object_address_ptr,
Value& result,
Error *error_ptr
)
@ -1367,6 +1380,7 @@ DWARFExpression::Evaluate
intptr_t ptr;
::memcpy (&ptr, src, sizeof(void *));
stack.back().GetScalar() = ptr;
stack.back().SetValueType(Value::eValueTypeScalar);
stack.back().ClearContext();
}
break;
@ -1381,6 +1395,7 @@ DWARFExpression::Evaluate
if (pointer_value != LLDB_INVALID_ADDRESS)
{
stack.back().GetScalar() = pointer_value;
stack.back().SetValueType(Value::eValueTypeScalar);
stack.back().ClearContext();
}
else
@ -1462,6 +1477,7 @@ DWARFExpression::Evaluate
default: break;
}
stack.back().GetScalar() = ptr;
stack.back().SetValueType(Value::eValueTypeScalar);
stack.back().ClearContext();
}
break;
@ -1485,6 +1501,7 @@ DWARFExpression::Evaluate
case 8: stack.back().GetScalar() = addr_data.GetU64(&addr_data_offset); break;
default: stack.back().GetScalar() = addr_data.GetPointer(&addr_data_offset);
}
stack.back().SetValueType(Value::eValueTypeScalar);
stack.back().ClearContext();
}
else
@ -2689,9 +2706,15 @@ DWARFExpression::Evaluate
// during user expression evaluation.
//----------------------------------------------------------------------
case DW_OP_push_object_address:
if (error_ptr)
error_ptr->SetErrorString ("Unimplemented opcode DW_OP_push_object_address.");
return false;
if (object_address_ptr)
stack.push_back(*object_address_ptr);
else
{
if (error_ptr)
error_ptr->SetErrorString ("DW_OP_push_object_address used without specifying an object address");
return false;
}
break;
//----------------------------------------------------------------------
// OPCODE: DW_OP_call2

View File

@ -1536,7 +1536,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, lldb_privat
dwarfexpr.SetRegisterKind (unwindplan_registerkind);
Value result;
Error error;
if (dwarfexpr.Evaluate (&exe_ctx, NULL, NULL, this, 0, NULL, result, &error))
if (dwarfexpr.Evaluate (&exe_ctx, nullptr, nullptr, this, 0, nullptr, nullptr, result, &error))
{
addr_t val;
val = result.GetScalar().ULongLong();
@ -1836,7 +1836,7 @@ RegisterContextLLDB::ReadCFAValueForRow (lldb::RegisterKind row_register_kind,
dwarfexpr.SetRegisterKind (row_register_kind);
Value result;
Error error;
if (dwarfexpr.Evaluate (&exe_ctx, NULL, NULL, this, 0, NULL, result, &error))
if (dwarfexpr.Evaluate (&exe_ctx, nullptr, nullptr, this, 0, nullptr, nullptr, result, &error))
{
cfa_value = result.GetScalar().ULongLong();

View File

@ -2703,10 +2703,10 @@ DWARFASTParserClang::ParseChildMembers (const SymbolContext& sc,
const DWARFDataExtractor& debug_info_data = die.GetDWARF()->get_debug_info_data();
uint32_t block_length = form_value.Unsigned();
uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
if (DWARFExpression::Evaluate(NULL, // ExecutionContext *
NULL, // ClangExpressionVariableList *
NULL, // ClangExpressionDeclMap *
NULL, // RegisterContext *
if (DWARFExpression::Evaluate(nullptr, // ExecutionContext *
nullptr, // ClangExpressionVariableList *
nullptr, // ClangExpressionDeclMap *
nullptr, // RegisterContext *
module_sp,
debug_info_data,
die.GetCU(),
@ -2714,8 +2714,9 @@ DWARFASTParserClang::ParseChildMembers (const SymbolContext& sc,
block_length,
eRegisterKindDWARF,
&initialValue,
nullptr,
memberOffset,
NULL))
nullptr))
{
member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
}
@ -3129,10 +3130,10 @@ DWARFASTParserClang::ParseChildMembers (const SymbolContext& sc,
const DWARFDataExtractor& debug_info_data = die.GetDWARF()->get_debug_info_data();
uint32_t block_length = form_value.Unsigned();
uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
if (DWARFExpression::Evaluate (NULL,
NULL,
NULL,
NULL,
if (DWARFExpression::Evaluate (nullptr,
nullptr,
nullptr,
nullptr,
module_sp,
debug_info_data,
die.GetCU(),
@ -3140,8 +3141,9 @@ DWARFASTParserClang::ParseChildMembers (const SymbolContext& sc,
block_length,
eRegisterKindDWARF,
&initialValue,
nullptr,
memberOffset,
NULL))
nullptr))
{
member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
}

View File

@ -715,7 +715,7 @@ DWARFASTParserGo::ParseChildMembers(const SymbolContext &sc, const DWARFDIE &par
NULL, // RegisterContext *
module_sp, debug_info_data, die.GetCU(),
block_offset, block_length, eRegisterKindDWARF,
&initialValue, memberOffset, NULL))
&initialValue, NULL, memberOffset, NULL))
{
member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
}

View File

@ -1063,7 +1063,6 @@ SymbolFileDWARF::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpec
if (cu_die)
{
const char * cu_comp_dir = resolveCompDir(cu_die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr));
const dw_offset_t stmt_list = cu_die.GetAttributeValueAsUnsigned(DW_AT_stmt_list, DW_INVALID_OFFSET);
if (stmt_list != DW_INVALID_OFFSET)
{
@ -1832,7 +1831,7 @@ SymbolFileDWARF::GetGlobalAranges()
const DWARFExpression &location = var_sp->LocationExpression();
Value location_result;
Error error;
if (location.Evaluate(NULL, NULL, NULL, LLDB_INVALID_ADDRESS, NULL, location_result, &error))
if (location.Evaluate(nullptr, nullptr, nullptr, LLDB_INVALID_ADDRESS, nullptr, nullptr, location_result, &error))
{
if (location_result.GetValueType() == Value::eValueTypeFileAddress)
{

View File

@ -1221,8 +1221,15 @@ StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr)
if (m_sc.function->GetFrameBaseExpression().IsLocationList())
loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.GetTargetPtr());
if (!m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx, nullptr, nullptr, nullptr, loclist_base_addr,
nullptr, expr_value, &m_frame_base_error))
if (m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx,
nullptr,
nullptr,
nullptr,
loclist_base_addr,
nullptr,
nullptr,
expr_value,
&m_frame_base_error) == false)
{
// We should really have an error if evaluate returns, but in case
// we don't, lets set the error to something at least.