[LLDB] Fix how ValueObjectVariable handles DW_AT_const_value when the DWARFExpression holds the data that represents a constant value

In some cases when we have a DW_AT_const_value and the data can be found in the
DWARFExpression then ValueObjectVariable does not handle it properly and we end
up with an extracting data from value failed error.

The test is a very stripped down assembly file since reproducing this relies on the results of compiling with -O1 which may not be stable over time.

Differential Revision: https://reviews.llvm.org/D86311
This commit is contained in:
shafik
2020-08-24 14:38:55 -07:00
parent 62e91bf563
commit 93b255142b
2 changed files with 413 additions and 1 deletions

View File

@@ -132,8 +132,11 @@ bool ValueObjectVariable::UpdateValue() {
if (variable->GetLocationIsConstantValueData()) {
// expr doesn't contain DWARF bytes, it contains the constant variable
// value bytes themselves...
if (expr.GetExpressionData(m_data))
if (expr.GetExpressionData(m_data)) {
if (m_data.GetDataStart() && m_data.GetByteSize())
m_value.SetBytes(m_data.GetDataStart(), m_data.GetByteSize());
m_value.SetContext(Value::eContextTypeVariable, variable);
}
else
m_error.SetErrorString("empty constant data");
// constant bytes can't be edited - sorry