From 07a4ac22edd3f08cb460a651a2318d9bf5090ba1 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Tue, 8 May 2012 21:25:06 +0000 Subject: Fixing a bug where the SetValueFromCString() method failed to operate on dynamic values. The fix consists in making the set operation fall through to the parent. We only actually allow this if the dynamic value is at a 0-offset from the parent, or the new value is 0. Other scenarios would need agreement on the actual meaning of the set operation (do we keep offsetting? do we just assume the user knows what they are doing?) so we prevent them, and let the expression parser deal with the complexity llvm-svn: 156422 --- lldb/source/Core/ValueObject.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lldb/source/Core/ValueObject.cpp') diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index b0b1a67095a..cd41f1d689f 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -1591,12 +1591,16 @@ ValueObject::GetPointerValue (AddressType *address_type) } bool -ValueObject::SetValueFromCString (const char *value_str) +ValueObject::SetValueFromCString (const char *value_str, Error& error) { + error.Clear(); // Make sure our value is up to date first so that our location and location // type is valid. if (!UpdateValueIfNeeded(false)) + { + error.SetErrorString("unable to read value"); return false; + } uint32_t count = 0; Encoding encoding = ClangASTType::GetEncoding (GetClangType(), count); @@ -1615,7 +1619,6 @@ ValueObject::SetValueFromCString (const char *value_str) // If the value fits in a scalar, then make a new scalar and again let the // scalar code do the conversion, then figure out where to put the new value. Scalar new_scalar; - Error error; error = new_scalar.SetValueFromCString (value_str, encoding, byte_size); if (error.Success()) { @@ -1634,8 +1637,13 @@ ValueObject::SetValueFromCString (const char *value_str) new_scalar, byte_size, error); - if (!error.Success() || bytes_written != byte_size) - return false; + if (!error.Success()) + return false; + if (bytes_written != byte_size) + { + error.SetErrorString("unable to write value to memory"); + return false; + } } } break; @@ -1673,6 +1681,7 @@ ValueObject::SetValueFromCString (const char *value_str) else { // We don't support setting things bigger than a scalar at present. + error.SetErrorString("unable to write aggregate data type"); return false; } -- cgit v1.2.3