1ac7ddfbfSEd Maste //===-- ValueObjectRegister.cpp ---------------------------------*- C++ -*-===//
2ac7ddfbfSEd Maste //
3ac7ddfbfSEd Maste //                     The LLVM Compiler Infrastructure
4ac7ddfbfSEd Maste //
5ac7ddfbfSEd Maste // This file is distributed under the University of Illinois Open Source
6ac7ddfbfSEd Maste // License. See LICENSE.TXT for details.
7ac7ddfbfSEd Maste //
8ac7ddfbfSEd Maste //===----------------------------------------------------------------------===//
9ac7ddfbfSEd Maste 
10ac7ddfbfSEd Maste #include "lldb/Core/ValueObjectRegister.h"
11ac7ddfbfSEd Maste 
12ac7ddfbfSEd Maste #include "lldb/Core/Module.h"
13*b5893f02SDimitry Andric #include "lldb/Core/Value.h"
14435933ddSDimitry Andric #include "lldb/Symbol/CompilerType.h"
15*b5893f02SDimitry Andric #include "lldb/Symbol/TypeSystem.h"
16ac7ddfbfSEd Maste #include "lldb/Target/ExecutionContext.h"
17ac7ddfbfSEd Maste #include "lldb/Target/Process.h"
18ac7ddfbfSEd Maste #include "lldb/Target/RegisterContext.h"
19*b5893f02SDimitry Andric #include "lldb/Target/StackFrame.h"
20ac7ddfbfSEd Maste #include "lldb/Target/Target.h"
21*b5893f02SDimitry Andric #include "lldb/Utility/DataExtractor.h"
22*b5893f02SDimitry Andric #include "lldb/Utility/Scalar.h"
23*b5893f02SDimitry Andric #include "lldb/Utility/Status.h"
24*b5893f02SDimitry Andric #include "lldb/Utility/Stream.h"
25f678e45dSDimitry Andric 
26*b5893f02SDimitry Andric #include "llvm/ADT/StringRef.h"
27f678e45dSDimitry Andric 
28*b5893f02SDimitry Andric #include <assert.h>
29*b5893f02SDimitry Andric #include <memory>
30f678e45dSDimitry Andric 
31f678e45dSDimitry Andric namespace lldb_private {
32f678e45dSDimitry Andric class ExecutionContextScope;
33f678e45dSDimitry Andric }
34ac7ddfbfSEd Maste 
35ac7ddfbfSEd Maste using namespace lldb;
36ac7ddfbfSEd Maste using namespace lldb_private;
37ac7ddfbfSEd Maste 
38ac7ddfbfSEd Maste #pragma mark ValueObjectRegisterContext
39ac7ddfbfSEd Maste 
ValueObjectRegisterContext(ValueObject & parent,RegisterContextSP & reg_ctx)40435933ddSDimitry Andric ValueObjectRegisterContext::ValueObjectRegisterContext(
41435933ddSDimitry Andric     ValueObject &parent, RegisterContextSP &reg_ctx)
42435933ddSDimitry Andric     : ValueObject(parent), m_reg_ctx_sp(reg_ctx) {
43ac7ddfbfSEd Maste   assert(reg_ctx);
44ac7ddfbfSEd Maste   m_name.SetCString("Registers");
45ac7ddfbfSEd Maste   SetValueIsValid(true);
46ac7ddfbfSEd Maste }
47ac7ddfbfSEd Maste 
~ValueObjectRegisterContext()48435933ddSDimitry Andric ValueObjectRegisterContext::~ValueObjectRegisterContext() {}
49ac7ddfbfSEd Maste 
GetCompilerTypeImpl()50435933ddSDimitry Andric CompilerType ValueObjectRegisterContext::GetCompilerTypeImpl() {
519f2f44ceSEd Maste   return CompilerType();
52ac7ddfbfSEd Maste }
53ac7ddfbfSEd Maste 
GetTypeName()54435933ddSDimitry Andric ConstString ValueObjectRegisterContext::GetTypeName() { return ConstString(); }
55435933ddSDimitry Andric 
GetDisplayTypeName()56435933ddSDimitry Andric ConstString ValueObjectRegisterContext::GetDisplayTypeName() {
57ac7ddfbfSEd Maste   return ConstString();
58ac7ddfbfSEd Maste }
59ac7ddfbfSEd Maste 
GetQualifiedTypeName()60435933ddSDimitry Andric ConstString ValueObjectRegisterContext::GetQualifiedTypeName() {
610127ef0fSEd Maste   return ConstString();
620127ef0fSEd Maste }
630127ef0fSEd Maste 
CalculateNumChildren(uint32_t max)64435933ddSDimitry Andric size_t ValueObjectRegisterContext::CalculateNumChildren(uint32_t max) {
659f2f44ceSEd Maste   auto reg_set_count = m_reg_ctx_sp->GetRegisterSetCount();
669f2f44ceSEd Maste   return reg_set_count <= max ? reg_set_count : max;
67ac7ddfbfSEd Maste }
68ac7ddfbfSEd Maste 
GetByteSize()69435933ddSDimitry Andric uint64_t ValueObjectRegisterContext::GetByteSize() { return 0; }
70ac7ddfbfSEd Maste 
UpdateValue()71435933ddSDimitry Andric bool ValueObjectRegisterContext::UpdateValue() {
72ac7ddfbfSEd Maste   m_error.Clear();
73ac7ddfbfSEd Maste   ExecutionContext exe_ctx(GetExecutionContextRef());
74ac7ddfbfSEd Maste   StackFrame *frame = exe_ctx.GetFramePtr();
75ac7ddfbfSEd Maste   if (frame)
76ac7ddfbfSEd Maste     m_reg_ctx_sp = frame->GetRegisterContext();
77ac7ddfbfSEd Maste   else
78ac7ddfbfSEd Maste     m_reg_ctx_sp.reset();
79ac7ddfbfSEd Maste 
80435933ddSDimitry Andric   if (m_reg_ctx_sp.get() == NULL) {
81ac7ddfbfSEd Maste     SetValueIsValid(false);
82ac7ddfbfSEd Maste     m_error.SetErrorToGenericError();
83435933ddSDimitry Andric   } else
84ac7ddfbfSEd Maste     SetValueIsValid(true);
85ac7ddfbfSEd Maste 
86ac7ddfbfSEd Maste   return m_error.Success();
87ac7ddfbfSEd Maste }
88ac7ddfbfSEd Maste 
CreateChildAtIndex(size_t idx,bool synthetic_array_member,int32_t synthetic_index)89435933ddSDimitry Andric ValueObject *ValueObjectRegisterContext::CreateChildAtIndex(
90435933ddSDimitry Andric     size_t idx, bool synthetic_array_member, int32_t synthetic_index) {
91ac7ddfbfSEd Maste   ValueObject *new_valobj = NULL;
92ac7ddfbfSEd Maste 
93ac7ddfbfSEd Maste   const size_t num_children = GetNumChildren();
94435933ddSDimitry Andric   if (idx < num_children) {
95ac7ddfbfSEd Maste     ExecutionContext exe_ctx(GetExecutionContextRef());
96435933ddSDimitry Andric     new_valobj = new ValueObjectRegisterSet(
97435933ddSDimitry Andric         exe_ctx.GetBestExecutionContextScope(), m_reg_ctx_sp, idx);
98ac7ddfbfSEd Maste   }
99ac7ddfbfSEd Maste 
100ac7ddfbfSEd Maste   return new_valobj;
101ac7ddfbfSEd Maste }
102ac7ddfbfSEd Maste 
103ac7ddfbfSEd Maste #pragma mark -
104ac7ddfbfSEd Maste #pragma mark ValueObjectRegisterSet
105ac7ddfbfSEd Maste 
106ac7ddfbfSEd Maste ValueObjectSP
Create(ExecutionContextScope * exe_scope,lldb::RegisterContextSP & reg_ctx_sp,uint32_t set_idx)107435933ddSDimitry Andric ValueObjectRegisterSet::Create(ExecutionContextScope *exe_scope,
108435933ddSDimitry Andric                                lldb::RegisterContextSP &reg_ctx_sp,
109435933ddSDimitry Andric                                uint32_t set_idx) {
110ac7ddfbfSEd Maste   return (new ValueObjectRegisterSet(exe_scope, reg_ctx_sp, set_idx))->GetSP();
111ac7ddfbfSEd Maste }
112ac7ddfbfSEd Maste 
ValueObjectRegisterSet(ExecutionContextScope * exe_scope,lldb::RegisterContextSP & reg_ctx,uint32_t reg_set_idx)113435933ddSDimitry Andric ValueObjectRegisterSet::ValueObjectRegisterSet(ExecutionContextScope *exe_scope,
114435933ddSDimitry Andric                                                lldb::RegisterContextSP &reg_ctx,
115435933ddSDimitry Andric                                                uint32_t reg_set_idx)
116435933ddSDimitry Andric     : ValueObject(exe_scope), m_reg_ctx_sp(reg_ctx), m_reg_set(NULL),
117435933ddSDimitry Andric       m_reg_set_idx(reg_set_idx) {
118ac7ddfbfSEd Maste   assert(reg_ctx);
119ac7ddfbfSEd Maste   m_reg_set = reg_ctx->GetRegisterSet(m_reg_set_idx);
120435933ddSDimitry Andric   if (m_reg_set) {
121ac7ddfbfSEd Maste     m_name.SetCString(m_reg_set->name);
122ac7ddfbfSEd Maste   }
123ac7ddfbfSEd Maste }
124ac7ddfbfSEd Maste 
~ValueObjectRegisterSet()125435933ddSDimitry Andric ValueObjectRegisterSet::~ValueObjectRegisterSet() {}
126ac7ddfbfSEd Maste 
GetCompilerTypeImpl()127435933ddSDimitry Andric CompilerType ValueObjectRegisterSet::GetCompilerTypeImpl() {
1289f2f44ceSEd Maste   return CompilerType();
129ac7ddfbfSEd Maste }
130ac7ddfbfSEd Maste 
GetTypeName()131435933ddSDimitry Andric ConstString ValueObjectRegisterSet::GetTypeName() { return ConstString(); }
132435933ddSDimitry Andric 
GetQualifiedTypeName()133435933ddSDimitry Andric ConstString ValueObjectRegisterSet::GetQualifiedTypeName() {
134ac7ddfbfSEd Maste   return ConstString();
135ac7ddfbfSEd Maste }
136ac7ddfbfSEd Maste 
CalculateNumChildren(uint32_t max)137435933ddSDimitry Andric size_t ValueObjectRegisterSet::CalculateNumChildren(uint32_t max) {
138ac7ddfbfSEd Maste   const RegisterSet *reg_set = m_reg_ctx_sp->GetRegisterSet(m_reg_set_idx);
139435933ddSDimitry Andric   if (reg_set) {
1409f2f44ceSEd Maste     auto reg_count = reg_set->num_registers;
1419f2f44ceSEd Maste     return reg_count <= max ? reg_count : max;
1429f2f44ceSEd Maste   }
143ac7ddfbfSEd Maste   return 0;
144ac7ddfbfSEd Maste }
145ac7ddfbfSEd Maste 
GetByteSize()146435933ddSDimitry Andric uint64_t ValueObjectRegisterSet::GetByteSize() { return 0; }
147ac7ddfbfSEd Maste 
UpdateValue()148435933ddSDimitry Andric bool ValueObjectRegisterSet::UpdateValue() {
149ac7ddfbfSEd Maste   m_error.Clear();
150ac7ddfbfSEd Maste   SetValueDidChange(false);
151ac7ddfbfSEd Maste   ExecutionContext exe_ctx(GetExecutionContextRef());
152ac7ddfbfSEd Maste   StackFrame *frame = exe_ctx.GetFramePtr();
153ac7ddfbfSEd Maste   if (frame == NULL)
154ac7ddfbfSEd Maste     m_reg_ctx_sp.reset();
155435933ddSDimitry Andric   else {
156ac7ddfbfSEd Maste     m_reg_ctx_sp = frame->GetRegisterContext();
157435933ddSDimitry Andric     if (m_reg_ctx_sp) {
158ac7ddfbfSEd Maste       const RegisterSet *reg_set = m_reg_ctx_sp->GetRegisterSet(m_reg_set_idx);
159ac7ddfbfSEd Maste       if (reg_set == NULL)
160ac7ddfbfSEd Maste         m_reg_ctx_sp.reset();
161435933ddSDimitry Andric       else if (m_reg_set != reg_set) {
162ac7ddfbfSEd Maste         SetValueDidChange(true);
163ac7ddfbfSEd Maste         m_name.SetCString(reg_set->name);
164ac7ddfbfSEd Maste       }
165ac7ddfbfSEd Maste     }
166ac7ddfbfSEd Maste   }
167435933ddSDimitry Andric   if (m_reg_ctx_sp) {
168ac7ddfbfSEd Maste     SetValueIsValid(true);
169435933ddSDimitry Andric   } else {
170ac7ddfbfSEd Maste     SetValueIsValid(false);
171ac7ddfbfSEd Maste     m_error.SetErrorToGenericError();
172ac7ddfbfSEd Maste     m_children.Clear();
173ac7ddfbfSEd Maste   }
174ac7ddfbfSEd Maste   return m_error.Success();
175ac7ddfbfSEd Maste }
176ac7ddfbfSEd Maste 
CreateChildAtIndex(size_t idx,bool synthetic_array_member,int32_t synthetic_index)177435933ddSDimitry Andric ValueObject *ValueObjectRegisterSet::CreateChildAtIndex(
178435933ddSDimitry Andric     size_t idx, bool synthetic_array_member, int32_t synthetic_index) {
179ac7ddfbfSEd Maste   ValueObject *valobj = NULL;
180435933ddSDimitry Andric   if (m_reg_ctx_sp && m_reg_set) {
181ac7ddfbfSEd Maste     const size_t num_children = GetNumChildren();
182ac7ddfbfSEd Maste     if (idx < num_children)
183435933ddSDimitry Andric       valobj = new ValueObjectRegister(*this, m_reg_ctx_sp,
184435933ddSDimitry Andric                                        m_reg_set->registers[idx]);
185ac7ddfbfSEd Maste   }
186ac7ddfbfSEd Maste   return valobj;
187ac7ddfbfSEd Maste }
188ac7ddfbfSEd Maste 
189ac7ddfbfSEd Maste lldb::ValueObjectSP
GetChildMemberWithName(const ConstString & name,bool can_create)190435933ddSDimitry Andric ValueObjectRegisterSet::GetChildMemberWithName(const ConstString &name,
191435933ddSDimitry Andric                                                bool can_create) {
192ac7ddfbfSEd Maste   ValueObject *valobj = NULL;
193435933ddSDimitry Andric   if (m_reg_ctx_sp && m_reg_set) {
194435933ddSDimitry Andric     const RegisterInfo *reg_info =
195435933ddSDimitry Andric         m_reg_ctx_sp->GetRegisterInfoByName(name.AsCString());
196ac7ddfbfSEd Maste     if (reg_info != NULL)
197435933ddSDimitry Andric       valobj = new ValueObjectRegister(*this, m_reg_ctx_sp,
198435933ddSDimitry Andric                                        reg_info->kinds[eRegisterKindLLDB]);
199ac7ddfbfSEd Maste   }
200ac7ddfbfSEd Maste   if (valobj)
201ac7ddfbfSEd Maste     return valobj->GetSP();
202ac7ddfbfSEd Maste   else
203ac7ddfbfSEd Maste     return ValueObjectSP();
204ac7ddfbfSEd Maste }
205ac7ddfbfSEd Maste 
206ac7ddfbfSEd Maste size_t
GetIndexOfChildWithName(const ConstString & name)207435933ddSDimitry Andric ValueObjectRegisterSet::GetIndexOfChildWithName(const ConstString &name) {
208435933ddSDimitry Andric   if (m_reg_ctx_sp && m_reg_set) {
209435933ddSDimitry Andric     const RegisterInfo *reg_info =
210435933ddSDimitry Andric         m_reg_ctx_sp->GetRegisterInfoByName(name.AsCString());
211ac7ddfbfSEd Maste     if (reg_info != NULL)
212ac7ddfbfSEd Maste       return reg_info->kinds[eRegisterKindLLDB];
213ac7ddfbfSEd Maste   }
214ac7ddfbfSEd Maste   return UINT32_MAX;
215ac7ddfbfSEd Maste }
216ac7ddfbfSEd Maste 
217ac7ddfbfSEd Maste #pragma mark -
218ac7ddfbfSEd Maste #pragma mark ValueObjectRegister
219ac7ddfbfSEd Maste 
ConstructObject(uint32_t reg_num)220435933ddSDimitry Andric void ValueObjectRegister::ConstructObject(uint32_t reg_num) {
221ac7ddfbfSEd Maste   const RegisterInfo *reg_info = m_reg_ctx_sp->GetRegisterInfoAtIndex(reg_num);
222435933ddSDimitry Andric   if (reg_info) {
223ac7ddfbfSEd Maste     m_reg_info = *reg_info;
224ac7ddfbfSEd Maste     if (reg_info->name)
225ac7ddfbfSEd Maste       m_name.SetCString(reg_info->name);
226ac7ddfbfSEd Maste     else if (reg_info->alt_name)
227ac7ddfbfSEd Maste       m_name.SetCString(reg_info->alt_name);
228ac7ddfbfSEd Maste   }
229ac7ddfbfSEd Maste }
230ac7ddfbfSEd Maste 
ValueObjectRegister(ValueObject & parent,lldb::RegisterContextSP & reg_ctx_sp,uint32_t reg_num)231435933ddSDimitry Andric ValueObjectRegister::ValueObjectRegister(ValueObject &parent,
232435933ddSDimitry Andric                                          lldb::RegisterContextSP &reg_ctx_sp,
233435933ddSDimitry Andric                                          uint32_t reg_num)
234435933ddSDimitry Andric     : ValueObject(parent), m_reg_ctx_sp(reg_ctx_sp), m_reg_info(),
235435933ddSDimitry Andric       m_reg_value(), m_type_name(), m_compiler_type() {
236ac7ddfbfSEd Maste   assert(reg_ctx_sp.get());
237ac7ddfbfSEd Maste   ConstructObject(reg_num);
238ac7ddfbfSEd Maste }
239ac7ddfbfSEd Maste 
Create(ExecutionContextScope * exe_scope,lldb::RegisterContextSP & reg_ctx_sp,uint32_t reg_num)240435933ddSDimitry Andric ValueObjectSP ValueObjectRegister::Create(ExecutionContextScope *exe_scope,
241435933ddSDimitry Andric                                           lldb::RegisterContextSP &reg_ctx_sp,
242435933ddSDimitry Andric                                           uint32_t reg_num) {
243ac7ddfbfSEd Maste   return (new ValueObjectRegister(exe_scope, reg_ctx_sp, reg_num))->GetSP();
244ac7ddfbfSEd Maste }
245ac7ddfbfSEd Maste 
ValueObjectRegister(ExecutionContextScope * exe_scope,lldb::RegisterContextSP & reg_ctx,uint32_t reg_num)246435933ddSDimitry Andric ValueObjectRegister::ValueObjectRegister(ExecutionContextScope *exe_scope,
247435933ddSDimitry Andric                                          lldb::RegisterContextSP &reg_ctx,
248435933ddSDimitry Andric                                          uint32_t reg_num)
249435933ddSDimitry Andric     : ValueObject(exe_scope), m_reg_ctx_sp(reg_ctx), m_reg_info(),
250435933ddSDimitry Andric       m_reg_value(), m_type_name(), m_compiler_type() {
251ac7ddfbfSEd Maste   assert(reg_ctx);
252ac7ddfbfSEd Maste   ConstructObject(reg_num);
253ac7ddfbfSEd Maste }
254ac7ddfbfSEd Maste 
~ValueObjectRegister()255435933ddSDimitry Andric ValueObjectRegister::~ValueObjectRegister() {}
256ac7ddfbfSEd Maste 
GetCompilerTypeImpl()257435933ddSDimitry Andric CompilerType ValueObjectRegister::GetCompilerTypeImpl() {
258435933ddSDimitry Andric   if (!m_compiler_type.IsValid()) {
259ac7ddfbfSEd Maste     ExecutionContext exe_ctx(GetExecutionContextRef());
260ac7ddfbfSEd Maste     Target *target = exe_ctx.GetTargetPtr();
261435933ddSDimitry Andric     if (target) {
262ac7ddfbfSEd Maste       Module *exe_module = target->GetExecutableModulePointer();
263435933ddSDimitry Andric       if (exe_module) {
264435933ddSDimitry Andric         TypeSystem *type_system =
265435933ddSDimitry Andric             exe_module->GetTypeSystemForLanguage(eLanguageTypeC);
2669f2f44ceSEd Maste         if (type_system)
267435933ddSDimitry Andric           m_compiler_type = type_system->GetBuiltinTypeForEncodingAndBitSize(
268435933ddSDimitry Andric               m_reg_info.encoding, m_reg_info.byte_size * 8);
269ac7ddfbfSEd Maste       }
270ac7ddfbfSEd Maste     }
271ac7ddfbfSEd Maste   }
2729f2f44ceSEd Maste   return m_compiler_type;
273ac7ddfbfSEd Maste }
274ac7ddfbfSEd Maste 
GetTypeName()275435933ddSDimitry Andric ConstString ValueObjectRegister::GetTypeName() {
276ac7ddfbfSEd Maste   if (m_type_name.IsEmpty())
2779f2f44ceSEd Maste     m_type_name = GetCompilerType().GetConstTypeName();
278ac7ddfbfSEd Maste   return m_type_name;
279ac7ddfbfSEd Maste }
280ac7ddfbfSEd Maste 
CalculateNumChildren(uint32_t max)281435933ddSDimitry Andric size_t ValueObjectRegister::CalculateNumChildren(uint32_t max) {
282*b5893f02SDimitry Andric   ExecutionContext exe_ctx(GetExecutionContextRef());
283*b5893f02SDimitry Andric   auto children_count = GetCompilerType().GetNumChildren(true, &exe_ctx);
2849f2f44ceSEd Maste   return children_count <= max ? children_count : max;
285ac7ddfbfSEd Maste }
286ac7ddfbfSEd Maste 
GetByteSize()287435933ddSDimitry Andric uint64_t ValueObjectRegister::GetByteSize() { return m_reg_info.byte_size; }
288ac7ddfbfSEd Maste 
UpdateValue()289435933ddSDimitry Andric bool ValueObjectRegister::UpdateValue() {
290ac7ddfbfSEd Maste   m_error.Clear();
291ac7ddfbfSEd Maste   ExecutionContext exe_ctx(GetExecutionContextRef());
292ac7ddfbfSEd Maste   StackFrame *frame = exe_ctx.GetFramePtr();
293435933ddSDimitry Andric   if (frame == NULL) {
294ac7ddfbfSEd Maste     m_reg_ctx_sp.reset();
295ac7ddfbfSEd Maste     m_reg_value.Clear();
296ac7ddfbfSEd Maste   }
297ac7ddfbfSEd Maste 
298435933ddSDimitry Andric   if (m_reg_ctx_sp) {
299435933ddSDimitry Andric     RegisterValue m_old_reg_value(m_reg_value);
300435933ddSDimitry Andric     if (m_reg_ctx_sp->ReadRegister(&m_reg_info, m_reg_value)) {
301435933ddSDimitry Andric       if (m_reg_value.GetData(m_data)) {
302ac7ddfbfSEd Maste         Process *process = exe_ctx.GetProcessPtr();
303ac7ddfbfSEd Maste         if (process)
304ac7ddfbfSEd Maste           m_data.SetAddressByteSize(process->GetAddressByteSize());
305435933ddSDimitry Andric         m_value.SetContext(Value::eContextTypeRegisterInfo,
306435933ddSDimitry Andric                            (void *)&m_reg_info);
307ac7ddfbfSEd Maste         m_value.SetValueType(Value::eValueTypeHostAddress);
308ac7ddfbfSEd Maste         m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
309ac7ddfbfSEd Maste         SetValueIsValid(true);
310435933ddSDimitry Andric         SetValueDidChange(!(m_old_reg_value == m_reg_value));
311ac7ddfbfSEd Maste         return true;
312ac7ddfbfSEd Maste       }
313ac7ddfbfSEd Maste     }
314ac7ddfbfSEd Maste   }
315ac7ddfbfSEd Maste 
316ac7ddfbfSEd Maste   SetValueIsValid(false);
317ac7ddfbfSEd Maste   m_error.SetErrorToGenericError();
318ac7ddfbfSEd Maste   return false;
319ac7ddfbfSEd Maste }
320ac7ddfbfSEd Maste 
SetValueFromCString(const char * value_str,Status & error)321435933ddSDimitry Andric bool ValueObjectRegister::SetValueFromCString(const char *value_str,
3225517e702SDimitry Andric                                               Status &error) {
323ac7ddfbfSEd Maste   // The new value will be in the m_data.  Copy that into our register value.
324435933ddSDimitry Andric   error =
325435933ddSDimitry Andric       m_reg_value.SetValueFromString(&m_reg_info, llvm::StringRef(value_str));
326435933ddSDimitry Andric   if (error.Success()) {
327435933ddSDimitry Andric     if (m_reg_ctx_sp->WriteRegister(&m_reg_info, m_reg_value)) {
328ac7ddfbfSEd Maste       SetNeedsUpdate();
329ac7ddfbfSEd Maste       return true;
330435933ddSDimitry Andric     } else
331ac7ddfbfSEd Maste       return false;
332435933ddSDimitry Andric   } else
333ac7ddfbfSEd Maste     return false;
334ac7ddfbfSEd Maste }
335ac7ddfbfSEd Maste 
SetData(DataExtractor & data,Status & error)3365517e702SDimitry Andric bool ValueObjectRegister::SetData(DataExtractor &data, Status &error) {
337ac7ddfbfSEd Maste   error = m_reg_value.SetValueFromData(&m_reg_info, data, 0, false);
338435933ddSDimitry Andric   if (error.Success()) {
339435933ddSDimitry Andric     if (m_reg_ctx_sp->WriteRegister(&m_reg_info, m_reg_value)) {
340ac7ddfbfSEd Maste       SetNeedsUpdate();
341ac7ddfbfSEd Maste       return true;
342435933ddSDimitry Andric     } else
343ac7ddfbfSEd Maste       return false;
344435933ddSDimitry Andric   } else
345ac7ddfbfSEd Maste     return false;
346ac7ddfbfSEd Maste }
347ac7ddfbfSEd Maste 
ResolveValue(Scalar & scalar)348435933ddSDimitry Andric bool ValueObjectRegister::ResolveValue(Scalar &scalar) {
349435933ddSDimitry Andric   if (UpdateValueIfNeeded(
350435933ddSDimitry Andric           false)) // make sure that you are up to date before returning anything
351ac7ddfbfSEd Maste     return m_reg_value.GetScalarValue(scalar);
352ac7ddfbfSEd Maste   return false;
353ac7ddfbfSEd Maste }
354ac7ddfbfSEd Maste 
GetExpressionPath(Stream & s,bool qualify_cxx_base_classes,GetExpressionPathFormat epformat)355435933ddSDimitry Andric void ValueObjectRegister::GetExpressionPath(Stream &s,
356435933ddSDimitry Andric                                             bool qualify_cxx_base_classes,
357435933ddSDimitry Andric                                             GetExpressionPathFormat epformat) {
358ac7ddfbfSEd Maste   s.Printf("$%s", m_reg_info.name);
359ac7ddfbfSEd Maste }
360