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/Scalar.h"
22 #include "lldb/Core/Section.h"
23 #include "lldb/Core/StreamFile.h"
24 #include "lldb/Core/Value.h"
25 #include "lldb/Core/ValueObject.h"
26 #include "lldb/Core/ValueObjectConstResult.h"
27 #include "lldb/DataFormatters/DataVisualization.h"
28 #include "lldb/Symbol/Block.h"
29 #include "lldb/Symbol/Declaration.h"
30 #include "lldb/Symbol/ObjectFile.h"
31 #include "lldb/Symbol/Type.h"
32 #include "lldb/Symbol/Variable.h"
33 #include "lldb/Symbol/VariableList.h"
34 #include "lldb/Target/ExecutionContext.h"
35 #include "lldb/Target/Process.h"
36 #include "lldb/Target/StackFrame.h"
37 #include "lldb/Target/Target.h"
38 #include "lldb/Target/Thread.h"
39 #include "lldb/Utility/DataExtractor.h"
40 #include "lldb/Utility/Log.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 if (target_sp && target_sp->IsValid())
108 lldb::ValueObjectSP GetRootSP() { return m_valobj_sp; }
110 lldb::ValueObjectSP GetSP(Process::StopLocker &stop_locker,
111 std::unique_lock<std::recursive_mutex> &lock,
113 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
115 error.SetErrorString("invalid value object");
119 lldb::ValueObjectSP value_sp = m_valobj_sp;
121 Target *target = value_sp->GetTargetSP().get();
123 return ValueObjectSP();
125 lock = std::unique_lock<std::recursive_mutex>(target->GetAPIMutex());
127 ProcessSP process_sp(value_sp->GetProcessSP());
128 if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock())) {
129 // We don't allow people to play around with ValueObject if the process
130 // is running. If you want to look at values, pause the process, then
133 log->Printf("SBValue(%p)::GetSP() => error: process is running",
134 static_cast<void *>(value_sp.get()));
135 error.SetErrorString("process must be stopped.");
136 return ValueObjectSP();
139 if (m_use_dynamic != eNoDynamicValues) {
140 ValueObjectSP dynamic_sp = value_sp->GetDynamicValue(m_use_dynamic);
142 value_sp = dynamic_sp;
145 if (m_use_synthetic) {
146 ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue(m_use_synthetic);
148 value_sp = synthetic_sp;
152 error.SetErrorString("invalid value object");
153 if (!m_name.IsEmpty())
154 value_sp->SetName(m_name);
159 void SetUseDynamic(lldb::DynamicValueType use_dynamic) {
160 m_use_dynamic = use_dynamic;
163 void SetUseSynthetic(bool use_synthetic) { m_use_synthetic = use_synthetic; }
165 lldb::DynamicValueType GetUseDynamic() { return m_use_dynamic; }
167 bool GetUseSynthetic() { return m_use_synthetic; }
169 // All the derived values that we would make from the m_valobj_sp will share
170 // the ExecutionContext with m_valobj_sp, so we don't need to do the
171 // calculations in GetSP to return the Target, Process, Thread or Frame. It
172 // is convenient to provide simple accessors for these, which I do here.
173 TargetSP GetTargetSP() {
175 return m_valobj_sp->GetTargetSP();
180 ProcessSP GetProcessSP() {
182 return m_valobj_sp->GetProcessSP();
187 ThreadSP GetThreadSP() {
189 return m_valobj_sp->GetThreadSP();
194 StackFrameSP GetFrameSP() {
196 return m_valobj_sp->GetFrameSP();
198 return StackFrameSP();
202 lldb::ValueObjectSP m_valobj_sp;
203 lldb::DynamicValueType m_use_dynamic;
204 bool m_use_synthetic;
212 ValueObjectSP GetLockedSP(ValueImpl &in_value) {
213 return in_value.GetSP(m_stop_locker, m_lock, m_lock_error);
216 Status &GetError() { return m_lock_error; }
219 Process::StopLocker m_stop_locker;
220 std::unique_lock<std::recursive_mutex> m_lock;
224 SBValue::SBValue() : m_opaque_sp() {}
226 SBValue::SBValue(const lldb::ValueObjectSP &value_sp) { SetSP(value_sp); }
228 SBValue::SBValue(const SBValue &rhs) { SetSP(rhs.m_opaque_sp); }
230 SBValue &SBValue::operator=(const SBValue &rhs) {
232 SetSP(rhs.m_opaque_sp);
237 SBValue::~SBValue() {}
239 bool SBValue::IsValid() {
240 // If this function ever changes to anything that does more than just check
241 // if the opaque shared pointer is non NULL, then we need to update all "if
242 // (m_opaque_sp)" code in this file.
243 return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid() &&
244 m_opaque_sp->GetRootSP().get() != NULL;
247 void SBValue::Clear() { m_opaque_sp.reset(); }
249 SBError SBValue::GetError() {
253 lldb::ValueObjectSP value_sp(GetSP(locker));
255 sb_error.SetError(value_sp->GetError());
257 sb_error.SetErrorStringWithFormat("error: %s",
258 locker.GetError().AsCString());
263 user_id_t SBValue::GetID() {
265 lldb::ValueObjectSP value_sp(GetSP(locker));
267 return value_sp->GetID();
268 return LLDB_INVALID_UID;
271 const char *SBValue::GetName() {
272 const char *name = NULL;
274 lldb::ValueObjectSP value_sp(GetSP(locker));
276 name = value_sp->GetName().GetCString();
278 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
281 log->Printf("SBValue(%p)::GetName () => \"%s\"",
282 static_cast<void *>(value_sp.get()), name);
284 log->Printf("SBValue(%p)::GetName () => NULL",
285 static_cast<void *>(value_sp.get()));
291 const char *SBValue::GetTypeName() {
292 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
293 const char *name = NULL;
295 lldb::ValueObjectSP value_sp(GetSP(locker));
297 name = value_sp->GetQualifiedTypeName().GetCString();
302 log->Printf("SBValue(%p)::GetTypeName () => \"%s\"",
303 static_cast<void *>(value_sp.get()), name);
305 log->Printf("SBValue(%p)::GetTypeName () => NULL",
306 static_cast<void *>(value_sp.get()));
312 const char *SBValue::GetDisplayTypeName() {
313 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
314 const char *name = NULL;
316 lldb::ValueObjectSP value_sp(GetSP(locker));
318 name = value_sp->GetDisplayTypeName().GetCString();
323 log->Printf("SBValue(%p)::GetTypeName () => \"%s\"",
324 static_cast<void *>(value_sp.get()), name);
326 log->Printf("SBValue(%p)::GetTypeName () => NULL",
327 static_cast<void *>(value_sp.get()));
333 size_t SBValue::GetByteSize() {
334 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
338 lldb::ValueObjectSP value_sp(GetSP(locker));
340 result = value_sp->GetByteSize();
344 log->Printf("SBValue(%p)::GetByteSize () => %" PRIu64,
345 static_cast<void *>(value_sp.get()),
346 static_cast<uint64_t>(result));
351 bool SBValue::IsInScope() {
355 lldb::ValueObjectSP value_sp(GetSP(locker));
357 result = value_sp->IsInScope();
360 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
362 log->Printf("SBValue(%p)::IsInScope () => %i",
363 static_cast<void *>(value_sp.get()), result);
368 const char *SBValue::GetValue() {
369 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
371 const char *cstr = NULL;
373 lldb::ValueObjectSP value_sp(GetSP(locker));
375 cstr = value_sp->GetValueAsCString();
379 log->Printf("SBValue(%p)::GetValue() => \"%s\"",
380 static_cast<void *>(value_sp.get()), cstr);
382 log->Printf("SBValue(%p)::GetValue() => NULL",
383 static_cast<void *>(value_sp.get()));
389 ValueType SBValue::GetValueType() {
390 ValueType result = eValueTypeInvalid;
392 lldb::ValueObjectSP value_sp(GetSP(locker));
394 result = value_sp->GetValueType();
396 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
399 case eValueTypeInvalid:
400 log->Printf("SBValue(%p)::GetValueType () => eValueTypeInvalid",
401 static_cast<void *>(value_sp.get()));
403 case eValueTypeVariableGlobal:
404 log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal",
405 static_cast<void *>(value_sp.get()));
407 case eValueTypeVariableStatic:
408 log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableStatic",
409 static_cast<void *>(value_sp.get()));
411 case eValueTypeVariableArgument:
412 log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableArgument",
413 static_cast<void *>(value_sp.get()));
415 case eValueTypeVariableLocal:
416 log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableLocal",
417 static_cast<void *>(value_sp.get()));
419 case eValueTypeRegister:
420 log->Printf("SBValue(%p)::GetValueType () => eValueTypeRegister",
421 static_cast<void *>(value_sp.get()));
423 case eValueTypeRegisterSet:
424 log->Printf("SBValue(%p)::GetValueType () => eValueTypeRegisterSet",
425 static_cast<void *>(value_sp.get()));
427 case eValueTypeConstResult:
428 log->Printf("SBValue(%p)::GetValueType () => eValueTypeConstResult",
429 static_cast<void *>(value_sp.get()));
431 case eValueTypeVariableThreadLocal:
433 "SBValue(%p)::GetValueType () => eValueTypeVariableThreadLocal",
434 static_cast<void *>(value_sp.get()));
441 const char *SBValue::GetObjectDescription() {
442 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
443 const char *cstr = NULL;
445 lldb::ValueObjectSP value_sp(GetSP(locker));
447 cstr = value_sp->GetObjectDescription();
451 log->Printf("SBValue(%p)::GetObjectDescription() => \"%s\"",
452 static_cast<void *>(value_sp.get()), cstr);
454 log->Printf("SBValue(%p)::GetObjectDescription() => NULL",
455 static_cast<void *>(value_sp.get()));
460 const char *SBValue::GetTypeValidatorResult() {
461 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
462 const char *cstr = NULL;
464 lldb::ValueObjectSP value_sp(GetSP(locker));
466 const auto &validation(value_sp->GetValidationStatus());
467 if (TypeValidatorResult::Failure == validation.first) {
468 if (validation.second.empty())
469 cstr = "unknown error";
471 cstr = validation.second.c_str();
476 log->Printf("SBValue(%p)::GetTypeValidatorResult() => \"%s\"",
477 static_cast<void *>(value_sp.get()), cstr);
479 log->Printf("SBValue(%p)::GetTypeValidatorResult() => NULL",
480 static_cast<void *>(value_sp.get()));
485 SBType SBValue::GetType() {
486 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
489 lldb::ValueObjectSP value_sp(GetSP(locker));
492 type_sp.reset(new TypeImpl(value_sp->GetTypeImpl()));
493 sb_type.SetSP(type_sp);
497 log->Printf("SBValue(%p)::GetType => SBType(%p)",
498 static_cast<void *>(value_sp.get()),
499 static_cast<void *>(type_sp.get()));
501 log->Printf("SBValue(%p)::GetType => NULL",
502 static_cast<void *>(value_sp.get()));
507 bool SBValue::GetValueDidChange() {
508 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
511 lldb::ValueObjectSP value_sp(GetSP(locker));
513 if (value_sp->UpdateValueIfNeeded(false))
514 result = value_sp->GetValueDidChange();
517 log->Printf("SBValue(%p)::GetValueDidChange() => %i",
518 static_cast<void *>(value_sp.get()), result);
523 const char *SBValue::GetSummary() {
524 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
525 const char *cstr = NULL;
527 lldb::ValueObjectSP value_sp(GetSP(locker));
529 cstr = value_sp->GetSummaryAsCString();
533 log->Printf("SBValue(%p)::GetSummary() => \"%s\"",
534 static_cast<void *>(value_sp.get()), cstr);
536 log->Printf("SBValue(%p)::GetSummary() => NULL",
537 static_cast<void *>(value_sp.get()));
542 const char *SBValue::GetSummary(lldb::SBStream &stream,
543 lldb::SBTypeSummaryOptions &options) {
544 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
546 lldb::ValueObjectSP value_sp(GetSP(locker));
549 if (value_sp->GetSummaryAsCString(buffer, options.ref()) && !buffer.empty())
550 stream.Printf("%s", buffer.c_str());
552 const char *cstr = stream.GetData();
555 log->Printf("SBValue(%p)::GetSummary() => \"%s\"",
556 static_cast<void *>(value_sp.get()), cstr);
558 log->Printf("SBValue(%p)::GetSummary() => NULL",
559 static_cast<void *>(value_sp.get()));
564 const char *SBValue::GetLocation() {
565 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
566 const char *cstr = NULL;
568 lldb::ValueObjectSP value_sp(GetSP(locker));
570 cstr = value_sp->GetLocationAsCString();
574 log->Printf("SBValue(%p)::GetLocation() => \"%s\"",
575 static_cast<void *>(value_sp.get()), cstr);
577 log->Printf("SBValue(%p)::GetLocation() => NULL",
578 static_cast<void *>(value_sp.get()));
583 // Deprecated - use the one that takes an lldb::SBError
584 bool SBValue::SetValueFromCString(const char *value_str) {
586 return SetValueFromCString(value_str, dummy);
589 bool SBValue::SetValueFromCString(const char *value_str, lldb::SBError &error) {
590 bool success = false;
592 lldb::ValueObjectSP value_sp(GetSP(locker));
593 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
595 success = value_sp->SetValueFromCString(value_str, error.ref());
597 error.SetErrorStringWithFormat("Could not get value: %s",
598 locker.GetError().AsCString());
601 log->Printf("SBValue(%p)::SetValueFromCString(\"%s\") => %i",
602 static_cast<void *>(value_sp.get()), value_str, success);
607 lldb::SBTypeFormat SBValue::GetTypeFormat() {
608 lldb::SBTypeFormat format;
610 lldb::ValueObjectSP value_sp(GetSP(locker));
612 if (value_sp->UpdateValueIfNeeded(true)) {
613 lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
615 format.SetSP(format_sp);
621 lldb::SBTypeSummary SBValue::GetTypeSummary() {
622 lldb::SBTypeSummary summary;
624 lldb::ValueObjectSP value_sp(GetSP(locker));
626 if (value_sp->UpdateValueIfNeeded(true)) {
627 lldb::TypeSummaryImplSP summary_sp = value_sp->GetSummaryFormat();
629 summary.SetSP(summary_sp);
635 lldb::SBTypeFilter SBValue::GetTypeFilter() {
636 lldb::SBTypeFilter filter;
638 lldb::ValueObjectSP value_sp(GetSP(locker));
640 if (value_sp->UpdateValueIfNeeded(true)) {
641 lldb::SyntheticChildrenSP synthetic_sp = value_sp->GetSyntheticChildren();
643 if (synthetic_sp && !synthetic_sp->IsScripted()) {
644 TypeFilterImplSP filter_sp =
645 std::static_pointer_cast<TypeFilterImpl>(synthetic_sp);
646 filter.SetSP(filter_sp);
653 #ifndef LLDB_DISABLE_PYTHON
654 lldb::SBTypeSynthetic SBValue::GetTypeSynthetic() {
655 lldb::SBTypeSynthetic synthetic;
657 lldb::ValueObjectSP value_sp(GetSP(locker));
659 if (value_sp->UpdateValueIfNeeded(true)) {
660 lldb::SyntheticChildrenSP children_sp = value_sp->GetSyntheticChildren();
662 if (children_sp && children_sp->IsScripted()) {
663 ScriptedSyntheticChildrenSP synth_sp =
664 std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
665 synthetic.SetSP(synth_sp);
673 lldb::SBValue SBValue::CreateChildAtOffset(const char *name, uint32_t offset,
675 lldb::SBValue sb_value;
677 lldb::ValueObjectSP value_sp(GetSP(locker));
678 lldb::ValueObjectSP new_value_sp;
680 TypeImplSP type_sp(type.GetSP());
681 if (type.IsValid()) {
682 sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(
683 offset, type_sp->GetCompilerType(false), true),
684 GetPreferDynamicValue(), GetPreferSyntheticValue(), name);
687 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
690 log->Printf("SBValue(%p)::CreateChildAtOffset => \"%s\"",
691 static_cast<void *>(value_sp.get()),
692 new_value_sp->GetName().AsCString());
694 log->Printf("SBValue(%p)::CreateChildAtOffset => NULL",
695 static_cast<void *>(value_sp.get()));
700 lldb::SBValue SBValue::Cast(SBType type) {
701 lldb::SBValue sb_value;
703 lldb::ValueObjectSP value_sp(GetSP(locker));
704 TypeImplSP type_sp(type.GetSP());
705 if (value_sp && type_sp)
706 sb_value.SetSP(value_sp->Cast(type_sp->GetCompilerType(false)),
707 GetPreferDynamicValue(), GetPreferSyntheticValue());
711 lldb::SBValue SBValue::CreateValueFromExpression(const char *name,
712 const char *expression) {
713 SBExpressionOptions options;
714 options.ref().SetKeepInMemory(true);
715 return CreateValueFromExpression(name, expression, options);
718 lldb::SBValue SBValue::CreateValueFromExpression(const char *name,
719 const char *expression,
720 SBExpressionOptions &options) {
721 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
722 lldb::SBValue sb_value;
724 lldb::ValueObjectSP value_sp(GetSP(locker));
725 lldb::ValueObjectSP new_value_sp;
727 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
728 new_value_sp = ValueObject::CreateValueObjectFromExpression(
729 name, expression, exe_ctx, options.ref());
731 new_value_sp->SetName(ConstString(name));
733 sb_value.SetSP(new_value_sp);
736 log->Printf("SBValue(%p)::CreateValueFromExpression(name=\"%s\", "
737 "expression=\"%s\") => SBValue (%p)",
738 static_cast<void *>(value_sp.get()), name, expression,
739 static_cast<void *>(new_value_sp.get()));
741 log->Printf("SBValue(%p)::CreateValueFromExpression(name=\"%s\", "
742 "expression=\"%s\") => NULL",
743 static_cast<void *>(value_sp.get()), name, expression);
748 lldb::SBValue SBValue::CreateValueFromAddress(const char *name,
749 lldb::addr_t address,
751 lldb::SBValue sb_value;
753 lldb::ValueObjectSP value_sp(GetSP(locker));
754 lldb::ValueObjectSP new_value_sp;
755 lldb::TypeImplSP type_impl_sp(sb_type.GetSP());
756 if (value_sp && type_impl_sp) {
757 CompilerType ast_type(type_impl_sp->GetCompilerType(true));
758 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
759 new_value_sp = ValueObject::CreateValueObjectFromAddress(name, address,
762 sb_value.SetSP(new_value_sp);
763 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
766 log->Printf("SBValue(%p)::CreateValueFromAddress => \"%s\"",
767 static_cast<void *>(value_sp.get()),
768 new_value_sp->GetName().AsCString());
770 log->Printf("SBValue(%p)::CreateValueFromAddress => NULL",
771 static_cast<void *>(value_sp.get()));
776 lldb::SBValue SBValue::CreateValueFromData(const char *name, SBData data,
778 lldb::SBValue sb_value;
779 lldb::ValueObjectSP new_value_sp;
781 lldb::ValueObjectSP value_sp(GetSP(locker));
782 lldb::TypeImplSP type_impl_sp(sb_type.GetSP());
783 if (value_sp && type_impl_sp) {
784 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
785 new_value_sp = ValueObject::CreateValueObjectFromData(
786 name, **data, exe_ctx, type_impl_sp->GetCompilerType(true));
787 new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
789 sb_value.SetSP(new_value_sp);
790 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
793 log->Printf("SBValue(%p)::CreateValueFromData => \"%s\"",
794 static_cast<void *>(value_sp.get()),
795 new_value_sp->GetName().AsCString());
797 log->Printf("SBValue(%p)::CreateValueFromData => NULL",
798 static_cast<void *>(value_sp.get()));
803 SBValue SBValue::GetChildAtIndex(uint32_t idx) {
804 const bool can_create_synthetic = false;
805 lldb::DynamicValueType use_dynamic = eNoDynamicValues;
808 target_sp = m_opaque_sp->GetTargetSP();
811 use_dynamic = target_sp->GetPreferDynamicValue();
813 return GetChildAtIndex(idx, use_dynamic, can_create_synthetic);
816 SBValue SBValue::GetChildAtIndex(uint32_t idx,
817 lldb::DynamicValueType use_dynamic,
818 bool can_create_synthetic) {
819 lldb::ValueObjectSP child_sp;
820 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
823 lldb::ValueObjectSP value_sp(GetSP(locker));
825 const bool can_create = true;
826 child_sp = value_sp->GetChildAtIndex(idx, can_create);
827 if (can_create_synthetic && !child_sp) {
828 child_sp = value_sp->GetSyntheticArrayMember(idx, can_create);
833 sb_value.SetSP(child_sp, use_dynamic, GetPreferSyntheticValue());
835 log->Printf("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)",
836 static_cast<void *>(value_sp.get()), idx,
837 static_cast<void *>(value_sp.get()));
842 uint32_t SBValue::GetIndexOfChildWithName(const char *name) {
843 uint32_t idx = UINT32_MAX;
845 lldb::ValueObjectSP value_sp(GetSP(locker));
847 idx = value_sp->GetIndexOfChildWithName(ConstString(name));
849 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
851 if (idx == UINT32_MAX)
853 "SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND",
854 static_cast<void *>(value_sp.get()), name);
856 log->Printf("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u",
857 static_cast<void *>(value_sp.get()), name, idx);
862 SBValue SBValue::GetChildMemberWithName(const char *name) {
863 lldb::DynamicValueType use_dynamic_value = eNoDynamicValues;
866 target_sp = m_opaque_sp->GetTargetSP();
869 use_dynamic_value = target_sp->GetPreferDynamicValue();
870 return GetChildMemberWithName(name, use_dynamic_value);
874 SBValue::GetChildMemberWithName(const char *name,
875 lldb::DynamicValueType use_dynamic_value) {
876 lldb::ValueObjectSP child_sp;
877 const ConstString str_name(name);
879 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
882 lldb::ValueObjectSP value_sp(GetSP(locker));
884 child_sp = value_sp->GetChildMemberWithName(str_name, true);
888 sb_value.SetSP(child_sp, use_dynamic_value, GetPreferSyntheticValue());
892 "SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)",
893 static_cast<void *>(value_sp.get()), name,
894 static_cast<void *>(value_sp.get()));
899 lldb::SBValue SBValue::GetDynamicValue(lldb::DynamicValueType use_dynamic) {
902 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), use_dynamic,
903 m_opaque_sp->GetUseSynthetic()));
904 value_sb.SetSP(proxy_sp);
909 lldb::SBValue SBValue::GetStaticValue() {
912 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
914 m_opaque_sp->GetUseSynthetic()));
915 value_sb.SetSP(proxy_sp);
920 lldb::SBValue SBValue::GetNonSyntheticValue() {
923 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
924 m_opaque_sp->GetUseDynamic(), false));
925 value_sb.SetSP(proxy_sp);
930 lldb::DynamicValueType SBValue::GetPreferDynamicValue() {
932 return eNoDynamicValues;
933 return m_opaque_sp->GetUseDynamic();
936 void SBValue::SetPreferDynamicValue(lldb::DynamicValueType use_dynamic) {
938 return m_opaque_sp->SetUseDynamic(use_dynamic);
941 bool SBValue::GetPreferSyntheticValue() {
944 return m_opaque_sp->GetUseSynthetic();
947 void SBValue::SetPreferSyntheticValue(bool use_synthetic) {
949 return m_opaque_sp->SetUseSynthetic(use_synthetic);
952 bool SBValue::IsDynamic() {
954 lldb::ValueObjectSP value_sp(GetSP(locker));
956 return value_sp->IsDynamic();
960 bool SBValue::IsSynthetic() {
962 lldb::ValueObjectSP value_sp(GetSP(locker));
964 return value_sp->IsSynthetic();
968 bool SBValue::IsSyntheticChildrenGenerated() {
970 lldb::ValueObjectSP value_sp(GetSP(locker));
972 return value_sp->IsSyntheticChildrenGenerated();
976 void SBValue::SetSyntheticChildrenGenerated(bool is) {
978 lldb::ValueObjectSP value_sp(GetSP(locker));
980 return value_sp->SetSyntheticChildrenGenerated(is);
983 lldb::SBValue SBValue::GetValueForExpressionPath(const char *expr_path) {
984 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
985 lldb::ValueObjectSP child_sp;
987 lldb::ValueObjectSP value_sp(GetSP(locker));
989 // using default values for all the fancy options, just do it if you can
990 child_sp = value_sp->GetValueForExpressionPath(expr_path);
994 sb_value.SetSP(child_sp, GetPreferDynamicValue(), GetPreferSyntheticValue());
997 log->Printf("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => "
999 static_cast<void *>(value_sp.get()), expr_path,
1000 static_cast<void *>(value_sp.get()));
1005 int64_t SBValue::GetValueAsSigned(SBError &error, int64_t fail_value) {
1008 lldb::ValueObjectSP value_sp(GetSP(locker));
1010 bool success = true;
1011 uint64_t ret_val = fail_value;
1012 ret_val = value_sp->GetValueAsSigned(fail_value, &success);
1014 error.SetErrorString("could not resolve value");
1017 error.SetErrorStringWithFormat("could not get SBValue: %s",
1018 locker.GetError().AsCString());
1023 uint64_t SBValue::GetValueAsUnsigned(SBError &error, uint64_t fail_value) {
1026 lldb::ValueObjectSP value_sp(GetSP(locker));
1028 bool success = true;
1029 uint64_t ret_val = fail_value;
1030 ret_val = value_sp->GetValueAsUnsigned(fail_value, &success);
1032 error.SetErrorString("could not resolve value");
1035 error.SetErrorStringWithFormat("could not get SBValue: %s",
1036 locker.GetError().AsCString());
1041 int64_t SBValue::GetValueAsSigned(int64_t fail_value) {
1043 lldb::ValueObjectSP value_sp(GetSP(locker));
1045 return value_sp->GetValueAsSigned(fail_value);
1050 uint64_t SBValue::GetValueAsUnsigned(uint64_t fail_value) {
1052 lldb::ValueObjectSP value_sp(GetSP(locker));
1054 return value_sp->GetValueAsUnsigned(fail_value);
1059 bool SBValue::MightHaveChildren() {
1060 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1061 bool has_children = false;
1063 lldb::ValueObjectSP value_sp(GetSP(locker));
1065 has_children = value_sp->MightHaveChildren();
1068 log->Printf("SBValue(%p)::MightHaveChildren() => %i",
1069 static_cast<void *>(value_sp.get()), has_children);
1070 return has_children;
1073 bool SBValue::IsRuntimeSupportValue() {
1074 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1075 bool is_support = false;
1077 lldb::ValueObjectSP value_sp(GetSP(locker));
1079 is_support = value_sp->IsRuntimeSupportValue();
1082 log->Printf("SBValue(%p)::IsRuntimeSupportValue() => %i",
1083 static_cast<void *>(value_sp.get()), is_support);
1087 uint32_t SBValue::GetNumChildren() { return GetNumChildren(UINT32_MAX); }
1089 uint32_t SBValue::GetNumChildren(uint32_t max) {
1090 uint32_t num_children = 0;
1092 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1094 lldb::ValueObjectSP value_sp(GetSP(locker));
1096 num_children = value_sp->GetNumChildren(max);
1099 log->Printf("SBValue(%p)::GetNumChildren (%u) => %u",
1100 static_cast<void *>(value_sp.get()), max, num_children);
1102 return num_children;
1105 SBValue SBValue::Dereference() {
1108 lldb::ValueObjectSP value_sp(GetSP(locker));
1111 sb_value = value_sp->Dereference(error);
1113 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1115 log->Printf("SBValue(%p)::Dereference () => SBValue(%p)",
1116 static_cast<void *>(value_sp.get()),
1117 static_cast<void *>(value_sp.get()));
1122 // Deprecated - please use GetType().IsPointerType() instead.
1123 bool SBValue::TypeIsPointerType() { return GetType().IsPointerType(); }
1125 void *SBValue::GetOpaqueType() {
1127 lldb::ValueObjectSP value_sp(GetSP(locker));
1129 return value_sp->GetCompilerType().GetOpaqueQualType();
1133 lldb::SBTarget SBValue::GetTarget() {
1137 target_sp = m_opaque_sp->GetTargetSP();
1138 sb_target.SetSP(target_sp);
1140 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1142 if (target_sp.get() == NULL)
1143 log->Printf("SBValue(%p)::GetTarget () => NULL",
1144 static_cast<void *>(m_opaque_sp.get()));
1146 log->Printf("SBValue(%p)::GetTarget () => %p",
1147 static_cast<void *>(m_opaque_sp.get()),
1148 static_cast<void *>(target_sp.get()));
1153 lldb::SBProcess SBValue::GetProcess() {
1154 SBProcess sb_process;
1155 ProcessSP process_sp;
1157 process_sp = m_opaque_sp->GetProcessSP();
1158 sb_process.SetSP(process_sp);
1160 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1162 if (process_sp.get() == NULL)
1163 log->Printf("SBValue(%p)::GetProcess () => NULL",
1164 static_cast<void *>(m_opaque_sp.get()));
1166 log->Printf("SBValue(%p)::GetProcess () => %p",
1167 static_cast<void *>(m_opaque_sp.get()),
1168 static_cast<void *>(process_sp.get()));
1173 lldb::SBThread SBValue::GetThread() {
1177 thread_sp = m_opaque_sp->GetThreadSP();
1178 sb_thread.SetThread(thread_sp);
1180 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1182 if (thread_sp.get() == NULL)
1183 log->Printf("SBValue(%p)::GetThread () => NULL",
1184 static_cast<void *>(m_opaque_sp.get()));
1186 log->Printf("SBValue(%p)::GetThread () => %p",
1187 static_cast<void *>(m_opaque_sp.get()),
1188 static_cast<void *>(thread_sp.get()));
1193 lldb::SBFrame SBValue::GetFrame() {
1195 StackFrameSP frame_sp;
1197 frame_sp = m_opaque_sp->GetFrameSP();
1198 sb_frame.SetFrameSP(frame_sp);
1200 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1202 if (frame_sp.get() == NULL)
1203 log->Printf("SBValue(%p)::GetFrame () => NULL",
1204 static_cast<void *>(m_opaque_sp.get()));
1206 log->Printf("SBValue(%p)::GetFrame () => %p",
1207 static_cast<void *>(m_opaque_sp.get()),
1208 static_cast<void *>(frame_sp.get()));
1213 lldb::ValueObjectSP SBValue::GetSP(ValueLocker &locker) const {
1214 if (!m_opaque_sp || !m_opaque_sp->IsValid()) {
1215 locker.GetError().SetErrorString("No value");
1216 return ValueObjectSP();
1218 return locker.GetLockedSP(*m_opaque_sp.get());
1221 lldb::ValueObjectSP SBValue::GetSP() const {
1223 return GetSP(locker);
1226 void SBValue::SetSP(ValueImplSP impl_sp) { m_opaque_sp = impl_sp; }
1228 void SBValue::SetSP(const lldb::ValueObjectSP &sp) {
1230 lldb::TargetSP target_sp(sp->GetTargetSP());
1232 lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1233 bool use_synthetic =
1234 target_sp->TargetProperties::GetEnableSyntheticValue();
1235 m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
1237 m_opaque_sp = ValueImplSP(new ValueImpl(sp, eNoDynamicValues, true));
1239 m_opaque_sp = ValueImplSP(new ValueImpl(sp, eNoDynamicValues, false));
1242 void SBValue::SetSP(const lldb::ValueObjectSP &sp,
1243 lldb::DynamicValueType use_dynamic) {
1245 lldb::TargetSP target_sp(sp->GetTargetSP());
1247 bool use_synthetic =
1248 target_sp->TargetProperties::GetEnableSyntheticValue();
1249 SetSP(sp, use_dynamic, use_synthetic);
1251 SetSP(sp, use_dynamic, true);
1253 SetSP(sp, use_dynamic, false);
1256 void SBValue::SetSP(const lldb::ValueObjectSP &sp, bool use_synthetic) {
1258 lldb::TargetSP target_sp(sp->GetTargetSP());
1260 lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1261 SetSP(sp, use_dynamic, use_synthetic);
1263 SetSP(sp, eNoDynamicValues, use_synthetic);
1265 SetSP(sp, eNoDynamicValues, use_synthetic);
1268 void SBValue::SetSP(const lldb::ValueObjectSP &sp,
1269 lldb::DynamicValueType use_dynamic, bool use_synthetic) {
1270 m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
1273 void SBValue::SetSP(const lldb::ValueObjectSP &sp,
1274 lldb::DynamicValueType use_dynamic, bool use_synthetic,
1277 ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic, name));
1280 bool SBValue::GetExpressionPath(SBStream &description) {
1282 lldb::ValueObjectSP value_sp(GetSP(locker));
1284 value_sp->GetExpressionPath(description.ref(), false);
1290 bool SBValue::GetExpressionPath(SBStream &description,
1291 bool qualify_cxx_base_classes) {
1293 lldb::ValueObjectSP value_sp(GetSP(locker));
1295 value_sp->GetExpressionPath(description.ref(), qualify_cxx_base_classes);
1301 bool SBValue::GetDescription(SBStream &description) {
1302 Stream &strm = description.ref();
1305 lldb::ValueObjectSP value_sp(GetSP(locker));
1307 value_sp->Dump(strm);
1309 strm.PutCString("No value");
1314 lldb::Format SBValue::GetFormat() {
1316 lldb::ValueObjectSP value_sp(GetSP(locker));
1318 return value_sp->GetFormat();
1319 return eFormatDefault;
1322 void SBValue::SetFormat(lldb::Format format) {
1324 lldb::ValueObjectSP value_sp(GetSP(locker));
1326 value_sp->SetFormat(format);
1329 lldb::SBValue SBValue::AddressOf() {
1332 lldb::ValueObjectSP value_sp(GetSP(locker));
1335 sb_value.SetSP(value_sp->AddressOf(error), GetPreferDynamicValue(),
1336 GetPreferSyntheticValue());
1338 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1340 log->Printf("SBValue(%p)::AddressOf () => SBValue(%p)",
1341 static_cast<void *>(value_sp.get()),
1342 static_cast<void *>(value_sp.get()));
1347 lldb::addr_t SBValue::GetLoadAddress() {
1348 lldb::addr_t value = LLDB_INVALID_ADDRESS;
1350 lldb::ValueObjectSP value_sp(GetSP(locker));
1352 TargetSP target_sp(value_sp->GetTargetSP());
1354 const bool scalar_is_load_address = true;
1355 AddressType addr_type;
1356 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
1357 if (addr_type == eAddressTypeFile) {
1358 ModuleSP module_sp(value_sp->GetModule());
1360 value = LLDB_INVALID_ADDRESS;
1363 module_sp->ResolveFileAddress(value, addr);
1364 value = addr.GetLoadAddress(target_sp.get());
1366 } else if (addr_type == eAddressTypeHost ||
1367 addr_type == eAddressTypeInvalid)
1368 value = LLDB_INVALID_ADDRESS;
1371 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1373 log->Printf("SBValue(%p)::GetLoadAddress () => (%" PRIu64 ")",
1374 static_cast<void *>(value_sp.get()), value);
1379 lldb::SBAddress SBValue::GetAddress() {
1382 lldb::ValueObjectSP value_sp(GetSP(locker));
1384 TargetSP target_sp(value_sp->GetTargetSP());
1386 lldb::addr_t value = LLDB_INVALID_ADDRESS;
1387 const bool scalar_is_load_address = true;
1388 AddressType addr_type;
1389 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
1390 if (addr_type == eAddressTypeFile) {
1391 ModuleSP module_sp(value_sp->GetModule());
1393 module_sp->ResolveFileAddress(value, addr);
1394 } else if (addr_type == eAddressTypeLoad) {
1395 // no need to check the return value on this.. if it can actually do
1396 // the resolve addr will be in the form (section,offset), otherwise it
1397 // will simply be returned as (NULL, value)
1398 addr.SetLoadAddress(value, target_sp.get());
1402 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1404 log->Printf("SBValue(%p)::GetAddress () => (%s,%" PRIu64 ")",
1405 static_cast<void *>(value_sp.get()),
1406 (addr.GetSection() ? addr.GetSection()->GetName().GetCString()
1409 return SBAddress(new Address(addr));
1412 lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) {
1413 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1414 lldb::SBData sb_data;
1416 lldb::ValueObjectSP value_sp(GetSP(locker));
1418 TargetSP target_sp(value_sp->GetTargetSP());
1420 DataExtractorSP data_sp(new DataExtractor());
1421 value_sp->GetPointeeData(*data_sp, item_idx, item_count);
1422 if (data_sp->GetByteSize() > 0)
1427 log->Printf("SBValue(%p)::GetPointeeData (%d, %d) => SBData(%p)",
1428 static_cast<void *>(value_sp.get()), item_idx, item_count,
1429 static_cast<void *>(sb_data.get()));
1434 lldb::SBData SBValue::GetData() {
1435 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1436 lldb::SBData sb_data;
1438 lldb::ValueObjectSP value_sp(GetSP(locker));
1440 DataExtractorSP data_sp(new DataExtractor());
1442 value_sp->GetData(*data_sp, error);
1443 if (error.Success())
1447 log->Printf("SBValue(%p)::GetData () => SBData(%p)",
1448 static_cast<void *>(value_sp.get()),
1449 static_cast<void *>(sb_data.get()));
1454 bool SBValue::SetData(lldb::SBData &data, SBError &error) {
1455 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1457 lldb::ValueObjectSP value_sp(GetSP(locker));
1461 DataExtractor *data_extractor = data.get();
1463 if (!data_extractor) {
1465 log->Printf("SBValue(%p)::SetData() => error: no data to set",
1466 static_cast<void *>(value_sp.get()));
1468 error.SetErrorString("No data to set");
1473 value_sp->SetData(*data_extractor, set_error);
1475 if (!set_error.Success()) {
1476 error.SetErrorStringWithFormat("Couldn't set data: %s",
1477 set_error.AsCString());
1482 error.SetErrorStringWithFormat(
1483 "Couldn't set data: could not get SBValue: %s",
1484 locker.GetError().AsCString());
1489 log->Printf("SBValue(%p)::SetData (%p) => %s",
1490 static_cast<void *>(value_sp.get()),
1491 static_cast<void *>(data.get()), ret ? "true" : "false");
1495 lldb::SBDeclaration SBValue::GetDeclaration() {
1497 lldb::ValueObjectSP value_sp(GetSP(locker));
1498 SBDeclaration decl_sb;
1501 if (value_sp->GetDeclaration(decl))
1502 decl_sb.SetDeclaration(decl);
1507 lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write,
1509 SBWatchpoint sb_watchpoint;
1511 // If the SBValue is not valid, there's no point in even trying to watch it.
1513 lldb::ValueObjectSP value_sp(GetSP(locker));
1514 TargetSP target_sp(GetTarget().GetSP());
1515 if (value_sp && target_sp) {
1516 // Read and Write cannot both be false.
1517 if (!read && !write)
1518 return sb_watchpoint;
1520 // If the value is not in scope, don't try and watch and invalid value
1522 return sb_watchpoint;
1524 addr_t addr = GetLoadAddress();
1525 if (addr == LLDB_INVALID_ADDRESS)
1526 return sb_watchpoint;
1527 size_t byte_size = GetByteSize();
1529 return sb_watchpoint;
1531 uint32_t watch_type = 0;
1533 watch_type |= LLDB_WATCH_TYPE_READ;
1535 watch_type |= LLDB_WATCH_TYPE_WRITE;
1538 CompilerType type(value_sp->GetCompilerType());
1539 WatchpointSP watchpoint_sp =
1540 target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc);
1543 if (watchpoint_sp) {
1544 sb_watchpoint.SetSP(watchpoint_sp);
1546 if (value_sp->GetDeclaration(decl)) {
1547 if (decl.GetFile()) {
1549 // True to show fullpath for declaration file.
1550 decl.DumpStopContext(&ss, true);
1551 watchpoint_sp->SetDeclInfo(ss.GetString());
1555 } else if (target_sp) {
1556 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1558 log->Printf("SBValue(%p)::Watch() => error getting SBValue: %s",
1559 static_cast<void *>(value_sp.get()),
1560 locker.GetError().AsCString());
1562 error.SetErrorStringWithFormat("could not get SBValue: %s",
1563 locker.GetError().AsCString());
1565 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1567 log->Printf("SBValue(%p)::Watch() => error getting SBValue: no target",
1568 static_cast<void *>(value_sp.get()));
1569 error.SetErrorString("could not set watchpoint, a target is required");
1572 return sb_watchpoint;
1575 // FIXME: Remove this method impl (as well as the decl in .h) once it is no
1577 // Backward compatibility fix in the interim.
1578 lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read,
1581 return Watch(resolve_location, read, write, error);
1584 lldb::SBWatchpoint SBValue::WatchPointee(bool resolve_location, bool read,
1585 bool write, SBError &error) {
1586 SBWatchpoint sb_watchpoint;
1587 if (IsInScope() && GetType().IsPointerType())
1588 sb_watchpoint = Dereference().Watch(resolve_location, read, write, error);
1589 return sb_watchpoint;
1592 lldb::SBValue SBValue::Persist() {
1594 lldb::ValueObjectSP value_sp(GetSP(locker));
1595 SBValue persisted_sb;
1597 persisted_sb.SetSP(value_sp->Persist());
1599 return persisted_sb;