1 //===-- SBValue.cpp ---------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/API/SBValue.h"
12 #include "lldb/API/SBDeclaration.h"
13 #include "lldb/API/SBStream.h"
14 #include "lldb/API/SBTypeFilter.h"
15 #include "lldb/API/SBTypeFormat.h"
16 #include "lldb/API/SBTypeSummary.h"
17 #include "lldb/API/SBTypeSynthetic.h"
19 #include "lldb/Breakpoint/Watchpoint.h"
20 #include "lldb/Core/Module.h"
21 #include "lldb/Core/Section.h"
22 #include "lldb/Core/StreamFile.h"
23 #include "lldb/Core/Value.h"
24 #include "lldb/Core/ValueObject.h"
25 #include "lldb/Core/ValueObjectConstResult.h"
26 #include "lldb/DataFormatters/DataVisualization.h"
27 #include "lldb/Symbol/Block.h"
28 #include "lldb/Symbol/Declaration.h"
29 #include "lldb/Symbol/ObjectFile.h"
30 #include "lldb/Symbol/Type.h"
31 #include "lldb/Symbol/Variable.h"
32 #include "lldb/Symbol/VariableList.h"
33 #include "lldb/Target/ExecutionContext.h"
34 #include "lldb/Target/Process.h"
35 #include "lldb/Target/StackFrame.h"
36 #include "lldb/Target/Target.h"
37 #include "lldb/Target/Thread.h"
38 #include "lldb/Utility/DataExtractor.h"
39 #include "lldb/Utility/Log.h"
40 #include "lldb/Utility/Scalar.h"
41 #include "lldb/Utility/Stream.h"
43 #include "lldb/API/SBDebugger.h"
44 #include "lldb/API/SBExpressionOptions.h"
45 #include "lldb/API/SBFrame.h"
46 #include "lldb/API/SBProcess.h"
47 #include "lldb/API/SBTarget.h"
48 #include "lldb/API/SBThread.h"
51 using namespace lldb_private;
57 ValueImpl(lldb::ValueObjectSP in_valobj_sp,
58 lldb::DynamicValueType use_dynamic, bool use_synthetic,
59 const char *name = NULL)
60 : m_valobj_sp(), m_use_dynamic(use_dynamic),
61 m_use_synthetic(use_synthetic), m_name(name) {
63 if ((m_valobj_sp = in_valobj_sp->GetQualifiedRepresentationIfAvailable(
64 lldb::eNoDynamicValues, false))) {
65 if (!m_name.IsEmpty())
66 m_valobj_sp->SetName(m_name);
71 ValueImpl(const ValueImpl &rhs)
72 : m_valobj_sp(rhs.m_valobj_sp), m_use_dynamic(rhs.m_use_dynamic),
73 m_use_synthetic(rhs.m_use_synthetic), m_name(rhs.m_name) {}
75 ValueImpl &operator=(const ValueImpl &rhs) {
77 m_valobj_sp = rhs.m_valobj_sp;
78 m_use_dynamic = rhs.m_use_dynamic;
79 m_use_synthetic = rhs.m_use_synthetic;
86 if (m_valobj_sp.get() == NULL)
89 // FIXME: This check is necessary but not sufficient. We for sure don't
90 // want to touch SBValues whose owning
91 // targets have gone away. This check is a little weak in that it
92 // enforces that restriction when you call IsValid, but since IsValid
93 // doesn't lock the target, you have no guarantee that the SBValue won't
94 // go invalid after you call this... Also, an SBValue could depend on
95 // data from one of the modules in the target, and those could go away
96 // independently of the target, for instance if a module is unloaded.
97 // But right now, neither SBValues nor ValueObjects know which modules
98 // they depend on. So I have no good way to make that check without
99 // tracking that in all the ValueObject subclasses.
100 TargetSP target_sp = m_valobj_sp->GetTargetSP();
101 return target_sp && target_sp->IsValid();
105 lldb::ValueObjectSP GetRootSP() { return m_valobj_sp; }
107 lldb::ValueObjectSP GetSP(Process::StopLocker &stop_locker,
108 std::unique_lock<std::recursive_mutex> &lock,
110 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
112 error.SetErrorString("invalid value object");
116 lldb::ValueObjectSP value_sp = m_valobj_sp;
118 Target *target = value_sp->GetTargetSP().get();
120 return ValueObjectSP();
122 lock = std::unique_lock<std::recursive_mutex>(target->GetAPIMutex());
124 ProcessSP process_sp(value_sp->GetProcessSP());
125 if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock())) {
126 // We don't allow people to play around with ValueObject if the process
127 // is running. If you want to look at values, pause the process, then
130 log->Printf("SBValue(%p)::GetSP() => error: process is running",
131 static_cast<void *>(value_sp.get()));
132 error.SetErrorString("process must be stopped.");
133 return ValueObjectSP();
136 if (m_use_dynamic != eNoDynamicValues) {
137 ValueObjectSP dynamic_sp = value_sp->GetDynamicValue(m_use_dynamic);
139 value_sp = dynamic_sp;
142 if (m_use_synthetic) {
143 ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue(m_use_synthetic);
145 value_sp = synthetic_sp;
149 error.SetErrorString("invalid value object");
150 if (!m_name.IsEmpty())
151 value_sp->SetName(m_name);
156 void SetUseDynamic(lldb::DynamicValueType use_dynamic) {
157 m_use_dynamic = use_dynamic;
160 void SetUseSynthetic(bool use_synthetic) { m_use_synthetic = use_synthetic; }
162 lldb::DynamicValueType GetUseDynamic() { return m_use_dynamic; }
164 bool GetUseSynthetic() { return m_use_synthetic; }
166 // All the derived values that we would make from the m_valobj_sp will share
167 // the ExecutionContext with m_valobj_sp, so we don't need to do the
168 // calculations in GetSP to return the Target, Process, Thread or Frame. It
169 // is convenient to provide simple accessors for these, which I do here.
170 TargetSP GetTargetSP() {
172 return m_valobj_sp->GetTargetSP();
177 ProcessSP GetProcessSP() {
179 return m_valobj_sp->GetProcessSP();
184 ThreadSP GetThreadSP() {
186 return m_valobj_sp->GetThreadSP();
191 StackFrameSP GetFrameSP() {
193 return m_valobj_sp->GetFrameSP();
195 return StackFrameSP();
199 lldb::ValueObjectSP m_valobj_sp;
200 lldb::DynamicValueType m_use_dynamic;
201 bool m_use_synthetic;
209 ValueObjectSP GetLockedSP(ValueImpl &in_value) {
210 return in_value.GetSP(m_stop_locker, m_lock, m_lock_error);
213 Status &GetError() { return m_lock_error; }
216 Process::StopLocker m_stop_locker;
217 std::unique_lock<std::recursive_mutex> m_lock;
221 SBValue::SBValue() : m_opaque_sp() {}
223 SBValue::SBValue(const lldb::ValueObjectSP &value_sp) { SetSP(value_sp); }
225 SBValue::SBValue(const SBValue &rhs) { SetSP(rhs.m_opaque_sp); }
227 SBValue &SBValue::operator=(const SBValue &rhs) {
229 SetSP(rhs.m_opaque_sp);
234 SBValue::~SBValue() {}
236 bool SBValue::IsValid() {
237 // If this function ever changes to anything that does more than just check
238 // if the opaque shared pointer is non NULL, then we need to update all "if
239 // (m_opaque_sp)" code in this file.
240 return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid() &&
241 m_opaque_sp->GetRootSP().get() != NULL;
244 void SBValue::Clear() { m_opaque_sp.reset(); }
246 SBError SBValue::GetError() {
250 lldb::ValueObjectSP value_sp(GetSP(locker));
252 sb_error.SetError(value_sp->GetError());
254 sb_error.SetErrorStringWithFormat("error: %s",
255 locker.GetError().AsCString());
260 user_id_t SBValue::GetID() {
262 lldb::ValueObjectSP value_sp(GetSP(locker));
264 return value_sp->GetID();
265 return LLDB_INVALID_UID;
268 const char *SBValue::GetName() {
269 const char *name = NULL;
271 lldb::ValueObjectSP value_sp(GetSP(locker));
273 name = value_sp->GetName().GetCString();
275 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
278 log->Printf("SBValue(%p)::GetName () => \"%s\"",
279 static_cast<void *>(value_sp.get()), name);
281 log->Printf("SBValue(%p)::GetName () => NULL",
282 static_cast<void *>(value_sp.get()));
288 const char *SBValue::GetTypeName() {
289 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
290 const char *name = NULL;
292 lldb::ValueObjectSP value_sp(GetSP(locker));
294 name = value_sp->GetQualifiedTypeName().GetCString();
299 log->Printf("SBValue(%p)::GetTypeName () => \"%s\"",
300 static_cast<void *>(value_sp.get()), name);
302 log->Printf("SBValue(%p)::GetTypeName () => NULL",
303 static_cast<void *>(value_sp.get()));
309 const char *SBValue::GetDisplayTypeName() {
310 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
311 const char *name = NULL;
313 lldb::ValueObjectSP value_sp(GetSP(locker));
315 name = value_sp->GetDisplayTypeName().GetCString();
320 log->Printf("SBValue(%p)::GetTypeName () => \"%s\"",
321 static_cast<void *>(value_sp.get()), name);
323 log->Printf("SBValue(%p)::GetTypeName () => NULL",
324 static_cast<void *>(value_sp.get()));
330 size_t SBValue::GetByteSize() {
331 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
335 lldb::ValueObjectSP value_sp(GetSP(locker));
337 result = value_sp->GetByteSize();
341 log->Printf("SBValue(%p)::GetByteSize () => %" PRIu64,
342 static_cast<void *>(value_sp.get()),
343 static_cast<uint64_t>(result));
348 bool SBValue::IsInScope() {
352 lldb::ValueObjectSP value_sp(GetSP(locker));
354 result = value_sp->IsInScope();
357 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
359 log->Printf("SBValue(%p)::IsInScope () => %i",
360 static_cast<void *>(value_sp.get()), result);
365 const char *SBValue::GetValue() {
366 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
368 const char *cstr = NULL;
370 lldb::ValueObjectSP value_sp(GetSP(locker));
372 cstr = value_sp->GetValueAsCString();
376 log->Printf("SBValue(%p)::GetValue() => \"%s\"",
377 static_cast<void *>(value_sp.get()), cstr);
379 log->Printf("SBValue(%p)::GetValue() => NULL",
380 static_cast<void *>(value_sp.get()));
386 ValueType SBValue::GetValueType() {
387 ValueType result = eValueTypeInvalid;
389 lldb::ValueObjectSP value_sp(GetSP(locker));
391 result = value_sp->GetValueType();
393 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
396 case eValueTypeInvalid:
397 log->Printf("SBValue(%p)::GetValueType () => eValueTypeInvalid",
398 static_cast<void *>(value_sp.get()));
400 case eValueTypeVariableGlobal:
401 log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal",
402 static_cast<void *>(value_sp.get()));
404 case eValueTypeVariableStatic:
405 log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableStatic",
406 static_cast<void *>(value_sp.get()));
408 case eValueTypeVariableArgument:
409 log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableArgument",
410 static_cast<void *>(value_sp.get()));
412 case eValueTypeVariableLocal:
413 log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableLocal",
414 static_cast<void *>(value_sp.get()));
416 case eValueTypeRegister:
417 log->Printf("SBValue(%p)::GetValueType () => eValueTypeRegister",
418 static_cast<void *>(value_sp.get()));
420 case eValueTypeRegisterSet:
421 log->Printf("SBValue(%p)::GetValueType () => eValueTypeRegisterSet",
422 static_cast<void *>(value_sp.get()));
424 case eValueTypeConstResult:
425 log->Printf("SBValue(%p)::GetValueType () => eValueTypeConstResult",
426 static_cast<void *>(value_sp.get()));
428 case eValueTypeVariableThreadLocal:
430 "SBValue(%p)::GetValueType () => eValueTypeVariableThreadLocal",
431 static_cast<void *>(value_sp.get()));
438 const char *SBValue::GetObjectDescription() {
439 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
440 const char *cstr = NULL;
442 lldb::ValueObjectSP value_sp(GetSP(locker));
444 cstr = value_sp->GetObjectDescription();
448 log->Printf("SBValue(%p)::GetObjectDescription() => \"%s\"",
449 static_cast<void *>(value_sp.get()), cstr);
451 log->Printf("SBValue(%p)::GetObjectDescription() => NULL",
452 static_cast<void *>(value_sp.get()));
457 const char *SBValue::GetTypeValidatorResult() {
458 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
459 const char *cstr = NULL;
461 lldb::ValueObjectSP value_sp(GetSP(locker));
463 const auto &validation(value_sp->GetValidationStatus());
464 if (TypeValidatorResult::Failure == validation.first) {
465 if (validation.second.empty())
466 cstr = "unknown error";
468 cstr = validation.second.c_str();
473 log->Printf("SBValue(%p)::GetTypeValidatorResult() => \"%s\"",
474 static_cast<void *>(value_sp.get()), cstr);
476 log->Printf("SBValue(%p)::GetTypeValidatorResult() => NULL",
477 static_cast<void *>(value_sp.get()));
482 SBType SBValue::GetType() {
483 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
486 lldb::ValueObjectSP value_sp(GetSP(locker));
489 type_sp.reset(new TypeImpl(value_sp->GetTypeImpl()));
490 sb_type.SetSP(type_sp);
494 log->Printf("SBValue(%p)::GetType => SBType(%p)",
495 static_cast<void *>(value_sp.get()),
496 static_cast<void *>(type_sp.get()));
498 log->Printf("SBValue(%p)::GetType => NULL",
499 static_cast<void *>(value_sp.get()));
504 bool SBValue::GetValueDidChange() {
505 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
508 lldb::ValueObjectSP value_sp(GetSP(locker));
510 if (value_sp->UpdateValueIfNeeded(false))
511 result = value_sp->GetValueDidChange();
514 log->Printf("SBValue(%p)::GetValueDidChange() => %i",
515 static_cast<void *>(value_sp.get()), result);
520 const char *SBValue::GetSummary() {
521 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
522 const char *cstr = NULL;
524 lldb::ValueObjectSP value_sp(GetSP(locker));
526 cstr = value_sp->GetSummaryAsCString();
530 log->Printf("SBValue(%p)::GetSummary() => \"%s\"",
531 static_cast<void *>(value_sp.get()), cstr);
533 log->Printf("SBValue(%p)::GetSummary() => NULL",
534 static_cast<void *>(value_sp.get()));
539 const char *SBValue::GetSummary(lldb::SBStream &stream,
540 lldb::SBTypeSummaryOptions &options) {
541 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
543 lldb::ValueObjectSP value_sp(GetSP(locker));
546 if (value_sp->GetSummaryAsCString(buffer, options.ref()) && !buffer.empty())
547 stream.Printf("%s", buffer.c_str());
549 const char *cstr = stream.GetData();
552 log->Printf("SBValue(%p)::GetSummary() => \"%s\"",
553 static_cast<void *>(value_sp.get()), cstr);
555 log->Printf("SBValue(%p)::GetSummary() => NULL",
556 static_cast<void *>(value_sp.get()));
561 const char *SBValue::GetLocation() {
562 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
563 const char *cstr = NULL;
565 lldb::ValueObjectSP value_sp(GetSP(locker));
567 cstr = value_sp->GetLocationAsCString();
571 log->Printf("SBValue(%p)::GetLocation() => \"%s\"",
572 static_cast<void *>(value_sp.get()), cstr);
574 log->Printf("SBValue(%p)::GetLocation() => NULL",
575 static_cast<void *>(value_sp.get()));
580 // Deprecated - use the one that takes an lldb::SBError
581 bool SBValue::SetValueFromCString(const char *value_str) {
583 return SetValueFromCString(value_str, dummy);
586 bool SBValue::SetValueFromCString(const char *value_str, lldb::SBError &error) {
587 bool success = false;
589 lldb::ValueObjectSP value_sp(GetSP(locker));
590 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
592 success = value_sp->SetValueFromCString(value_str, error.ref());
594 error.SetErrorStringWithFormat("Could not get value: %s",
595 locker.GetError().AsCString());
598 log->Printf("SBValue(%p)::SetValueFromCString(\"%s\") => %i",
599 static_cast<void *>(value_sp.get()), value_str, success);
604 lldb::SBTypeFormat SBValue::GetTypeFormat() {
605 lldb::SBTypeFormat format;
607 lldb::ValueObjectSP value_sp(GetSP(locker));
609 if (value_sp->UpdateValueIfNeeded(true)) {
610 lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
612 format.SetSP(format_sp);
618 lldb::SBTypeSummary SBValue::GetTypeSummary() {
619 lldb::SBTypeSummary summary;
621 lldb::ValueObjectSP value_sp(GetSP(locker));
623 if (value_sp->UpdateValueIfNeeded(true)) {
624 lldb::TypeSummaryImplSP summary_sp = value_sp->GetSummaryFormat();
626 summary.SetSP(summary_sp);
632 lldb::SBTypeFilter SBValue::GetTypeFilter() {
633 lldb::SBTypeFilter filter;
635 lldb::ValueObjectSP value_sp(GetSP(locker));
637 if (value_sp->UpdateValueIfNeeded(true)) {
638 lldb::SyntheticChildrenSP synthetic_sp = value_sp->GetSyntheticChildren();
640 if (synthetic_sp && !synthetic_sp->IsScripted()) {
641 TypeFilterImplSP filter_sp =
642 std::static_pointer_cast<TypeFilterImpl>(synthetic_sp);
643 filter.SetSP(filter_sp);
650 #ifndef LLDB_DISABLE_PYTHON
651 lldb::SBTypeSynthetic SBValue::GetTypeSynthetic() {
652 lldb::SBTypeSynthetic synthetic;
654 lldb::ValueObjectSP value_sp(GetSP(locker));
656 if (value_sp->UpdateValueIfNeeded(true)) {
657 lldb::SyntheticChildrenSP children_sp = value_sp->GetSyntheticChildren();
659 if (children_sp && children_sp->IsScripted()) {
660 ScriptedSyntheticChildrenSP synth_sp =
661 std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
662 synthetic.SetSP(synth_sp);
670 lldb::SBValue SBValue::CreateChildAtOffset(const char *name, uint32_t offset,
672 lldb::SBValue sb_value;
674 lldb::ValueObjectSP value_sp(GetSP(locker));
675 lldb::ValueObjectSP new_value_sp;
677 TypeImplSP type_sp(type.GetSP());
678 if (type.IsValid()) {
679 sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(
680 offset, type_sp->GetCompilerType(false), true),
681 GetPreferDynamicValue(), GetPreferSyntheticValue(), name);
684 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
687 log->Printf("SBValue(%p)::CreateChildAtOffset => \"%s\"",
688 static_cast<void *>(value_sp.get()),
689 new_value_sp->GetName().AsCString());
691 log->Printf("SBValue(%p)::CreateChildAtOffset => NULL",
692 static_cast<void *>(value_sp.get()));
697 lldb::SBValue SBValue::Cast(SBType type) {
698 lldb::SBValue sb_value;
700 lldb::ValueObjectSP value_sp(GetSP(locker));
701 TypeImplSP type_sp(type.GetSP());
702 if (value_sp && type_sp)
703 sb_value.SetSP(value_sp->Cast(type_sp->GetCompilerType(false)),
704 GetPreferDynamicValue(), GetPreferSyntheticValue());
708 lldb::SBValue SBValue::CreateValueFromExpression(const char *name,
709 const char *expression) {
710 SBExpressionOptions options;
711 options.ref().SetKeepInMemory(true);
712 return CreateValueFromExpression(name, expression, options);
715 lldb::SBValue SBValue::CreateValueFromExpression(const char *name,
716 const char *expression,
717 SBExpressionOptions &options) {
718 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
719 lldb::SBValue sb_value;
721 lldb::ValueObjectSP value_sp(GetSP(locker));
722 lldb::ValueObjectSP new_value_sp;
724 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
725 new_value_sp = ValueObject::CreateValueObjectFromExpression(
726 name, expression, exe_ctx, options.ref());
728 new_value_sp->SetName(ConstString(name));
730 sb_value.SetSP(new_value_sp);
733 log->Printf("SBValue(%p)::CreateValueFromExpression(name=\"%s\", "
734 "expression=\"%s\") => SBValue (%p)",
735 static_cast<void *>(value_sp.get()), name, expression,
736 static_cast<void *>(new_value_sp.get()));
738 log->Printf("SBValue(%p)::CreateValueFromExpression(name=\"%s\", "
739 "expression=\"%s\") => NULL",
740 static_cast<void *>(value_sp.get()), name, expression);
745 lldb::SBValue SBValue::CreateValueFromAddress(const char *name,
746 lldb::addr_t address,
748 lldb::SBValue sb_value;
750 lldb::ValueObjectSP value_sp(GetSP(locker));
751 lldb::ValueObjectSP new_value_sp;
752 lldb::TypeImplSP type_impl_sp(sb_type.GetSP());
753 if (value_sp && type_impl_sp) {
754 CompilerType ast_type(type_impl_sp->GetCompilerType(true));
755 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
756 new_value_sp = ValueObject::CreateValueObjectFromAddress(name, address,
759 sb_value.SetSP(new_value_sp);
760 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
763 log->Printf("SBValue(%p)::CreateValueFromAddress => \"%s\"",
764 static_cast<void *>(value_sp.get()),
765 new_value_sp->GetName().AsCString());
767 log->Printf("SBValue(%p)::CreateValueFromAddress => NULL",
768 static_cast<void *>(value_sp.get()));
773 lldb::SBValue SBValue::CreateValueFromData(const char *name, SBData data,
775 lldb::SBValue sb_value;
776 lldb::ValueObjectSP new_value_sp;
778 lldb::ValueObjectSP value_sp(GetSP(locker));
779 lldb::TypeImplSP type_impl_sp(sb_type.GetSP());
780 if (value_sp && type_impl_sp) {
781 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
782 new_value_sp = ValueObject::CreateValueObjectFromData(
783 name, **data, exe_ctx, type_impl_sp->GetCompilerType(true));
784 new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
786 sb_value.SetSP(new_value_sp);
787 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
790 log->Printf("SBValue(%p)::CreateValueFromData => \"%s\"",
791 static_cast<void *>(value_sp.get()),
792 new_value_sp->GetName().AsCString());
794 log->Printf("SBValue(%p)::CreateValueFromData => NULL",
795 static_cast<void *>(value_sp.get()));
800 SBValue SBValue::GetChildAtIndex(uint32_t idx) {
801 const bool can_create_synthetic = false;
802 lldb::DynamicValueType use_dynamic = eNoDynamicValues;
805 target_sp = m_opaque_sp->GetTargetSP();
808 use_dynamic = target_sp->GetPreferDynamicValue();
810 return GetChildAtIndex(idx, use_dynamic, can_create_synthetic);
813 SBValue SBValue::GetChildAtIndex(uint32_t idx,
814 lldb::DynamicValueType use_dynamic,
815 bool can_create_synthetic) {
816 lldb::ValueObjectSP child_sp;
817 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
820 lldb::ValueObjectSP value_sp(GetSP(locker));
822 const bool can_create = true;
823 child_sp = value_sp->GetChildAtIndex(idx, can_create);
824 if (can_create_synthetic && !child_sp) {
825 child_sp = value_sp->GetSyntheticArrayMember(idx, can_create);
830 sb_value.SetSP(child_sp, use_dynamic, GetPreferSyntheticValue());
832 log->Printf("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)",
833 static_cast<void *>(value_sp.get()), idx,
834 static_cast<void *>(value_sp.get()));
839 uint32_t SBValue::GetIndexOfChildWithName(const char *name) {
840 uint32_t idx = UINT32_MAX;
842 lldb::ValueObjectSP value_sp(GetSP(locker));
844 idx = value_sp->GetIndexOfChildWithName(ConstString(name));
846 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
848 if (idx == UINT32_MAX)
850 "SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND",
851 static_cast<void *>(value_sp.get()), name);
853 log->Printf("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u",
854 static_cast<void *>(value_sp.get()), name, idx);
859 SBValue SBValue::GetChildMemberWithName(const char *name) {
860 lldb::DynamicValueType use_dynamic_value = eNoDynamicValues;
863 target_sp = m_opaque_sp->GetTargetSP();
866 use_dynamic_value = target_sp->GetPreferDynamicValue();
867 return GetChildMemberWithName(name, use_dynamic_value);
871 SBValue::GetChildMemberWithName(const char *name,
872 lldb::DynamicValueType use_dynamic_value) {
873 lldb::ValueObjectSP child_sp;
874 const ConstString str_name(name);
876 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
879 lldb::ValueObjectSP value_sp(GetSP(locker));
881 child_sp = value_sp->GetChildMemberWithName(str_name, true);
885 sb_value.SetSP(child_sp, use_dynamic_value, GetPreferSyntheticValue());
889 "SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)",
890 static_cast<void *>(value_sp.get()), name,
891 static_cast<void *>(value_sp.get()));
896 lldb::SBValue SBValue::GetDynamicValue(lldb::DynamicValueType use_dynamic) {
899 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), use_dynamic,
900 m_opaque_sp->GetUseSynthetic()));
901 value_sb.SetSP(proxy_sp);
906 lldb::SBValue SBValue::GetStaticValue() {
909 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
911 m_opaque_sp->GetUseSynthetic()));
912 value_sb.SetSP(proxy_sp);
917 lldb::SBValue SBValue::GetNonSyntheticValue() {
920 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
921 m_opaque_sp->GetUseDynamic(), false));
922 value_sb.SetSP(proxy_sp);
927 lldb::DynamicValueType SBValue::GetPreferDynamicValue() {
929 return eNoDynamicValues;
930 return m_opaque_sp->GetUseDynamic();
933 void SBValue::SetPreferDynamicValue(lldb::DynamicValueType use_dynamic) {
935 return m_opaque_sp->SetUseDynamic(use_dynamic);
938 bool SBValue::GetPreferSyntheticValue() {
941 return m_opaque_sp->GetUseSynthetic();
944 void SBValue::SetPreferSyntheticValue(bool use_synthetic) {
946 return m_opaque_sp->SetUseSynthetic(use_synthetic);
949 bool SBValue::IsDynamic() {
951 lldb::ValueObjectSP value_sp(GetSP(locker));
953 return value_sp->IsDynamic();
957 bool SBValue::IsSynthetic() {
959 lldb::ValueObjectSP value_sp(GetSP(locker));
961 return value_sp->IsSynthetic();
965 bool SBValue::IsSyntheticChildrenGenerated() {
967 lldb::ValueObjectSP value_sp(GetSP(locker));
969 return value_sp->IsSyntheticChildrenGenerated();
973 void SBValue::SetSyntheticChildrenGenerated(bool is) {
975 lldb::ValueObjectSP value_sp(GetSP(locker));
977 return value_sp->SetSyntheticChildrenGenerated(is);
980 lldb::SBValue SBValue::GetValueForExpressionPath(const char *expr_path) {
981 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
982 lldb::ValueObjectSP child_sp;
984 lldb::ValueObjectSP value_sp(GetSP(locker));
986 // using default values for all the fancy options, just do it if you can
987 child_sp = value_sp->GetValueForExpressionPath(expr_path);
991 sb_value.SetSP(child_sp, GetPreferDynamicValue(), GetPreferSyntheticValue());
994 log->Printf("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => "
996 static_cast<void *>(value_sp.get()), expr_path,
997 static_cast<void *>(value_sp.get()));
1002 int64_t SBValue::GetValueAsSigned(SBError &error, int64_t fail_value) {
1005 lldb::ValueObjectSP value_sp(GetSP(locker));
1007 bool success = true;
1008 uint64_t ret_val = fail_value;
1009 ret_val = value_sp->GetValueAsSigned(fail_value, &success);
1011 error.SetErrorString("could not resolve value");
1014 error.SetErrorStringWithFormat("could not get SBValue: %s",
1015 locker.GetError().AsCString());
1020 uint64_t SBValue::GetValueAsUnsigned(SBError &error, uint64_t fail_value) {
1023 lldb::ValueObjectSP value_sp(GetSP(locker));
1025 bool success = true;
1026 uint64_t ret_val = fail_value;
1027 ret_val = value_sp->GetValueAsUnsigned(fail_value, &success);
1029 error.SetErrorString("could not resolve value");
1032 error.SetErrorStringWithFormat("could not get SBValue: %s",
1033 locker.GetError().AsCString());
1038 int64_t SBValue::GetValueAsSigned(int64_t fail_value) {
1040 lldb::ValueObjectSP value_sp(GetSP(locker));
1042 return value_sp->GetValueAsSigned(fail_value);
1047 uint64_t SBValue::GetValueAsUnsigned(uint64_t fail_value) {
1049 lldb::ValueObjectSP value_sp(GetSP(locker));
1051 return value_sp->GetValueAsUnsigned(fail_value);
1056 bool SBValue::MightHaveChildren() {
1057 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1058 bool has_children = false;
1060 lldb::ValueObjectSP value_sp(GetSP(locker));
1062 has_children = value_sp->MightHaveChildren();
1065 log->Printf("SBValue(%p)::MightHaveChildren() => %i",
1066 static_cast<void *>(value_sp.get()), has_children);
1067 return has_children;
1070 bool SBValue::IsRuntimeSupportValue() {
1071 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1072 bool is_support = false;
1074 lldb::ValueObjectSP value_sp(GetSP(locker));
1076 is_support = value_sp->IsRuntimeSupportValue();
1079 log->Printf("SBValue(%p)::IsRuntimeSupportValue() => %i",
1080 static_cast<void *>(value_sp.get()), is_support);
1084 uint32_t SBValue::GetNumChildren() { return GetNumChildren(UINT32_MAX); }
1086 uint32_t SBValue::GetNumChildren(uint32_t max) {
1087 uint32_t num_children = 0;
1089 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1091 lldb::ValueObjectSP value_sp(GetSP(locker));
1093 num_children = value_sp->GetNumChildren(max);
1096 log->Printf("SBValue(%p)::GetNumChildren (%u) => %u",
1097 static_cast<void *>(value_sp.get()), max, num_children);
1099 return num_children;
1102 SBValue SBValue::Dereference() {
1105 lldb::ValueObjectSP value_sp(GetSP(locker));
1108 sb_value = value_sp->Dereference(error);
1110 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1112 log->Printf("SBValue(%p)::Dereference () => SBValue(%p)",
1113 static_cast<void *>(value_sp.get()),
1114 static_cast<void *>(value_sp.get()));
1119 // Deprecated - please use GetType().IsPointerType() instead.
1120 bool SBValue::TypeIsPointerType() { return GetType().IsPointerType(); }
1122 void *SBValue::GetOpaqueType() {
1124 lldb::ValueObjectSP value_sp(GetSP(locker));
1126 return value_sp->GetCompilerType().GetOpaqueQualType();
1130 lldb::SBTarget SBValue::GetTarget() {
1134 target_sp = m_opaque_sp->GetTargetSP();
1135 sb_target.SetSP(target_sp);
1137 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1139 if (target_sp.get() == NULL)
1140 log->Printf("SBValue(%p)::GetTarget () => NULL",
1141 static_cast<void *>(m_opaque_sp.get()));
1143 log->Printf("SBValue(%p)::GetTarget () => %p",
1144 static_cast<void *>(m_opaque_sp.get()),
1145 static_cast<void *>(target_sp.get()));
1150 lldb::SBProcess SBValue::GetProcess() {
1151 SBProcess sb_process;
1152 ProcessSP process_sp;
1154 process_sp = m_opaque_sp->GetProcessSP();
1155 sb_process.SetSP(process_sp);
1157 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1159 if (process_sp.get() == NULL)
1160 log->Printf("SBValue(%p)::GetProcess () => NULL",
1161 static_cast<void *>(m_opaque_sp.get()));
1163 log->Printf("SBValue(%p)::GetProcess () => %p",
1164 static_cast<void *>(m_opaque_sp.get()),
1165 static_cast<void *>(process_sp.get()));
1170 lldb::SBThread SBValue::GetThread() {
1174 thread_sp = m_opaque_sp->GetThreadSP();
1175 sb_thread.SetThread(thread_sp);
1177 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1179 if (thread_sp.get() == NULL)
1180 log->Printf("SBValue(%p)::GetThread () => NULL",
1181 static_cast<void *>(m_opaque_sp.get()));
1183 log->Printf("SBValue(%p)::GetThread () => %p",
1184 static_cast<void *>(m_opaque_sp.get()),
1185 static_cast<void *>(thread_sp.get()));
1190 lldb::SBFrame SBValue::GetFrame() {
1192 StackFrameSP frame_sp;
1194 frame_sp = m_opaque_sp->GetFrameSP();
1195 sb_frame.SetFrameSP(frame_sp);
1197 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1199 if (frame_sp.get() == NULL)
1200 log->Printf("SBValue(%p)::GetFrame () => NULL",
1201 static_cast<void *>(m_opaque_sp.get()));
1203 log->Printf("SBValue(%p)::GetFrame () => %p",
1204 static_cast<void *>(m_opaque_sp.get()),
1205 static_cast<void *>(frame_sp.get()));
1210 lldb::ValueObjectSP SBValue::GetSP(ValueLocker &locker) const {
1211 if (!m_opaque_sp || !m_opaque_sp->IsValid()) {
1212 locker.GetError().SetErrorString("No value");
1213 return ValueObjectSP();
1215 return locker.GetLockedSP(*m_opaque_sp.get());
1218 lldb::ValueObjectSP SBValue::GetSP() const {
1220 return GetSP(locker);
1223 void SBValue::SetSP(ValueImplSP impl_sp) { m_opaque_sp = impl_sp; }
1225 void SBValue::SetSP(const lldb::ValueObjectSP &sp) {
1227 lldb::TargetSP target_sp(sp->GetTargetSP());
1229 lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1230 bool use_synthetic =
1231 target_sp->TargetProperties::GetEnableSyntheticValue();
1232 m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
1234 m_opaque_sp = ValueImplSP(new ValueImpl(sp, eNoDynamicValues, true));
1236 m_opaque_sp = ValueImplSP(new ValueImpl(sp, eNoDynamicValues, false));
1239 void SBValue::SetSP(const lldb::ValueObjectSP &sp,
1240 lldb::DynamicValueType use_dynamic) {
1242 lldb::TargetSP target_sp(sp->GetTargetSP());
1244 bool use_synthetic =
1245 target_sp->TargetProperties::GetEnableSyntheticValue();
1246 SetSP(sp, use_dynamic, use_synthetic);
1248 SetSP(sp, use_dynamic, true);
1250 SetSP(sp, use_dynamic, false);
1253 void SBValue::SetSP(const lldb::ValueObjectSP &sp, bool use_synthetic) {
1255 lldb::TargetSP target_sp(sp->GetTargetSP());
1257 lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1258 SetSP(sp, use_dynamic, use_synthetic);
1260 SetSP(sp, eNoDynamicValues, use_synthetic);
1262 SetSP(sp, eNoDynamicValues, use_synthetic);
1265 void SBValue::SetSP(const lldb::ValueObjectSP &sp,
1266 lldb::DynamicValueType use_dynamic, bool use_synthetic) {
1267 m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
1270 void SBValue::SetSP(const lldb::ValueObjectSP &sp,
1271 lldb::DynamicValueType use_dynamic, bool use_synthetic,
1274 ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic, name));
1277 bool SBValue::GetExpressionPath(SBStream &description) {
1279 lldb::ValueObjectSP value_sp(GetSP(locker));
1281 value_sp->GetExpressionPath(description.ref(), false);
1287 bool SBValue::GetExpressionPath(SBStream &description,
1288 bool qualify_cxx_base_classes) {
1290 lldb::ValueObjectSP value_sp(GetSP(locker));
1292 value_sp->GetExpressionPath(description.ref(), qualify_cxx_base_classes);
1298 bool SBValue::GetDescription(SBStream &description) {
1299 Stream &strm = description.ref();
1302 lldb::ValueObjectSP value_sp(GetSP(locker));
1304 value_sp->Dump(strm);
1306 strm.PutCString("No value");
1311 lldb::Format SBValue::GetFormat() {
1313 lldb::ValueObjectSP value_sp(GetSP(locker));
1315 return value_sp->GetFormat();
1316 return eFormatDefault;
1319 void SBValue::SetFormat(lldb::Format format) {
1321 lldb::ValueObjectSP value_sp(GetSP(locker));
1323 value_sp->SetFormat(format);
1326 lldb::SBValue SBValue::AddressOf() {
1329 lldb::ValueObjectSP value_sp(GetSP(locker));
1332 sb_value.SetSP(value_sp->AddressOf(error), GetPreferDynamicValue(),
1333 GetPreferSyntheticValue());
1335 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1337 log->Printf("SBValue(%p)::AddressOf () => SBValue(%p)",
1338 static_cast<void *>(value_sp.get()),
1339 static_cast<void *>(value_sp.get()));
1344 lldb::addr_t SBValue::GetLoadAddress() {
1345 lldb::addr_t value = LLDB_INVALID_ADDRESS;
1347 lldb::ValueObjectSP value_sp(GetSP(locker));
1349 TargetSP target_sp(value_sp->GetTargetSP());
1351 const bool scalar_is_load_address = true;
1352 AddressType addr_type;
1353 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
1354 if (addr_type == eAddressTypeFile) {
1355 ModuleSP module_sp(value_sp->GetModule());
1357 value = LLDB_INVALID_ADDRESS;
1360 module_sp->ResolveFileAddress(value, addr);
1361 value = addr.GetLoadAddress(target_sp.get());
1363 } else if (addr_type == eAddressTypeHost ||
1364 addr_type == eAddressTypeInvalid)
1365 value = LLDB_INVALID_ADDRESS;
1368 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1370 log->Printf("SBValue(%p)::GetLoadAddress () => (%" PRIu64 ")",
1371 static_cast<void *>(value_sp.get()), value);
1376 lldb::SBAddress SBValue::GetAddress() {
1379 lldb::ValueObjectSP value_sp(GetSP(locker));
1381 TargetSP target_sp(value_sp->GetTargetSP());
1383 lldb::addr_t value = LLDB_INVALID_ADDRESS;
1384 const bool scalar_is_load_address = true;
1385 AddressType addr_type;
1386 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
1387 if (addr_type == eAddressTypeFile) {
1388 ModuleSP module_sp(value_sp->GetModule());
1390 module_sp->ResolveFileAddress(value, addr);
1391 } else if (addr_type == eAddressTypeLoad) {
1392 // no need to check the return value on this.. if it can actually do
1393 // the resolve addr will be in the form (section,offset), otherwise it
1394 // will simply be returned as (NULL, value)
1395 addr.SetLoadAddress(value, target_sp.get());
1399 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1401 log->Printf("SBValue(%p)::GetAddress () => (%s,%" PRIu64 ")",
1402 static_cast<void *>(value_sp.get()),
1403 (addr.GetSection() ? addr.GetSection()->GetName().GetCString()
1406 return SBAddress(new Address(addr));
1409 lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) {
1410 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1411 lldb::SBData sb_data;
1413 lldb::ValueObjectSP value_sp(GetSP(locker));
1415 TargetSP target_sp(value_sp->GetTargetSP());
1417 DataExtractorSP data_sp(new DataExtractor());
1418 value_sp->GetPointeeData(*data_sp, item_idx, item_count);
1419 if (data_sp->GetByteSize() > 0)
1424 log->Printf("SBValue(%p)::GetPointeeData (%d, %d) => SBData(%p)",
1425 static_cast<void *>(value_sp.get()), item_idx, item_count,
1426 static_cast<void *>(sb_data.get()));
1431 lldb::SBData SBValue::GetData() {
1432 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1433 lldb::SBData sb_data;
1435 lldb::ValueObjectSP value_sp(GetSP(locker));
1437 DataExtractorSP data_sp(new DataExtractor());
1439 value_sp->GetData(*data_sp, error);
1440 if (error.Success())
1444 log->Printf("SBValue(%p)::GetData () => SBData(%p)",
1445 static_cast<void *>(value_sp.get()),
1446 static_cast<void *>(sb_data.get()));
1451 bool SBValue::SetData(lldb::SBData &data, SBError &error) {
1452 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1454 lldb::ValueObjectSP value_sp(GetSP(locker));
1458 DataExtractor *data_extractor = data.get();
1460 if (!data_extractor) {
1462 log->Printf("SBValue(%p)::SetData() => error: no data to set",
1463 static_cast<void *>(value_sp.get()));
1465 error.SetErrorString("No data to set");
1470 value_sp->SetData(*data_extractor, set_error);
1472 if (!set_error.Success()) {
1473 error.SetErrorStringWithFormat("Couldn't set data: %s",
1474 set_error.AsCString());
1479 error.SetErrorStringWithFormat(
1480 "Couldn't set data: could not get SBValue: %s",
1481 locker.GetError().AsCString());
1486 log->Printf("SBValue(%p)::SetData (%p) => %s",
1487 static_cast<void *>(value_sp.get()),
1488 static_cast<void *>(data.get()), ret ? "true" : "false");
1492 lldb::SBDeclaration SBValue::GetDeclaration() {
1494 lldb::ValueObjectSP value_sp(GetSP(locker));
1495 SBDeclaration decl_sb;
1498 if (value_sp->GetDeclaration(decl))
1499 decl_sb.SetDeclaration(decl);
1504 lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write,
1506 SBWatchpoint sb_watchpoint;
1508 // If the SBValue is not valid, there's no point in even trying to watch it.
1510 lldb::ValueObjectSP value_sp(GetSP(locker));
1511 TargetSP target_sp(GetTarget().GetSP());
1512 if (value_sp && target_sp) {
1513 // Read and Write cannot both be false.
1514 if (!read && !write)
1515 return sb_watchpoint;
1517 // If the value is not in scope, don't try and watch and invalid value
1519 return sb_watchpoint;
1521 addr_t addr = GetLoadAddress();
1522 if (addr == LLDB_INVALID_ADDRESS)
1523 return sb_watchpoint;
1524 size_t byte_size = GetByteSize();
1526 return sb_watchpoint;
1528 uint32_t watch_type = 0;
1530 watch_type |= LLDB_WATCH_TYPE_READ;
1532 watch_type |= LLDB_WATCH_TYPE_WRITE;
1535 CompilerType type(value_sp->GetCompilerType());
1536 WatchpointSP watchpoint_sp =
1537 target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc);
1540 if (watchpoint_sp) {
1541 sb_watchpoint.SetSP(watchpoint_sp);
1543 if (value_sp->GetDeclaration(decl)) {
1544 if (decl.GetFile()) {
1546 // True to show fullpath for declaration file.
1547 decl.DumpStopContext(&ss, true);
1548 watchpoint_sp->SetDeclInfo(ss.GetString());
1552 } else if (target_sp) {
1553 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1555 log->Printf("SBValue(%p)::Watch() => error getting SBValue: %s",
1556 static_cast<void *>(value_sp.get()),
1557 locker.GetError().AsCString());
1559 error.SetErrorStringWithFormat("could not get SBValue: %s",
1560 locker.GetError().AsCString());
1562 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1564 log->Printf("SBValue(%p)::Watch() => error getting SBValue: no target",
1565 static_cast<void *>(value_sp.get()));
1566 error.SetErrorString("could not set watchpoint, a target is required");
1569 return sb_watchpoint;
1572 // FIXME: Remove this method impl (as well as the decl in .h) once it is no
1574 // Backward compatibility fix in the interim.
1575 lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read,
1578 return Watch(resolve_location, read, write, error);
1581 lldb::SBWatchpoint SBValue::WatchPointee(bool resolve_location, bool read,
1582 bool write, SBError &error) {
1583 SBWatchpoint sb_watchpoint;
1584 if (IsInScope() && GetType().IsPointerType())
1585 sb_watchpoint = Dereference().Watch(resolve_location, read, write, error);
1586 return sb_watchpoint;
1589 lldb::SBValue SBValue::Persist() {
1591 lldb::ValueObjectSP value_sp(GetSP(locker));
1592 SBValue persisted_sb;
1594 persisted_sb.SetSP(value_sp->Persist());
1596 return persisted_sb;