Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 1 | //===-- ValueObjectDynamicValue.cpp ---------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | |
| 11 | #include "lldb/Core/ValueObjectDynamicValue.h" |
| 12 | |
| 13 | // C Includes |
| 14 | // C++ Includes |
| 15 | // Other libraries and framework includes |
| 16 | // Project includes |
Enrico Granata | 7b69503 | 2012-10-17 22:23:56 +0000 | [diff] [blame] | 17 | #include "lldb/Core/Log.h" |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 18 | #include "lldb/Core/Module.h" |
| 19 | #include "lldb/Core/ValueObjectList.h" |
| 20 | #include "lldb/Core/Value.h" |
| 21 | #include "lldb/Core/ValueObject.h" |
| 22 | |
Enrico Granata | 89fda00 | 2012-10-27 02:05:48 +0000 | [diff] [blame] | 23 | #include "lldb/Symbol/ClangASTType.h" |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 24 | #include "lldb/Symbol/ObjectFile.h" |
| 25 | #include "lldb/Symbol/SymbolContext.h" |
| 26 | #include "lldb/Symbol/Type.h" |
| 27 | #include "lldb/Symbol/Variable.h" |
| 28 | |
| 29 | #include "lldb/Target/ExecutionContext.h" |
| 30 | #include "lldb/Target/LanguageRuntime.h" |
| 31 | #include "lldb/Target/Process.h" |
| 32 | #include "lldb/Target/RegisterContext.h" |
| 33 | #include "lldb/Target/Target.h" |
| 34 | #include "lldb/Target/Thread.h" |
| 35 | |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 36 | using namespace lldb_private; |
| 37 | |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 38 | ValueObjectDynamicValue::ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic) : |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 39 | ValueObject(parent), |
| 40 | m_address (), |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 41 | m_dynamic_type_info(), |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 42 | m_use_dynamic (use_dynamic) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 43 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 44 | SetName (parent.GetName()); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | ValueObjectDynamicValue::~ValueObjectDynamicValue() |
| 48 | { |
| 49 | m_owning_valobj_sp.reset(); |
| 50 | } |
| 51 | |
Greg Clayton | 52f7923 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 52 | ClangASTType |
Sean Callanan | 931acec | 2012-02-22 23:57:45 +0000 | [diff] [blame] | 53 | ValueObjectDynamicValue::GetClangTypeImpl () |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 54 | { |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 55 | if (m_dynamic_type_info.HasTypeSP()) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 56 | return m_value.GetClangType(); |
| 57 | else |
| 58 | return m_parent->GetClangType(); |
| 59 | } |
| 60 | |
| 61 | ConstString |
| 62 | ValueObjectDynamicValue::GetTypeName() |
| 63 | { |
Enrico Granata | afb7c85 | 2011-08-02 17:27:39 +0000 | [diff] [blame] | 64 | const bool success = UpdateValueIfNeeded(false); |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 65 | if (success) |
| 66 | { |
| 67 | if (m_dynamic_type_info.HasTypeSP()) |
Greg Clayton | 52f7923 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 68 | return GetClangType().GetConstTypeName(); |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 69 | if (m_dynamic_type_info.HasName()) |
| 70 | return m_dynamic_type_info.GetName(); |
| 71 | } |
| 72 | return m_parent->GetTypeName(); |
| 73 | } |
| 74 | |
| 75 | ConstString |
| 76 | ValueObjectDynamicValue::GetQualifiedTypeName() |
| 77 | { |
| 78 | const bool success = UpdateValueIfNeeded(false); |
| 79 | if (success) |
| 80 | { |
| 81 | if (m_dynamic_type_info.HasTypeSP()) |
Greg Clayton | 52f7923 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 82 | return GetClangType().GetConstQualifiedTypeName (); |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 83 | if (m_dynamic_type_info.HasName()) |
| 84 | return m_dynamic_type_info.GetName(); |
| 85 | } |
| 86 | return m_parent->GetTypeName(); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 87 | } |
| 88 | |
Greg Clayton | 36da2aa | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 89 | size_t |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 90 | ValueObjectDynamicValue::CalculateNumChildren() |
| 91 | { |
Enrico Granata | afb7c85 | 2011-08-02 17:27:39 +0000 | [diff] [blame] | 92 | const bool success = UpdateValueIfNeeded(false); |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 93 | if (success && m_dynamic_type_info.HasTypeSP()) |
Greg Clayton | 52f7923 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 94 | return GetClangType().GetNumChildren (true); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 95 | else |
| 96 | return m_parent->GetNumChildren(); |
| 97 | } |
| 98 | |
Greg Clayton | fe6dc6e | 2013-03-14 18:31:44 +0000 | [diff] [blame] | 99 | uint64_t |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 100 | ValueObjectDynamicValue::GetByteSize() |
| 101 | { |
Enrico Granata | afb7c85 | 2011-08-02 17:27:39 +0000 | [diff] [blame] | 102 | const bool success = UpdateValueIfNeeded(false); |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 103 | if (success && m_dynamic_type_info.HasTypeSP()) |
Greg Clayton | 52f7923 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 104 | return m_value.GetValueByteSize(NULL); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 105 | else |
| 106 | return m_parent->GetByteSize(); |
| 107 | } |
| 108 | |
| 109 | lldb::ValueType |
| 110 | ValueObjectDynamicValue::GetValueType() const |
| 111 | { |
| 112 | return m_parent->GetValueType(); |
| 113 | } |
| 114 | |
| 115 | bool |
| 116 | ValueObjectDynamicValue::UpdateValue () |
| 117 | { |
| 118 | SetValueIsValid (false); |
| 119 | m_error.Clear(); |
| 120 | |
Enrico Granata | afb7c85 | 2011-08-02 17:27:39 +0000 | [diff] [blame] | 121 | if (!m_parent->UpdateValueIfNeeded(false)) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 122 | { |
Greg Clayton | 82f0746 | 2011-05-30 00:49:24 +0000 | [diff] [blame] | 123 | // The dynamic value failed to get an error, pass the error along |
| 124 | if (m_error.Success() && m_parent->GetError().Fail()) |
| 125 | m_error = m_parent->GetError(); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 126 | return false; |
| 127 | } |
| 128 | |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 129 | // Setting our type_sp to NULL will route everything back through our |
| 130 | // parent which is equivalent to not using dynamic values. |
| 131 | if (m_use_dynamic == lldb::eNoDynamicValues) |
| 132 | { |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 133 | m_dynamic_type_info.Clear(); |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 134 | return true; |
| 135 | } |
| 136 | |
Greg Clayton | b4d7fc0 | 2012-02-17 07:49:44 +0000 | [diff] [blame] | 137 | ExecutionContext exe_ctx (GetExecutionContextRef()); |
Greg Clayton | 567e7f3 | 2011-09-22 04:58:26 +0000 | [diff] [blame] | 138 | Target *target = exe_ctx.GetTargetPtr(); |
| 139 | if (target) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 140 | { |
Greg Clayton | 567e7f3 | 2011-09-22 04:58:26 +0000 | [diff] [blame] | 141 | m_data.SetByteOrder(target->GetArchitecture().GetByteOrder()); |
| 142 | m_data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize()); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | // First make sure our Type and/or Address haven't changed: |
Greg Clayton | b4d7fc0 | 2012-02-17 07:49:44 +0000 | [diff] [blame] | 146 | Process *process = exe_ctx.GetProcessPtr(); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 147 | if (!process) |
| 148 | return false; |
| 149 | |
Jim Ingham | ef80aab | 2011-05-02 18:13:59 +0000 | [diff] [blame] | 150 | TypeAndOrName class_type_or_name; |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 151 | Address dynamic_address; |
| 152 | bool found_dynamic_type = false; |
| 153 | |
| 154 | lldb::LanguageType known_type = m_parent->GetObjectRuntimeLanguage(); |
| 155 | if (known_type != lldb::eLanguageTypeUnknown && known_type != lldb::eLanguageTypeC) |
| 156 | { |
| 157 | LanguageRuntime *runtime = process->GetLanguageRuntime (known_type); |
| 158 | if (runtime) |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 159 | found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 160 | } |
| 161 | else |
| 162 | { |
| 163 | LanguageRuntime *cpp_runtime = process->GetLanguageRuntime (lldb::eLanguageTypeC_plus_plus); |
| 164 | if (cpp_runtime) |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 165 | found_dynamic_type = cpp_runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 166 | |
| 167 | if (!found_dynamic_type) |
| 168 | { |
| 169 | LanguageRuntime *objc_runtime = process->GetLanguageRuntime (lldb::eLanguageTypeObjC); |
| 170 | if (objc_runtime) |
Enrico Granata | 441f08c | 2011-08-03 02:18:51 +0000 | [diff] [blame] | 171 | found_dynamic_type = objc_runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 172 | } |
| 173 | } |
| 174 | |
Jim Ingham | ef80aab | 2011-05-02 18:13:59 +0000 | [diff] [blame] | 175 | // Getting the dynamic value may have run the program a bit, and so marked us as needing updating, but we really |
| 176 | // don't... |
| 177 | |
| 178 | m_update_point.SetUpdated(); |
| 179 | |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 180 | // If we don't have a dynamic type, then make ourselves just a echo of our parent. |
| 181 | // Or we could return false, and make ourselves an echo of our parent? |
| 182 | if (!found_dynamic_type) |
| 183 | { |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 184 | if (m_dynamic_type_info) |
Enrico Granata | c62ef46 | 2012-11-27 23:50:00 +0000 | [diff] [blame] | 185 | SetValueDidChange(true); |
Enrico Granata | 341c311 | 2012-11-27 23:28:32 +0000 | [diff] [blame] | 186 | ClearDynamicTypeInformation(); |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 187 | m_dynamic_type_info.Clear(); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 188 | m_value = m_parent->GetValue(); |
Greg Clayton | 52f7923 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 189 | m_error = m_value.GetValueAsData (&exe_ctx, m_data, 0, GetModule().get()); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 190 | return m_error.Success(); |
| 191 | } |
| 192 | |
| 193 | Value old_value(m_value); |
| 194 | |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 195 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); |
Enrico Granata | 7b69503 | 2012-10-17 22:23:56 +0000 | [diff] [blame] | 196 | |
Enrico Granata | 3d656c7 | 2012-10-22 18:18:36 +0000 | [diff] [blame] | 197 | bool has_changed_type = false; |
| 198 | |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 199 | if (!m_dynamic_type_info) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 200 | { |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 201 | m_dynamic_type_info = class_type_or_name; |
Enrico Granata | 3d656c7 | 2012-10-22 18:18:36 +0000 | [diff] [blame] | 202 | has_changed_type = true; |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 203 | } |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 204 | else if (class_type_or_name != m_dynamic_type_info) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 205 | { |
| 206 | // We are another type, we need to tear down our children... |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 207 | m_dynamic_type_info = class_type_or_name; |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 208 | SetValueDidChange (true); |
Enrico Granata | 3d656c7 | 2012-10-22 18:18:36 +0000 | [diff] [blame] | 209 | has_changed_type = true; |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 210 | } |
| 211 | |
Enrico Granata | 3d656c7 | 2012-10-22 18:18:36 +0000 | [diff] [blame] | 212 | if (has_changed_type) |
| 213 | ClearDynamicTypeInformation (); |
| 214 | |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 215 | if (!m_address.IsValid() || m_address != dynamic_address) |
| 216 | { |
| 217 | if (m_address.IsValid()) |
| 218 | SetValueDidChange (true); |
| 219 | |
| 220 | // We've moved, so we should be fine... |
| 221 | m_address = dynamic_address; |
Greg Clayton | b4d7fc0 | 2012-02-17 07:49:44 +0000 | [diff] [blame] | 222 | lldb::TargetSP target_sp (GetTargetSP()); |
| 223 | lldb::addr_t load_address = m_address.GetLoadAddress(target_sp.get()); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 224 | m_value.GetScalar() = load_address; |
| 225 | } |
| 226 | |
Greg Clayton | 52f7923 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 227 | ClangASTType corrected_type; |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 228 | if (m_dynamic_type_info.HasTypeSP()) |
| 229 | { |
| 230 | // The type will always be the type of the dynamic object. If our parent's type was a pointer, |
| 231 | // then our type should be a pointer to the type of the dynamic object. If a reference, then the original type |
| 232 | // should be okay... |
Greg Clayton | 52f7923 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 233 | ClangASTType orig_type = m_dynamic_type_info.GetTypeSP()->GetClangForwardType(); |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 234 | corrected_type = orig_type; |
| 235 | if (m_parent->IsPointerType()) |
Greg Clayton | 52f7923 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 236 | corrected_type = orig_type.GetPointerType (); |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 237 | else if (m_parent->IsPointerOrReferenceType()) |
Greg Clayton | 52f7923 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 238 | corrected_type = orig_type.GetLValueReferenceType (); |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 239 | } |
| 240 | else /*if (m_dynamic_type_info.HasName())*/ |
| 241 | { |
| 242 | // If we are here we need to adjust our dynamic type name to include the correct & or * symbol |
| 243 | std::string type_name_buf (m_dynamic_type_info.GetName().GetCString()); |
| 244 | if (m_parent->IsPointerType()) |
| 245 | type_name_buf.append(" *"); |
| 246 | else if (m_parent->IsPointerOrReferenceType()) |
| 247 | type_name_buf.append(" &"); |
| 248 | corrected_type = m_parent->GetClangType(); |
| 249 | m_dynamic_type_info.SetName(type_name_buf.c_str()); |
| 250 | } |
| 251 | |
Greg Clayton | 52f7923 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 252 | //m_value.SetContext (Value::eContextTypeClangType, corrected_type); |
| 253 | m_value.SetClangType (corrected_type); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 254 | |
| 255 | // Our address is the location of the dynamic type stored in memory. It isn't a load address, |
| 256 | // because we aren't pointing to the LOCATION that stores the pointer to us, we're pointing to us... |
| 257 | m_value.SetValueType(Value::eValueTypeScalar); |
| 258 | |
Enrico Granata | 3d656c7 | 2012-10-22 18:18:36 +0000 | [diff] [blame] | 259 | if (has_changed_type && log) |
| 260 | log->Printf("[%s %p] has a new dynamic type %s", |
| 261 | GetName().GetCString(), |
| 262 | this, |
| 263 | GetTypeName().GetCString()); |
| 264 | |
Enrico Granata | 1a469c7 | 2013-01-23 01:17:27 +0000 | [diff] [blame] | 265 | if (m_address.IsValid() && m_dynamic_type_info) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 266 | { |
| 267 | // The variable value is in the Scalar value inside the m_value. |
| 268 | // We can point our m_data right to it. |
Greg Clayton | 52f7923 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 269 | m_error = m_value.GetValueAsData (&exe_ctx, m_data, 0, GetModule().get()); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 270 | if (m_error.Success()) |
| 271 | { |
Greg Clayton | 52f7923 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 272 | if (GetClangType().IsAggregateType ()) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 273 | { |
| 274 | // this value object represents an aggregate type whose |
| 275 | // children have values, but this object does not. So we |
| 276 | // say we are changed if our location has changed. |
| 277 | SetValueDidChange (m_value.GetValueType() != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar()); |
| 278 | } |
| 279 | |
| 280 | SetValueIsValid (true); |
| 281 | return true; |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | // We get here if we've failed above... |
| 286 | SetValueIsValid (false); |
| 287 | return false; |
| 288 | } |
| 289 | |
| 290 | |
| 291 | |
| 292 | bool |
| 293 | ValueObjectDynamicValue::IsInScope () |
| 294 | { |
| 295 | return m_parent->IsInScope(); |
| 296 | } |
| 297 | |
Enrico Granata | 651cbe2 | 2012-05-08 21:25:06 +0000 | [diff] [blame] | 298 | bool |
| 299 | ValueObjectDynamicValue::SetValueFromCString (const char *value_str, Error& error) |
| 300 | { |
| 301 | if (!UpdateValueIfNeeded(false)) |
| 302 | { |
| 303 | error.SetErrorString("unable to read value"); |
| 304 | return false; |
| 305 | } |
| 306 | |
| 307 | uint64_t my_value = GetValueAsUnsigned(UINT64_MAX); |
| 308 | uint64_t parent_value = m_parent->GetValueAsUnsigned(UINT64_MAX); |
| 309 | |
| 310 | if (my_value == UINT64_MAX || parent_value == UINT64_MAX) |
| 311 | { |
| 312 | error.SetErrorString("unable to read value"); |
| 313 | return false; |
| 314 | } |
| 315 | |
| 316 | // if we are at an offset from our parent, in order to set ourselves correctly we would need |
| 317 | // to change the new value so that it refers to the correct dynamic type. we choose not to deal |
| 318 | // with that - if anything more than a value overwrite is required, you should be using the |
| 319 | // expression parser instead of the value editing facility |
| 320 | if (my_value != parent_value) |
| 321 | { |
| 322 | // but NULL'ing out a value should always be allowed |
| 323 | if (strcmp(value_str,"0")) |
| 324 | { |
| 325 | error.SetErrorString("unable to modify dynamic value, use 'expression' command"); |
| 326 | return false; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | bool ret_val = m_parent->SetValueFromCString(value_str,error); |
| 331 | SetNeedsUpdate(); |
| 332 | return ret_val; |
| 333 | } |
Sean Callanan | ab8e00e | 2013-04-13 01:21:23 +0000 | [diff] [blame] | 334 | |
| 335 | bool |
| 336 | ValueObjectDynamicValue::SetData (DataExtractor &data, Error &error) |
| 337 | { |
| 338 | if (!UpdateValueIfNeeded(false)) |
| 339 | { |
| 340 | error.SetErrorString("unable to read value"); |
| 341 | return false; |
| 342 | } |
| 343 | |
| 344 | uint64_t my_value = GetValueAsUnsigned(UINT64_MAX); |
| 345 | uint64_t parent_value = m_parent->GetValueAsUnsigned(UINT64_MAX); |
| 346 | |
| 347 | if (my_value == UINT64_MAX || parent_value == UINT64_MAX) |
| 348 | { |
| 349 | error.SetErrorString("unable to read value"); |
| 350 | return false; |
| 351 | } |
| 352 | |
| 353 | // if we are at an offset from our parent, in order to set ourselves correctly we would need |
| 354 | // to change the new value so that it refers to the correct dynamic type. we choose not to deal |
| 355 | // with that - if anything more than a value overwrite is required, you should be using the |
| 356 | // expression parser instead of the value editing facility |
| 357 | if (my_value != parent_value) |
| 358 | { |
| 359 | // but NULL'ing out a value should always be allowed |
| 360 | lldb::offset_t offset = 0; |
| 361 | |
| 362 | if (data.GetPointer(&offset) != 0) |
| 363 | { |
| 364 | error.SetErrorString("unable to modify dynamic value, use 'expression' command"); |
| 365 | return false; |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | bool ret_val = m_parent->SetData(data, error); |
| 370 | SetNeedsUpdate(); |
| 371 | return ret_val; |
| 372 | } |