1 //===-- SBValue.cpp -------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBValue.h"
10 #include "SBReproducerPrivate.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/Scalar.h"
40 #include "lldb/Utility/Stream.h"
42 #include "lldb/API/SBDebugger.h"
43 #include "lldb/API/SBExpressionOptions.h"
44 #include "lldb/API/SBFrame.h"
45 #include "lldb/API/SBProcess.h"
46 #include "lldb/API/SBTarget.h"
47 #include "lldb/API/SBThread.h"
52 using namespace lldb_private;
56 ValueImpl() = default;
58 ValueImpl(lldb::ValueObjectSP in_valobj_sp,
59 lldb::DynamicValueType use_dynamic, bool use_synthetic,
60 const char *name = nullptr)
61 : m_valobj_sp(), m_use_dynamic(use_dynamic),
62 m_use_synthetic(use_synthetic), m_name(name) {
64 if ((m_valobj_sp = in_valobj_sp->GetQualifiedRepresentationIfAvailable(
65 lldb::eNoDynamicValues, false))) {
66 if (!m_name.IsEmpty())
67 m_valobj_sp->SetName(m_name);
72 ValueImpl(const ValueImpl &rhs)
73 : m_valobj_sp(rhs.m_valobj_sp), m_use_dynamic(rhs.m_use_dynamic),
74 m_use_synthetic(rhs.m_use_synthetic), m_name(rhs.m_name) {}
76 ValueImpl &operator=(const ValueImpl &rhs) {
78 m_valobj_sp = rhs.m_valobj_sp;
79 m_use_dynamic = rhs.m_use_dynamic;
80 m_use_synthetic = rhs.m_use_synthetic;
87 if (m_valobj_sp.get() == nullptr)
90 // FIXME: This check is necessary but not sufficient. We for sure don't
91 // want to touch SBValues whose owning
92 // targets have gone away. This check is a little weak in that it
93 // enforces that restriction when you call IsValid, but since IsValid
94 // doesn't lock the target, you have no guarantee that the SBValue won't
95 // go invalid after you call this... Also, an SBValue could depend on
96 // data from one of the modules in the target, and those could go away
97 // independently of the target, for instance if a module is unloaded.
98 // But right now, neither SBValues nor ValueObjects know which modules
99 // they depend on. So I have no good way to make that check without
100 // tracking that in all the ValueObject subclasses.
101 TargetSP target_sp = m_valobj_sp->GetTargetSP();
102 return target_sp && target_sp->IsValid();
106 lldb::ValueObjectSP GetRootSP() { return m_valobj_sp; }
108 lldb::ValueObjectSP GetSP(Process::StopLocker &stop_locker,
109 std::unique_lock<std::recursive_mutex> &lock,
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
129 error.SetErrorString("process must be stopped.");
130 return ValueObjectSP();
133 if (m_use_dynamic != eNoDynamicValues) {
134 ValueObjectSP dynamic_sp = value_sp->GetDynamicValue(m_use_dynamic);
136 value_sp = dynamic_sp;
139 if (m_use_synthetic) {
140 ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue();
142 value_sp = synthetic_sp;
146 error.SetErrorString("invalid value object");
147 if (!m_name.IsEmpty())
148 value_sp->SetName(m_name);
153 void SetUseDynamic(lldb::DynamicValueType use_dynamic) {
154 m_use_dynamic = use_dynamic;
157 void SetUseSynthetic(bool use_synthetic) { m_use_synthetic = use_synthetic; }
159 lldb::DynamicValueType GetUseDynamic() { return m_use_dynamic; }
161 bool GetUseSynthetic() { return m_use_synthetic; }
163 // All the derived values that we would make from the m_valobj_sp will share
164 // the ExecutionContext with m_valobj_sp, so we don't need to do the
165 // calculations in GetSP to return the Target, Process, Thread or Frame. It
166 // is convenient to provide simple accessors for these, which I do here.
167 TargetSP GetTargetSP() {
169 return m_valobj_sp->GetTargetSP();
174 ProcessSP GetProcessSP() {
176 return m_valobj_sp->GetProcessSP();
181 ThreadSP GetThreadSP() {
183 return m_valobj_sp->GetThreadSP();
188 StackFrameSP GetFrameSP() {
190 return m_valobj_sp->GetFrameSP();
192 return StackFrameSP();
196 lldb::ValueObjectSP m_valobj_sp;
197 lldb::DynamicValueType m_use_dynamic;
198 bool m_use_synthetic;
204 ValueLocker() = default;
206 ValueObjectSP GetLockedSP(ValueImpl &in_value) {
207 return in_value.GetSP(m_stop_locker, m_lock, m_lock_error);
210 Status &GetError() { return m_lock_error; }
213 Process::StopLocker m_stop_locker;
214 std::unique_lock<std::recursive_mutex> m_lock;
218 SBValue::SBValue() : m_opaque_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBValue); }
220 SBValue::SBValue(const lldb::ValueObjectSP &value_sp) {
221 LLDB_RECORD_CONSTRUCTOR(SBValue, (const lldb::ValueObjectSP &), value_sp);
226 SBValue::SBValue(const SBValue &rhs) {
227 LLDB_RECORD_CONSTRUCTOR(SBValue, (const lldb::SBValue &), rhs);
229 SetSP(rhs.m_opaque_sp);
232 SBValue &SBValue::operator=(const SBValue &rhs) {
233 LLDB_RECORD_METHOD(lldb::SBValue &,
234 SBValue, operator=,(const lldb::SBValue &), rhs);
237 SetSP(rhs.m_opaque_sp);
239 return LLDB_RECORD_RESULT(*this);
242 SBValue::~SBValue() = default;
244 bool SBValue::IsValid() {
245 LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsValid);
246 return this->operator bool();
248 SBValue::operator bool() const {
249 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValue, operator bool);
251 // If this function ever changes to anything that does more than just check
252 // if the opaque shared pointer is non NULL, then we need to update all "if
253 // (m_opaque_sp)" code in this file.
254 return m_opaque_sp.get() != nullptr && m_opaque_sp->IsValid() &&
255 m_opaque_sp->GetRootSP().get() != nullptr;
258 void SBValue::Clear() {
259 LLDB_RECORD_METHOD_NO_ARGS(void, SBValue, Clear);
264 SBError SBValue::GetError() {
265 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBValue, GetError);
270 lldb::ValueObjectSP value_sp(GetSP(locker));
272 sb_error.SetError(value_sp->GetError());
274 sb_error.SetErrorStringWithFormat("error: %s",
275 locker.GetError().AsCString());
277 return LLDB_RECORD_RESULT(sb_error);
280 user_id_t SBValue::GetID() {
281 LLDB_RECORD_METHOD_NO_ARGS(lldb::user_id_t, SBValue, GetID);
284 lldb::ValueObjectSP value_sp(GetSP(locker));
286 return value_sp->GetID();
287 return LLDB_INVALID_UID;
290 const char *SBValue::GetName() {
291 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetName);
293 const char *name = nullptr;
295 lldb::ValueObjectSP value_sp(GetSP(locker));
297 name = value_sp->GetName().GetCString();
302 const char *SBValue::GetTypeName() {
303 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetTypeName);
305 const char *name = nullptr;
307 lldb::ValueObjectSP value_sp(GetSP(locker));
309 name = value_sp->GetQualifiedTypeName().GetCString();
315 const char *SBValue::GetDisplayTypeName() {
316 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetDisplayTypeName);
318 const char *name = nullptr;
320 lldb::ValueObjectSP value_sp(GetSP(locker));
322 name = value_sp->GetDisplayTypeName().GetCString();
328 size_t SBValue::GetByteSize() {
329 LLDB_RECORD_METHOD_NO_ARGS(size_t, SBValue, GetByteSize);
334 lldb::ValueObjectSP value_sp(GetSP(locker));
336 result = value_sp->GetByteSize();
342 bool SBValue::IsInScope() {
343 LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsInScope);
348 lldb::ValueObjectSP value_sp(GetSP(locker));
350 result = value_sp->IsInScope();
356 const char *SBValue::GetValue() {
357 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetValue);
359 const char *cstr = nullptr;
361 lldb::ValueObjectSP value_sp(GetSP(locker));
363 cstr = value_sp->GetValueAsCString();
369 ValueType SBValue::GetValueType() {
370 LLDB_RECORD_METHOD_NO_ARGS(lldb::ValueType, SBValue, GetValueType);
372 ValueType result = eValueTypeInvalid;
374 lldb::ValueObjectSP value_sp(GetSP(locker));
376 result = value_sp->GetValueType();
381 const char *SBValue::GetObjectDescription() {
382 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetObjectDescription);
384 const char *cstr = nullptr;
386 lldb::ValueObjectSP value_sp(GetSP(locker));
388 cstr = value_sp->GetObjectDescription();
394 SBType SBValue::GetType() {
395 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBValue, GetType);
399 lldb::ValueObjectSP value_sp(GetSP(locker));
402 type_sp = std::make_shared<TypeImpl>(value_sp->GetTypeImpl());
403 sb_type.SetSP(type_sp);
406 return LLDB_RECORD_RESULT(sb_type);
409 bool SBValue::GetValueDidChange() {
410 LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, GetValueDidChange);
414 lldb::ValueObjectSP value_sp(GetSP(locker));
416 if (value_sp->UpdateValueIfNeeded(false))
417 result = value_sp->GetValueDidChange();
423 const char *SBValue::GetSummary() {
424 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetSummary);
426 const char *cstr = nullptr;
428 lldb::ValueObjectSP value_sp(GetSP(locker));
430 cstr = value_sp->GetSummaryAsCString();
436 const char *SBValue::GetSummary(lldb::SBStream &stream,
437 lldb::SBTypeSummaryOptions &options) {
438 LLDB_RECORD_METHOD(const char *, SBValue, GetSummary,
439 (lldb::SBStream &, lldb::SBTypeSummaryOptions &), stream,
443 lldb::ValueObjectSP value_sp(GetSP(locker));
446 if (value_sp->GetSummaryAsCString(buffer, options.ref()) && !buffer.empty())
447 stream.Printf("%s", buffer.c_str());
449 const char *cstr = stream.GetData();
453 const char *SBValue::GetLocation() {
454 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetLocation);
456 const char *cstr = nullptr;
458 lldb::ValueObjectSP value_sp(GetSP(locker));
460 cstr = value_sp->GetLocationAsCString();
465 // Deprecated - use the one that takes an lldb::SBError
466 bool SBValue::SetValueFromCString(const char *value_str) {
467 LLDB_RECORD_METHOD(bool, SBValue, SetValueFromCString, (const char *),
471 return SetValueFromCString(value_str, dummy);
474 bool SBValue::SetValueFromCString(const char *value_str, lldb::SBError &error) {
475 LLDB_RECORD_METHOD(bool, SBValue, SetValueFromCString,
476 (const char *, lldb::SBError &), value_str, error);
478 bool success = false;
480 lldb::ValueObjectSP value_sp(GetSP(locker));
482 success = value_sp->SetValueFromCString(value_str, error.ref());
484 error.SetErrorStringWithFormat("Could not get value: %s",
485 locker.GetError().AsCString());
490 lldb::SBTypeFormat SBValue::GetTypeFormat() {
491 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeFormat, SBValue, GetTypeFormat);
493 lldb::SBTypeFormat format;
495 lldb::ValueObjectSP value_sp(GetSP(locker));
497 if (value_sp->UpdateValueIfNeeded(true)) {
498 lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
500 format.SetSP(format_sp);
503 return LLDB_RECORD_RESULT(format);
506 lldb::SBTypeSummary SBValue::GetTypeSummary() {
507 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeSummary, SBValue, GetTypeSummary);
509 lldb::SBTypeSummary summary;
511 lldb::ValueObjectSP value_sp(GetSP(locker));
513 if (value_sp->UpdateValueIfNeeded(true)) {
514 lldb::TypeSummaryImplSP summary_sp = value_sp->GetSummaryFormat();
516 summary.SetSP(summary_sp);
519 return LLDB_RECORD_RESULT(summary);
522 lldb::SBTypeFilter SBValue::GetTypeFilter() {
523 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeFilter, SBValue, GetTypeFilter);
525 lldb::SBTypeFilter filter;
527 lldb::ValueObjectSP value_sp(GetSP(locker));
529 if (value_sp->UpdateValueIfNeeded(true)) {
530 lldb::SyntheticChildrenSP synthetic_sp = value_sp->GetSyntheticChildren();
532 if (synthetic_sp && !synthetic_sp->IsScripted()) {
533 TypeFilterImplSP filter_sp =
534 std::static_pointer_cast<TypeFilterImpl>(synthetic_sp);
535 filter.SetSP(filter_sp);
539 return LLDB_RECORD_RESULT(filter);
542 lldb::SBTypeSynthetic SBValue::GetTypeSynthetic() {
543 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeSynthetic, SBValue, GetTypeSynthetic);
545 lldb::SBTypeSynthetic synthetic;
547 lldb::ValueObjectSP value_sp(GetSP(locker));
549 if (value_sp->UpdateValueIfNeeded(true)) {
550 lldb::SyntheticChildrenSP children_sp = value_sp->GetSyntheticChildren();
552 if (children_sp && children_sp->IsScripted()) {
553 ScriptedSyntheticChildrenSP synth_sp =
554 std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
555 synthetic.SetSP(synth_sp);
559 return LLDB_RECORD_RESULT(synthetic);
562 lldb::SBValue SBValue::CreateChildAtOffset(const char *name, uint32_t offset,
564 LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateChildAtOffset,
565 (const char *, uint32_t, lldb::SBType), name, offset,
568 lldb::SBValue sb_value;
570 lldb::ValueObjectSP value_sp(GetSP(locker));
571 lldb::ValueObjectSP new_value_sp;
573 TypeImplSP type_sp(type.GetSP());
574 if (type.IsValid()) {
575 sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(
576 offset, type_sp->GetCompilerType(false), true),
577 GetPreferDynamicValue(), GetPreferSyntheticValue(), name);
580 return LLDB_RECORD_RESULT(sb_value);
583 lldb::SBValue SBValue::Cast(SBType type) {
584 LLDB_RECORD_METHOD(lldb::SBValue, SBValue, Cast, (lldb::SBType), type);
586 lldb::SBValue sb_value;
588 lldb::ValueObjectSP value_sp(GetSP(locker));
589 TypeImplSP type_sp(type.GetSP());
590 if (value_sp && type_sp)
591 sb_value.SetSP(value_sp->Cast(type_sp->GetCompilerType(false)),
592 GetPreferDynamicValue(), GetPreferSyntheticValue());
593 return LLDB_RECORD_RESULT(sb_value);
596 lldb::SBValue SBValue::CreateValueFromExpression(const char *name,
597 const char *expression) {
598 LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromExpression,
599 (const char *, const char *), name, expression);
601 SBExpressionOptions options;
602 options.ref().SetKeepInMemory(true);
603 return LLDB_RECORD_RESULT(
604 CreateValueFromExpression(name, expression, options));
607 lldb::SBValue SBValue::CreateValueFromExpression(const char *name,
608 const char *expression,
609 SBExpressionOptions &options) {
610 LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromExpression,
611 (const char *, const char *, lldb::SBExpressionOptions &),
612 name, expression, options);
614 lldb::SBValue sb_value;
616 lldb::ValueObjectSP value_sp(GetSP(locker));
617 lldb::ValueObjectSP new_value_sp;
619 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
620 new_value_sp = ValueObject::CreateValueObjectFromExpression(
621 name, expression, exe_ctx, options.ref());
623 new_value_sp->SetName(ConstString(name));
625 sb_value.SetSP(new_value_sp);
626 return LLDB_RECORD_RESULT(sb_value);
629 lldb::SBValue SBValue::CreateValueFromAddress(const char *name,
630 lldb::addr_t address,
632 LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromAddress,
633 (const char *, lldb::addr_t, lldb::SBType), name, address,
636 lldb::SBValue sb_value;
638 lldb::ValueObjectSP value_sp(GetSP(locker));
639 lldb::ValueObjectSP new_value_sp;
640 lldb::TypeImplSP type_impl_sp(sb_type.GetSP());
641 if (value_sp && type_impl_sp) {
642 CompilerType ast_type(type_impl_sp->GetCompilerType(true));
643 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
644 new_value_sp = ValueObject::CreateValueObjectFromAddress(name, address,
647 sb_value.SetSP(new_value_sp);
648 return LLDB_RECORD_RESULT(sb_value);
651 lldb::SBValue SBValue::CreateValueFromData(const char *name, SBData data,
653 LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromData,
654 (const char *, lldb::SBData, lldb::SBType), name, data,
657 lldb::SBValue sb_value;
658 lldb::ValueObjectSP new_value_sp;
660 lldb::ValueObjectSP value_sp(GetSP(locker));
661 lldb::TypeImplSP type_impl_sp(sb_type.GetSP());
662 if (value_sp && type_impl_sp) {
663 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
664 new_value_sp = ValueObject::CreateValueObjectFromData(
665 name, **data, exe_ctx, type_impl_sp->GetCompilerType(true));
666 new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
668 sb_value.SetSP(new_value_sp);
669 return LLDB_RECORD_RESULT(sb_value);
672 SBValue SBValue::GetChildAtIndex(uint32_t idx) {
673 LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildAtIndex, (uint32_t), idx);
675 const bool can_create_synthetic = false;
676 lldb::DynamicValueType use_dynamic = eNoDynamicValues;
679 target_sp = m_opaque_sp->GetTargetSP();
682 use_dynamic = target_sp->GetPreferDynamicValue();
684 return LLDB_RECORD_RESULT(
685 GetChildAtIndex(idx, use_dynamic, can_create_synthetic));
688 SBValue SBValue::GetChildAtIndex(uint32_t idx,
689 lldb::DynamicValueType use_dynamic,
690 bool can_create_synthetic) {
691 LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildAtIndex,
692 (uint32_t, lldb::DynamicValueType, bool), idx, use_dynamic,
693 can_create_synthetic);
695 lldb::ValueObjectSP child_sp;
698 lldb::ValueObjectSP value_sp(GetSP(locker));
700 const bool can_create = true;
701 child_sp = value_sp->GetChildAtIndex(idx, can_create);
702 if (can_create_synthetic && !child_sp) {
703 child_sp = value_sp->GetSyntheticArrayMember(idx, can_create);
708 sb_value.SetSP(child_sp, use_dynamic, GetPreferSyntheticValue());
710 return LLDB_RECORD_RESULT(sb_value);
713 uint32_t SBValue::GetIndexOfChildWithName(const char *name) {
714 LLDB_RECORD_METHOD(uint32_t, SBValue, GetIndexOfChildWithName, (const char *),
717 uint32_t idx = UINT32_MAX;
719 lldb::ValueObjectSP value_sp(GetSP(locker));
721 idx = value_sp->GetIndexOfChildWithName(ConstString(name));
726 SBValue SBValue::GetChildMemberWithName(const char *name) {
727 LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName,
728 (const char *), name);
730 lldb::DynamicValueType use_dynamic_value = eNoDynamicValues;
733 target_sp = m_opaque_sp->GetTargetSP();
736 use_dynamic_value = target_sp->GetPreferDynamicValue();
737 return LLDB_RECORD_RESULT(GetChildMemberWithName(name, use_dynamic_value));
741 SBValue::GetChildMemberWithName(const char *name,
742 lldb::DynamicValueType use_dynamic_value) {
743 LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName,
744 (const char *, lldb::DynamicValueType), name,
747 lldb::ValueObjectSP child_sp;
748 const ConstString str_name(name);
751 lldb::ValueObjectSP value_sp(GetSP(locker));
753 child_sp = value_sp->GetChildMemberWithName(str_name, true);
757 sb_value.SetSP(child_sp, use_dynamic_value, GetPreferSyntheticValue());
759 return LLDB_RECORD_RESULT(sb_value);
762 lldb::SBValue SBValue::GetDynamicValue(lldb::DynamicValueType use_dynamic) {
763 LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetDynamicValue,
764 (lldb::DynamicValueType), use_dynamic);
768 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), use_dynamic,
769 m_opaque_sp->GetUseSynthetic()));
770 value_sb.SetSP(proxy_sp);
772 return LLDB_RECORD_RESULT(value_sb);
775 lldb::SBValue SBValue::GetStaticValue() {
776 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, GetStaticValue);
780 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
782 m_opaque_sp->GetUseSynthetic()));
783 value_sb.SetSP(proxy_sp);
785 return LLDB_RECORD_RESULT(value_sb);
788 lldb::SBValue SBValue::GetNonSyntheticValue() {
789 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, GetNonSyntheticValue);
793 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
794 m_opaque_sp->GetUseDynamic(), false));
795 value_sb.SetSP(proxy_sp);
797 return LLDB_RECORD_RESULT(value_sb);
800 lldb::DynamicValueType SBValue::GetPreferDynamicValue() {
801 LLDB_RECORD_METHOD_NO_ARGS(lldb::DynamicValueType, SBValue,
802 GetPreferDynamicValue);
805 return eNoDynamicValues;
806 return m_opaque_sp->GetUseDynamic();
809 void SBValue::SetPreferDynamicValue(lldb::DynamicValueType use_dynamic) {
810 LLDB_RECORD_METHOD(void, SBValue, SetPreferDynamicValue,
811 (lldb::DynamicValueType), use_dynamic);
814 return m_opaque_sp->SetUseDynamic(use_dynamic);
817 bool SBValue::GetPreferSyntheticValue() {
818 LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, GetPreferSyntheticValue);
822 return m_opaque_sp->GetUseSynthetic();
825 void SBValue::SetPreferSyntheticValue(bool use_synthetic) {
826 LLDB_RECORD_METHOD(void, SBValue, SetPreferSyntheticValue, (bool),
830 return m_opaque_sp->SetUseSynthetic(use_synthetic);
833 bool SBValue::IsDynamic() {
834 LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsDynamic);
837 lldb::ValueObjectSP value_sp(GetSP(locker));
839 return value_sp->IsDynamic();
843 bool SBValue::IsSynthetic() {
844 LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsSynthetic);
847 lldb::ValueObjectSP value_sp(GetSP(locker));
849 return value_sp->IsSynthetic();
853 bool SBValue::IsSyntheticChildrenGenerated() {
854 LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsSyntheticChildrenGenerated);
857 lldb::ValueObjectSP value_sp(GetSP(locker));
859 return value_sp->IsSyntheticChildrenGenerated();
863 void SBValue::SetSyntheticChildrenGenerated(bool is) {
864 LLDB_RECORD_METHOD(void, SBValue, SetSyntheticChildrenGenerated, (bool), is);
867 lldb::ValueObjectSP value_sp(GetSP(locker));
869 return value_sp->SetSyntheticChildrenGenerated(is);
872 lldb::SBValue SBValue::GetValueForExpressionPath(const char *expr_path) {
873 LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetValueForExpressionPath,
874 (const char *), expr_path);
876 lldb::ValueObjectSP child_sp;
878 lldb::ValueObjectSP value_sp(GetSP(locker));
880 // using default values for all the fancy options, just do it if you can
881 child_sp = value_sp->GetValueForExpressionPath(expr_path);
885 sb_value.SetSP(child_sp, GetPreferDynamicValue(), GetPreferSyntheticValue());
887 return LLDB_RECORD_RESULT(sb_value);
890 int64_t SBValue::GetValueAsSigned(SBError &error, int64_t fail_value) {
891 LLDB_RECORD_METHOD(int64_t, SBValue, GetValueAsSigned,
892 (lldb::SBError &, int64_t), error, fail_value);
896 lldb::ValueObjectSP value_sp(GetSP(locker));
899 uint64_t ret_val = fail_value;
900 ret_val = value_sp->GetValueAsSigned(fail_value, &success);
902 error.SetErrorString("could not resolve value");
905 error.SetErrorStringWithFormat("could not get SBValue: %s",
906 locker.GetError().AsCString());
911 uint64_t SBValue::GetValueAsUnsigned(SBError &error, uint64_t fail_value) {
912 LLDB_RECORD_METHOD(uint64_t, SBValue, GetValueAsUnsigned,
913 (lldb::SBError &, uint64_t), error, fail_value);
917 lldb::ValueObjectSP value_sp(GetSP(locker));
920 uint64_t ret_val = fail_value;
921 ret_val = value_sp->GetValueAsUnsigned(fail_value, &success);
923 error.SetErrorString("could not resolve value");
926 error.SetErrorStringWithFormat("could not get SBValue: %s",
927 locker.GetError().AsCString());
932 int64_t SBValue::GetValueAsSigned(int64_t fail_value) {
933 LLDB_RECORD_METHOD(int64_t, SBValue, GetValueAsSigned, (int64_t), fail_value);
936 lldb::ValueObjectSP value_sp(GetSP(locker));
938 return value_sp->GetValueAsSigned(fail_value);
943 uint64_t SBValue::GetValueAsUnsigned(uint64_t fail_value) {
944 LLDB_RECORD_METHOD(uint64_t, SBValue, GetValueAsUnsigned, (uint64_t),
948 lldb::ValueObjectSP value_sp(GetSP(locker));
950 return value_sp->GetValueAsUnsigned(fail_value);
955 bool SBValue::MightHaveChildren() {
956 LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, MightHaveChildren);
958 bool has_children = false;
960 lldb::ValueObjectSP value_sp(GetSP(locker));
962 has_children = value_sp->MightHaveChildren();
967 bool SBValue::IsRuntimeSupportValue() {
968 LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsRuntimeSupportValue);
970 bool is_support = false;
972 lldb::ValueObjectSP value_sp(GetSP(locker));
974 is_support = value_sp->IsRuntimeSupportValue();
979 uint32_t SBValue::GetNumChildren() {
980 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBValue, GetNumChildren);
982 return GetNumChildren(UINT32_MAX);
985 uint32_t SBValue::GetNumChildren(uint32_t max) {
986 LLDB_RECORD_METHOD(uint32_t, SBValue, GetNumChildren, (uint32_t), max);
988 uint32_t num_children = 0;
991 lldb::ValueObjectSP value_sp(GetSP(locker));
993 num_children = value_sp->GetNumChildren(max);
998 SBValue SBValue::Dereference() {
999 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, Dereference);
1003 lldb::ValueObjectSP value_sp(GetSP(locker));
1006 sb_value = value_sp->Dereference(error);
1009 return LLDB_RECORD_RESULT(sb_value);
1012 // Deprecated - please use GetType().IsPointerType() instead.
1013 bool SBValue::TypeIsPointerType() {
1014 LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, TypeIsPointerType);
1016 return GetType().IsPointerType();
1019 void *SBValue::GetOpaqueType() {
1020 LLDB_RECORD_METHOD_NO_ARGS(void *, SBValue, GetOpaqueType);
1023 lldb::ValueObjectSP value_sp(GetSP(locker));
1025 return value_sp->GetCompilerType().GetOpaqueQualType();
1029 lldb::SBTarget SBValue::GetTarget() {
1030 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBValue, GetTarget);
1035 target_sp = m_opaque_sp->GetTargetSP();
1036 sb_target.SetSP(target_sp);
1039 return LLDB_RECORD_RESULT(sb_target);
1042 lldb::SBProcess SBValue::GetProcess() {
1043 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBValue, GetProcess);
1045 SBProcess sb_process;
1046 ProcessSP process_sp;
1048 process_sp = m_opaque_sp->GetProcessSP();
1049 sb_process.SetSP(process_sp);
1052 return LLDB_RECORD_RESULT(sb_process);
1055 lldb::SBThread SBValue::GetThread() {
1056 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBThread, SBValue, GetThread);
1061 thread_sp = m_opaque_sp->GetThreadSP();
1062 sb_thread.SetThread(thread_sp);
1065 return LLDB_RECORD_RESULT(sb_thread);
1068 lldb::SBFrame SBValue::GetFrame() {
1069 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFrame, SBValue, GetFrame);
1072 StackFrameSP frame_sp;
1074 frame_sp = m_opaque_sp->GetFrameSP();
1075 sb_frame.SetFrameSP(frame_sp);
1078 return LLDB_RECORD_RESULT(sb_frame);
1081 lldb::ValueObjectSP SBValue::GetSP(ValueLocker &locker) const {
1082 if (!m_opaque_sp || !m_opaque_sp->IsValid()) {
1083 locker.GetError().SetErrorString("No value");
1084 return ValueObjectSP();
1086 return locker.GetLockedSP(*m_opaque_sp.get());
1089 lldb::ValueObjectSP SBValue::GetSP() const {
1090 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ValueObjectSP, SBValue, GetSP);
1093 return LLDB_RECORD_RESULT(GetSP(locker));
1096 void SBValue::SetSP(ValueImplSP impl_sp) { m_opaque_sp = impl_sp; }
1098 void SBValue::SetSP(const lldb::ValueObjectSP &sp) {
1100 lldb::TargetSP target_sp(sp->GetTargetSP());
1102 lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1103 bool use_synthetic =
1104 target_sp->TargetProperties::GetEnableSyntheticValue();
1105 m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
1107 m_opaque_sp = ValueImplSP(new ValueImpl(sp, eNoDynamicValues, true));
1109 m_opaque_sp = ValueImplSP(new ValueImpl(sp, eNoDynamicValues, false));
1112 void SBValue::SetSP(const lldb::ValueObjectSP &sp,
1113 lldb::DynamicValueType use_dynamic) {
1115 lldb::TargetSP target_sp(sp->GetTargetSP());
1117 bool use_synthetic =
1118 target_sp->TargetProperties::GetEnableSyntheticValue();
1119 SetSP(sp, use_dynamic, use_synthetic);
1121 SetSP(sp, use_dynamic, true);
1123 SetSP(sp, use_dynamic, false);
1126 void SBValue::SetSP(const lldb::ValueObjectSP &sp, bool use_synthetic) {
1128 lldb::TargetSP target_sp(sp->GetTargetSP());
1130 lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1131 SetSP(sp, use_dynamic, use_synthetic);
1133 SetSP(sp, eNoDynamicValues, use_synthetic);
1135 SetSP(sp, eNoDynamicValues, use_synthetic);
1138 void SBValue::SetSP(const lldb::ValueObjectSP &sp,
1139 lldb::DynamicValueType use_dynamic, bool use_synthetic) {
1140 m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
1143 void SBValue::SetSP(const lldb::ValueObjectSP &sp,
1144 lldb::DynamicValueType use_dynamic, bool use_synthetic,
1147 ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic, name));
1150 bool SBValue::GetExpressionPath(SBStream &description) {
1151 LLDB_RECORD_METHOD(bool, SBValue, GetExpressionPath, (lldb::SBStream &),
1155 lldb::ValueObjectSP value_sp(GetSP(locker));
1157 value_sp->GetExpressionPath(description.ref());
1163 bool SBValue::GetExpressionPath(SBStream &description,
1164 bool qualify_cxx_base_classes) {
1165 LLDB_RECORD_METHOD(bool, SBValue, GetExpressionPath, (lldb::SBStream &, bool),
1166 description, qualify_cxx_base_classes);
1169 lldb::ValueObjectSP value_sp(GetSP(locker));
1171 value_sp->GetExpressionPath(description.ref());
1177 lldb::SBValue SBValue::EvaluateExpression(const char *expr) const {
1178 LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValue, EvaluateExpression,
1179 (const char *), expr);
1182 lldb::ValueObjectSP value_sp(GetSP(locker));
1184 return LLDB_RECORD_RESULT(SBValue());
1186 lldb::TargetSP target_sp = value_sp->GetTargetSP();
1188 return LLDB_RECORD_RESULT(SBValue());
1190 lldb::SBExpressionOptions options;
1191 options.SetFetchDynamicValue(target_sp->GetPreferDynamicValue());
1192 options.SetUnwindOnError(true);
1193 options.SetIgnoreBreakpoints(true);
1195 return LLDB_RECORD_RESULT(EvaluateExpression(expr, options, nullptr));
1199 SBValue::EvaluateExpression(const char *expr,
1200 const SBExpressionOptions &options) const {
1201 LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValue, EvaluateExpression,
1202 (const char *, const lldb::SBExpressionOptions &),
1205 return LLDB_RECORD_RESULT(EvaluateExpression(expr, options, nullptr));
1208 lldb::SBValue SBValue::EvaluateExpression(const char *expr,
1209 const SBExpressionOptions &options,
1210 const char *name) const {
1211 LLDB_RECORD_METHOD_CONST(
1212 lldb::SBValue, SBValue, EvaluateExpression,
1213 (const char *, const lldb::SBExpressionOptions &, const char *), expr,
1217 if (!expr || expr[0] == '\0') {
1218 return LLDB_RECORD_RESULT(SBValue());
1223 lldb::ValueObjectSP value_sp(GetSP(locker));
1225 return LLDB_RECORD_RESULT(SBValue());
1228 lldb::TargetSP target_sp = value_sp->GetTargetSP();
1230 return LLDB_RECORD_RESULT(SBValue());
1233 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1234 ExecutionContext exe_ctx(target_sp.get());
1236 StackFrame *frame = exe_ctx.GetFramePtr();
1238 return LLDB_RECORD_RESULT(SBValue());
1241 ValueObjectSP res_val_sp;
1242 target_sp->EvaluateExpression(expr, frame, res_val_sp, options.ref(), nullptr,
1246 res_val_sp->SetName(ConstString(name));
1249 result.SetSP(res_val_sp, options.GetFetchDynamicValue());
1250 return LLDB_RECORD_RESULT(result);
1253 bool SBValue::GetDescription(SBStream &description) {
1254 LLDB_RECORD_METHOD(bool, SBValue, GetDescription, (lldb::SBStream &),
1257 Stream &strm = description.ref();
1260 lldb::ValueObjectSP value_sp(GetSP(locker));
1262 value_sp->Dump(strm);
1264 strm.PutCString("No value");
1269 lldb::Format SBValue::GetFormat() {
1270 LLDB_RECORD_METHOD_NO_ARGS(lldb::Format, SBValue, GetFormat);
1273 lldb::ValueObjectSP value_sp(GetSP(locker));
1275 return value_sp->GetFormat();
1276 return eFormatDefault;
1279 void SBValue::SetFormat(lldb::Format format) {
1280 LLDB_RECORD_METHOD(void, SBValue, SetFormat, (lldb::Format), format);
1283 lldb::ValueObjectSP value_sp(GetSP(locker));
1285 value_sp->SetFormat(format);
1288 lldb::SBValue SBValue::AddressOf() {
1289 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, AddressOf);
1293 lldb::ValueObjectSP value_sp(GetSP(locker));
1296 sb_value.SetSP(value_sp->AddressOf(error), GetPreferDynamicValue(),
1297 GetPreferSyntheticValue());
1300 return LLDB_RECORD_RESULT(sb_value);
1303 lldb::addr_t SBValue::GetLoadAddress() {
1304 LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBValue, GetLoadAddress);
1306 lldb::addr_t value = LLDB_INVALID_ADDRESS;
1308 lldb::ValueObjectSP value_sp(GetSP(locker));
1310 TargetSP target_sp(value_sp->GetTargetSP());
1312 const bool scalar_is_load_address = true;
1313 AddressType addr_type;
1314 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
1315 if (addr_type == eAddressTypeFile) {
1316 ModuleSP module_sp(value_sp->GetModule());
1318 value = LLDB_INVALID_ADDRESS;
1321 module_sp->ResolveFileAddress(value, addr);
1322 value = addr.GetLoadAddress(target_sp.get());
1324 } else if (addr_type == eAddressTypeHost ||
1325 addr_type == eAddressTypeInvalid)
1326 value = LLDB_INVALID_ADDRESS;
1333 lldb::SBAddress SBValue::GetAddress() {
1334 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBValue, GetAddress);
1338 lldb::ValueObjectSP value_sp(GetSP(locker));
1340 TargetSP target_sp(value_sp->GetTargetSP());
1342 lldb::addr_t value = LLDB_INVALID_ADDRESS;
1343 const bool scalar_is_load_address = true;
1344 AddressType addr_type;
1345 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
1346 if (addr_type == eAddressTypeFile) {
1347 ModuleSP module_sp(value_sp->GetModule());
1349 module_sp->ResolveFileAddress(value, addr);
1350 } else if (addr_type == eAddressTypeLoad) {
1351 // no need to check the return value on this.. if it can actually do
1352 // the resolve addr will be in the form (section,offset), otherwise it
1353 // will simply be returned as (NULL, value)
1354 addr.SetLoadAddress(value, target_sp.get());
1359 return LLDB_RECORD_RESULT(SBAddress(new Address(addr)));
1362 lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) {
1363 LLDB_RECORD_METHOD(lldb::SBData, SBValue, GetPointeeData,
1364 (uint32_t, uint32_t), item_idx, item_count);
1366 lldb::SBData sb_data;
1368 lldb::ValueObjectSP value_sp(GetSP(locker));
1370 TargetSP target_sp(value_sp->GetTargetSP());
1372 DataExtractorSP data_sp(new DataExtractor());
1373 value_sp->GetPointeeData(*data_sp, item_idx, item_count);
1374 if (data_sp->GetByteSize() > 0)
1379 return LLDB_RECORD_RESULT(sb_data);
1382 lldb::SBData SBValue::GetData() {
1383 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBData, SBValue, GetData);
1385 lldb::SBData sb_data;
1387 lldb::ValueObjectSP value_sp(GetSP(locker));
1389 DataExtractorSP data_sp(new DataExtractor());
1391 value_sp->GetData(*data_sp, error);
1392 if (error.Success())
1396 return LLDB_RECORD_RESULT(sb_data);
1399 bool SBValue::SetData(lldb::SBData &data, SBError &error) {
1400 LLDB_RECORD_METHOD(bool, SBValue, SetData, (lldb::SBData &, lldb::SBError &),
1404 lldb::ValueObjectSP value_sp(GetSP(locker));
1408 DataExtractor *data_extractor = data.get();
1410 if (!data_extractor) {
1411 error.SetErrorString("No data to set");
1416 value_sp->SetData(*data_extractor, set_error);
1418 if (!set_error.Success()) {
1419 error.SetErrorStringWithFormat("Couldn't set data: %s",
1420 set_error.AsCString());
1425 error.SetErrorStringWithFormat(
1426 "Couldn't set data: could not get SBValue: %s",
1427 locker.GetError().AsCString());
1434 lldb::SBDeclaration SBValue::GetDeclaration() {
1435 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBDeclaration, SBValue, GetDeclaration);
1438 lldb::ValueObjectSP value_sp(GetSP(locker));
1439 SBDeclaration decl_sb;
1442 if (value_sp->GetDeclaration(decl))
1443 decl_sb.SetDeclaration(decl);
1445 return LLDB_RECORD_RESULT(decl_sb);
1448 lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write,
1450 LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBValue, Watch,
1451 (bool, bool, bool, lldb::SBError &), resolve_location,
1452 read, write, error);
1454 SBWatchpoint sb_watchpoint;
1456 // If the SBValue is not valid, there's no point in even trying to watch it.
1458 lldb::ValueObjectSP value_sp(GetSP(locker));
1459 TargetSP target_sp(GetTarget().GetSP());
1460 if (value_sp && target_sp) {
1461 // Read and Write cannot both be false.
1462 if (!read && !write)
1463 return LLDB_RECORD_RESULT(sb_watchpoint);
1465 // If the value is not in scope, don't try and watch and invalid value
1467 return LLDB_RECORD_RESULT(sb_watchpoint);
1469 addr_t addr = GetLoadAddress();
1470 if (addr == LLDB_INVALID_ADDRESS)
1471 return LLDB_RECORD_RESULT(sb_watchpoint);
1472 size_t byte_size = GetByteSize();
1474 return LLDB_RECORD_RESULT(sb_watchpoint);
1476 uint32_t watch_type = 0;
1478 watch_type |= LLDB_WATCH_TYPE_READ;
1480 watch_type |= LLDB_WATCH_TYPE_WRITE;
1483 CompilerType type(value_sp->GetCompilerType());
1484 WatchpointSP watchpoint_sp =
1485 target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc);
1488 if (watchpoint_sp) {
1489 sb_watchpoint.SetSP(watchpoint_sp);
1491 if (value_sp->GetDeclaration(decl)) {
1492 if (decl.GetFile()) {
1494 // True to show fullpath for declaration file.
1495 decl.DumpStopContext(&ss, true);
1496 watchpoint_sp->SetDeclInfo(std::string(ss.GetString()));
1500 } else if (target_sp) {
1501 error.SetErrorStringWithFormat("could not get SBValue: %s",
1502 locker.GetError().AsCString());
1504 error.SetErrorString("could not set watchpoint, a target is required");
1507 return LLDB_RECORD_RESULT(sb_watchpoint);
1510 // FIXME: Remove this method impl (as well as the decl in .h) once it is no
1512 // Backward compatibility fix in the interim.
1513 lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read,
1515 LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBValue, Watch, (bool, bool, bool),
1516 resolve_location, read, write);
1519 return LLDB_RECORD_RESULT(Watch(resolve_location, read, write, error));
1522 lldb::SBWatchpoint SBValue::WatchPointee(bool resolve_location, bool read,
1523 bool write, SBError &error) {
1524 LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBValue, WatchPointee,
1525 (bool, bool, bool, lldb::SBError &), resolve_location,
1526 read, write, error);
1528 SBWatchpoint sb_watchpoint;
1529 if (IsInScope() && GetType().IsPointerType())
1530 sb_watchpoint = Dereference().Watch(resolve_location, read, write, error);
1531 return LLDB_RECORD_RESULT(sb_watchpoint);
1534 lldb::SBValue SBValue::Persist() {
1535 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, Persist);
1538 lldb::ValueObjectSP value_sp(GetSP(locker));
1539 SBValue persisted_sb;
1541 persisted_sb.SetSP(value_sp->Persist());
1543 return LLDB_RECORD_RESULT(persisted_sb);
1546 namespace lldb_private {
1550 void RegisterMethods<SBValue>(Registry &R) {
1551 LLDB_REGISTER_CONSTRUCTOR(SBValue, ());
1552 LLDB_REGISTER_CONSTRUCTOR(SBValue, (const lldb::ValueObjectSP &));
1553 LLDB_REGISTER_CONSTRUCTOR(SBValue, (const lldb::SBValue &));
1554 LLDB_REGISTER_METHOD(lldb::SBValue &,
1555 SBValue, operator=,(const lldb::SBValue &));
1556 LLDB_REGISTER_METHOD(bool, SBValue, IsValid, ());
1557 LLDB_REGISTER_METHOD_CONST(bool, SBValue, operator bool, ());
1558 LLDB_REGISTER_METHOD(void, SBValue, Clear, ());
1559 LLDB_REGISTER_METHOD(lldb::SBError, SBValue, GetError, ());
1560 LLDB_REGISTER_METHOD(lldb::user_id_t, SBValue, GetID, ());
1561 LLDB_REGISTER_METHOD(const char *, SBValue, GetName, ());
1562 LLDB_REGISTER_METHOD(const char *, SBValue, GetTypeName, ());
1563 LLDB_REGISTER_METHOD(const char *, SBValue, GetDisplayTypeName, ());
1564 LLDB_REGISTER_METHOD(size_t, SBValue, GetByteSize, ());
1565 LLDB_REGISTER_METHOD(bool, SBValue, IsInScope, ());
1566 LLDB_REGISTER_METHOD(const char *, SBValue, GetValue, ());
1567 LLDB_REGISTER_METHOD(lldb::ValueType, SBValue, GetValueType, ());
1568 LLDB_REGISTER_METHOD(const char *, SBValue, GetObjectDescription, ());
1569 LLDB_REGISTER_METHOD(lldb::SBType, SBValue, GetType, ());
1570 LLDB_REGISTER_METHOD(bool, SBValue, GetValueDidChange, ());
1571 LLDB_REGISTER_METHOD(const char *, SBValue, GetSummary, ());
1572 LLDB_REGISTER_METHOD(const char *, SBValue, GetSummary,
1573 (lldb::SBStream &, lldb::SBTypeSummaryOptions &));
1574 LLDB_REGISTER_METHOD(const char *, SBValue, GetLocation, ());
1575 LLDB_REGISTER_METHOD(bool, SBValue, SetValueFromCString, (const char *));
1576 LLDB_REGISTER_METHOD(bool, SBValue, SetValueFromCString,
1577 (const char *, lldb::SBError &));
1578 LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBValue, GetTypeFormat, ());
1579 LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBValue, GetTypeSummary, ());
1580 LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBValue, GetTypeFilter, ());
1581 LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBValue, GetTypeSynthetic, ());
1582 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateChildAtOffset,
1583 (const char *, uint32_t, lldb::SBType));
1584 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, Cast, (lldb::SBType));
1585 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateValueFromExpression,
1586 (const char *, const char *));
1587 LLDB_REGISTER_METHOD(
1588 lldb::SBValue, SBValue, CreateValueFromExpression,
1589 (const char *, const char *, lldb::SBExpressionOptions &));
1590 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateValueFromAddress,
1591 (const char *, lldb::addr_t, lldb::SBType));
1592 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateValueFromData,
1593 (const char *, lldb::SBData, lldb::SBType));
1594 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildAtIndex, (uint32_t));
1595 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildAtIndex,
1596 (uint32_t, lldb::DynamicValueType, bool));
1597 LLDB_REGISTER_METHOD(uint32_t, SBValue, GetIndexOfChildWithName,
1599 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName,
1601 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName,
1602 (const char *, lldb::DynamicValueType));
1603 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetDynamicValue,
1604 (lldb::DynamicValueType));
1605 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetStaticValue, ());
1606 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetNonSyntheticValue, ());
1607 LLDB_REGISTER_METHOD(lldb::DynamicValueType, SBValue, GetPreferDynamicValue,
1609 LLDB_REGISTER_METHOD(void, SBValue, SetPreferDynamicValue,
1610 (lldb::DynamicValueType));
1611 LLDB_REGISTER_METHOD(bool, SBValue, GetPreferSyntheticValue, ());
1612 LLDB_REGISTER_METHOD(void, SBValue, SetPreferSyntheticValue, (bool));
1613 LLDB_REGISTER_METHOD(bool, SBValue, IsDynamic, ());
1614 LLDB_REGISTER_METHOD(bool, SBValue, IsSynthetic, ());
1615 LLDB_REGISTER_METHOD(bool, SBValue, IsSyntheticChildrenGenerated, ());
1616 LLDB_REGISTER_METHOD(void, SBValue, SetSyntheticChildrenGenerated, (bool));
1617 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetValueForExpressionPath,
1619 LLDB_REGISTER_METHOD(int64_t, SBValue, GetValueAsSigned,
1620 (lldb::SBError &, int64_t));
1621 LLDB_REGISTER_METHOD(uint64_t, SBValue, GetValueAsUnsigned,
1622 (lldb::SBError &, uint64_t));
1623 LLDB_REGISTER_METHOD(int64_t, SBValue, GetValueAsSigned, (int64_t));
1624 LLDB_REGISTER_METHOD(uint64_t, SBValue, GetValueAsUnsigned, (uint64_t));
1625 LLDB_REGISTER_METHOD(bool, SBValue, MightHaveChildren, ());
1626 LLDB_REGISTER_METHOD(bool, SBValue, IsRuntimeSupportValue, ());
1627 LLDB_REGISTER_METHOD(uint32_t, SBValue, GetNumChildren, ());
1628 LLDB_REGISTER_METHOD(uint32_t, SBValue, GetNumChildren, (uint32_t));
1629 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, Dereference, ());
1630 LLDB_REGISTER_METHOD(bool, SBValue, TypeIsPointerType, ());
1631 LLDB_REGISTER_METHOD(void *, SBValue, GetOpaqueType, ());
1632 LLDB_REGISTER_METHOD(lldb::SBTarget, SBValue, GetTarget, ());
1633 LLDB_REGISTER_METHOD(lldb::SBProcess, SBValue, GetProcess, ());
1634 LLDB_REGISTER_METHOD(lldb::SBThread, SBValue, GetThread, ());
1635 LLDB_REGISTER_METHOD(lldb::SBFrame, SBValue, GetFrame, ());
1636 LLDB_REGISTER_METHOD_CONST(lldb::ValueObjectSP, SBValue, GetSP, ());
1637 LLDB_REGISTER_METHOD(bool, SBValue, GetExpressionPath, (lldb::SBStream &));
1638 LLDB_REGISTER_METHOD(bool, SBValue, GetExpressionPath,
1639 (lldb::SBStream &, bool));
1640 LLDB_REGISTER_METHOD_CONST(lldb::SBValue, SBValue, EvaluateExpression,
1642 LLDB_REGISTER_METHOD_CONST(
1643 lldb::SBValue, SBValue, EvaluateExpression,
1644 (const char *, const lldb::SBExpressionOptions &));
1645 LLDB_REGISTER_METHOD_CONST(
1646 lldb::SBValue, SBValue, EvaluateExpression,
1647 (const char *, const lldb::SBExpressionOptions &, const char *));
1648 LLDB_REGISTER_METHOD(bool, SBValue, GetDescription, (lldb::SBStream &));
1649 LLDB_REGISTER_METHOD(lldb::Format, SBValue, GetFormat, ());
1650 LLDB_REGISTER_METHOD(void, SBValue, SetFormat, (lldb::Format));
1651 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, AddressOf, ());
1652 LLDB_REGISTER_METHOD(lldb::addr_t, SBValue, GetLoadAddress, ());
1653 LLDB_REGISTER_METHOD(lldb::SBAddress, SBValue, GetAddress, ());
1654 LLDB_REGISTER_METHOD(lldb::SBData, SBValue, GetPointeeData,
1655 (uint32_t, uint32_t));
1656 LLDB_REGISTER_METHOD(lldb::SBData, SBValue, GetData, ());
1657 LLDB_REGISTER_METHOD(bool, SBValue, SetData,
1658 (lldb::SBData &, lldb::SBError &));
1659 LLDB_REGISTER_METHOD(lldb::SBDeclaration, SBValue, GetDeclaration, ());
1660 LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBValue, Watch,
1661 (bool, bool, bool, lldb::SBError &));
1662 LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBValue, Watch,
1663 (bool, bool, bool));
1664 LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBValue, WatchPointee,
1665 (bool, bool, bool, lldb::SBError &));
1666 LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, Persist, ());