LLDB mainline
SBValue.cpp
Go to the documentation of this file.
1//===-- SBValue.cpp -------------------------------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#include "lldb/API/SBValue.h"
11
13#include "lldb/API/SBStream.h"
18
21#include "lldb/Core/Module.h"
22#include "lldb/Core/Section.h"
23#include "lldb/Core/Value.h"
26#include "lldb/Symbol/Block.h"
28#include "lldb/Symbol/Type.h"
32#include "lldb/Target/Process.h"
34#include "lldb/Target/Target.h"
35#include "lldb/Target/Thread.h"
37#include "lldb/Utility/Scalar.h"
38#include "lldb/Utility/Stream.h"
41
42#include "lldb/API/SBDebugger.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"
49
50#include <memory>
51
52using namespace lldb;
53using namespace lldb_private;
54
55class ValueImpl {
56public:
57 ValueImpl() = default;
58
60 lldb::DynamicValueType use_dynamic, bool use_synthetic,
61 const char *name = nullptr)
62 : m_use_dynamic(use_dynamic), m_use_synthetic(use_synthetic),
63 m_name(name) {
64 if (in_valobj_sp) {
65 if ((m_valobj_sp = in_valobj_sp->GetQualifiedRepresentationIfAvailable(
66 lldb::eNoDynamicValues, false))) {
67 if (!m_name.IsEmpty())
68 m_valobj_sp->SetName(m_name);
69 }
70 }
71 }
72
73 ValueImpl(const ValueImpl &rhs) = default;
74
76 if (this != &rhs) {
80 m_name = rhs.m_name;
81 }
82 return *this;
83 }
84
85 bool IsValid() {
86 if (m_valobj_sp.get() == nullptr)
87 return false;
88 else {
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();
102 }
103 }
104
106
108 std::unique_lock<std::recursive_mutex> &lock,
109 Status &error) {
110 if (!m_valobj_sp) {
111 error = Status::FromErrorString("invalid value object");
112 return m_valobj_sp;
113 }
114
116
117 Target *target = value_sp->GetTargetSP().get();
118 // If this ValueObject holds an error, then it is valuable for that.
119 if (value_sp->GetError().Fail())
120 return value_sp;
121
122 if (!target)
123 return ValueObjectSP();
124
125 lock = std::unique_lock<std::recursive_mutex>(target->GetAPIMutex());
126
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
131 // look.
132 error = Status::FromErrorString("process must be stopped.");
133 return ValueObjectSP();
134 }
135
137 ValueObjectSP dynamic_sp = value_sp->GetDynamicValue(m_use_dynamic);
138 if (dynamic_sp)
139 value_sp = dynamic_sp;
140 }
141
142 if (m_use_synthetic) {
143 ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue();
144 if (synthetic_sp)
145 value_sp = synthetic_sp;
146 }
147
148 if (!value_sp)
149 error = Status::FromErrorString("invalid value object");
150 if (!m_name.IsEmpty())
151 value_sp->SetName(m_name);
152
153 return value_sp;
154 }
155
157 m_use_dynamic = use_dynamic;
158 }
159
160 void SetUseSynthetic(bool use_synthetic) { m_use_synthetic = use_synthetic; }
161
163
165
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.
171 if (m_valobj_sp)
172 return m_valobj_sp->GetTargetSP();
173 else
174 return TargetSP();
175 }
176
178 if (m_valobj_sp)
179 return m_valobj_sp->GetProcessSP();
180 else
181 return ProcessSP();
182 }
183
185 if (m_valobj_sp)
186 return m_valobj_sp->GetThreadSP();
187 else
188 return ThreadSP();
189 }
190
192 if (m_valobj_sp)
193 return m_valobj_sp->GetFrameSP();
194 else
195 return StackFrameSP();
196 }
197
198private:
203};
204
206public:
207 ValueLocker() = default;
208
210 return in_value.GetSP(m_stop_locker, m_lock, m_lock_error);
211 }
212
214
215private:
217 std::unique_lock<std::recursive_mutex> m_lock;
219};
220
222
224 LLDB_INSTRUMENT_VA(this, value_sp);
225
226 SetSP(value_sp);
227}
228
230 LLDB_INSTRUMENT_VA(this, rhs);
231
232 SetSP(rhs.m_opaque_sp);
233}
234
236 LLDB_INSTRUMENT_VA(this, rhs);
237
238 if (this != &rhs) {
239 SetSP(rhs.m_opaque_sp);
240 }
241 return *this;
242}
243
244SBValue::~SBValue() = default;
245
247 LLDB_INSTRUMENT_VA(this);
248 return this->operator bool();
249}
250SBValue::operator bool() const {
251 LLDB_INSTRUMENT_VA(this);
252
253 // If this function ever changes to anything that does more than just check
254 // if the opaque shared pointer is non NULL, then we need to update all "if
255 // (m_opaque_sp)" code in this file.
256 return m_opaque_sp.get() != nullptr && m_opaque_sp->IsValid() &&
257 m_opaque_sp->GetRootSP().get() != nullptr;
258}
259
261 LLDB_INSTRUMENT_VA(this);
262
263 m_opaque_sp.reset();
264}
265
267 LLDB_INSTRUMENT_VA(this);
268
269 SBError sb_error;
270
271 ValueLocker locker;
272 lldb::ValueObjectSP value_sp(GetSP(locker));
273 if (value_sp)
274 sb_error.SetError(value_sp->GetError().Clone());
275 else
276 sb_error = Status::FromErrorStringWithFormat("error: %s",
277 locker.GetError().AsCString());
278
279 return sb_error;
280}
281
283 LLDB_INSTRUMENT_VA(this);
284
285 ValueLocker locker;
286 lldb::ValueObjectSP value_sp(GetSP(locker));
287 if (value_sp)
288 return value_sp->GetID();
289 return LLDB_INVALID_UID;
290}
291
292const char *SBValue::GetName() {
293 LLDB_INSTRUMENT_VA(this);
294
295 ValueLocker locker;
296 lldb::ValueObjectSP value_sp(GetSP(locker));
297 if (!value_sp)
298 return nullptr;
299
300 return value_sp->GetName().GetCString();
301}
302
303const char *SBValue::GetTypeName() {
304 LLDB_INSTRUMENT_VA(this);
305
306 ValueLocker locker;
307 lldb::ValueObjectSP value_sp(GetSP(locker));
308 if (!value_sp)
309 return nullptr;
310
311 return value_sp->GetQualifiedTypeName().GetCString();
312}
313
315 LLDB_INSTRUMENT_VA(this);
316
317 ValueLocker locker;
318 lldb::ValueObjectSP value_sp(GetSP(locker));
319 if (!value_sp)
320 return nullptr;
321
322 return value_sp->GetDisplayTypeName().GetCString();
323}
324
326 LLDB_INSTRUMENT_VA(this);
327
328 size_t result = 0;
329
330 ValueLocker locker;
331 lldb::ValueObjectSP value_sp(GetSP(locker));
332 if (value_sp) {
333 result = llvm::expectedToOptional(value_sp->GetByteSize()).value_or(0);
334 }
335
336 return result;
337}
338
340 LLDB_INSTRUMENT_VA(this);
341
342 bool result = false;
343
344 ValueLocker locker;
345 lldb::ValueObjectSP value_sp(GetSP(locker));
346 if (value_sp) {
347 result = value_sp->IsInScope();
348 }
349
350 return result;
351}
352
353const char *SBValue::GetValue() {
354 LLDB_INSTRUMENT_VA(this);
355
356 ValueLocker locker;
357 lldb::ValueObjectSP value_sp(GetSP(locker));
358 if (!value_sp)
359 return nullptr;
360 return ConstString(value_sp->GetValueAsCString()).GetCString();
361}
362
364 LLDB_INSTRUMENT_VA(this);
365
367 ValueLocker locker;
368 lldb::ValueObjectSP value_sp(GetSP(locker));
369 if (value_sp)
370 result = value_sp->GetValueType();
371
372 return result;
373}
374
376 LLDB_INSTRUMENT_VA(this);
377
378 ValueLocker locker;
379 lldb::ValueObjectSP value_sp(GetSP(locker));
380 if (!value_sp)
381 return nullptr;
382
383 llvm::Expected<std::string> str = value_sp->GetObjectDescription();
384 if (!str) {
385 llvm::consumeError(str.takeError());
386 return nullptr;
387 }
388 return ConstString(*str).AsCString();
389}
390
392 LLDB_INSTRUMENT_VA(this);
393
394 SBType sb_type;
395 ValueLocker locker;
396 lldb::ValueObjectSP value_sp(GetSP(locker));
397 TypeImplSP type_sp;
398 if (value_sp) {
399 type_sp = std::make_shared<TypeImpl>(value_sp->GetTypeImpl());
400 sb_type.SetSP(type_sp);
401 }
402
403 return sb_type;
404}
405
407 LLDB_INSTRUMENT_VA(this);
408
409 bool result = false;
410 ValueLocker locker;
411 lldb::ValueObjectSP value_sp(GetSP(locker));
412 if (value_sp) {
413 if (value_sp->UpdateValueIfNeeded(false))
414 result = value_sp->GetValueDidChange();
415 }
416
417 return result;
418}
419
420const char *SBValue::GetSummary() {
421 LLDB_INSTRUMENT_VA(this);
422
423 ValueLocker locker;
424 lldb::ValueObjectSP value_sp(GetSP(locker));
425 if (!value_sp)
426 return nullptr;
427
428 return ConstString(value_sp->GetSummaryAsCString()).GetCString();
429}
430
433 LLDB_INSTRUMENT_VA(this, stream, options);
434
435 ValueLocker locker;
436 lldb::ValueObjectSP value_sp(GetSP(locker));
437 if (value_sp) {
438 std::string buffer;
439 if (value_sp->GetSummaryAsCString(buffer, options.ref()) && !buffer.empty())
440 stream.Printf("%s", buffer.c_str());
441 }
442 return ConstString(stream.GetData()).GetCString();
443}
444
445const char *SBValue::GetLocation() {
446 LLDB_INSTRUMENT_VA(this);
447
448 ValueLocker locker;
449 lldb::ValueObjectSP value_sp(GetSP(locker));
450 if (!value_sp)
451 return nullptr;
452
453 return ConstString(value_sp->GetLocationAsCString()).GetCString();
454}
455
456// Deprecated - use the one that takes an lldb::SBError
457bool SBValue::SetValueFromCString(const char *value_str) {
458 LLDB_INSTRUMENT_VA(this, value_str);
459
460 lldb::SBError dummy;
461 return SetValueFromCString(value_str, dummy);
462}
463
464bool SBValue::SetValueFromCString(const char *value_str, lldb::SBError &error) {
465 LLDB_INSTRUMENT_VA(this, value_str, error);
466
467 bool success = false;
468 ValueLocker locker;
469 lldb::ValueObjectSP value_sp(GetSP(locker));
470 if (value_sp) {
471 success = value_sp->SetValueFromCString(value_str, error.ref());
472 } else
473 error = Status::FromErrorStringWithFormat("Could not get value: %s",
474 locker.GetError().AsCString());
475
476 return success;
477}
478
480 LLDB_INSTRUMENT_VA(this);
481
482 lldb::SBTypeFormat format;
483 ValueLocker locker;
484 lldb::ValueObjectSP value_sp(GetSP(locker));
485 if (value_sp) {
486 if (value_sp->UpdateValueIfNeeded(true)) {
487 lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
488 if (format_sp)
489 format.SetSP(format_sp);
490 }
491 }
492 return format;
493}
494
496 LLDB_INSTRUMENT_VA(this);
497
498 lldb::SBTypeSummary summary;
499 ValueLocker locker;
500 lldb::ValueObjectSP value_sp(GetSP(locker));
501 if (value_sp) {
502 if (value_sp->UpdateValueIfNeeded(true)) {
503 lldb::TypeSummaryImplSP summary_sp = value_sp->GetSummaryFormat();
504 if (summary_sp)
505 summary.SetSP(summary_sp);
506 }
507 }
508 return summary;
509}
510
512 LLDB_INSTRUMENT_VA(this);
513
514 lldb::SBTypeFilter filter;
515 ValueLocker locker;
516 lldb::ValueObjectSP value_sp(GetSP(locker));
517 if (value_sp) {
518 if (value_sp->UpdateValueIfNeeded(true)) {
519 lldb::SyntheticChildrenSP synthetic_sp = value_sp->GetSyntheticChildren();
520
521 if (synthetic_sp && !synthetic_sp->IsScripted()) {
522 TypeFilterImplSP filter_sp =
523 std::static_pointer_cast<TypeFilterImpl>(synthetic_sp);
524 filter.SetSP(filter_sp);
525 }
526 }
527 }
528 return filter;
529}
530
532 LLDB_INSTRUMENT_VA(this);
533
534 lldb::SBTypeSynthetic synthetic;
535 ValueLocker locker;
536 lldb::ValueObjectSP value_sp(GetSP(locker));
537 if (value_sp) {
538 if (value_sp->UpdateValueIfNeeded(true)) {
539 lldb::SyntheticChildrenSP children_sp = value_sp->GetSyntheticChildren();
540
541 if (children_sp && children_sp->IsScripted()) {
543 std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
544 synthetic.SetSP(synth_sp);
545 }
546 }
547 }
548 return synthetic;
549}
550
551lldb::SBValue SBValue::CreateChildAtOffset(const char *name, uint32_t offset,
552 SBType type) {
553 LLDB_INSTRUMENT_VA(this, name, offset, type);
554
555 lldb::SBValue sb_value;
556 ValueLocker locker;
557 lldb::ValueObjectSP value_sp(GetSP(locker));
558 lldb::ValueObjectSP new_value_sp;
559 if (value_sp) {
560 TypeImplSP type_sp(type.GetSP());
561 if (type.IsValid()) {
562 sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(
563 offset, type_sp->GetCompilerType(false), true),
565 }
566 }
567 return sb_value;
568}
569
571 LLDB_INSTRUMENT_VA(this, type);
572
573 lldb::SBValue sb_value;
574 ValueLocker locker;
575 lldb::ValueObjectSP value_sp(GetSP(locker));
576 TypeImplSP type_sp(type.GetSP());
577 if (value_sp && type_sp)
578 sb_value.SetSP(value_sp->Cast(type_sp->GetCompilerType(false)),
580 return sb_value;
581}
582
584 const char *expression) {
585 LLDB_INSTRUMENT_VA(this, name, expression);
586
587 SBExpressionOptions options;
588 options.ref().SetKeepInMemory(true);
589 return CreateValueFromExpression(name, expression, options);
590}
591
593 const char *expression,
594 SBExpressionOptions &options) {
595 LLDB_INSTRUMENT_VA(this, name, expression, options);
596
597 lldb::SBValue sb_value;
598 ValueLocker locker;
599 lldb::ValueObjectSP value_sp(GetSP(locker));
600 lldb::ValueObjectSP new_value_sp;
601 if (value_sp) {
602 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
604 name, expression, exe_ctx, options.ref());
605 if (new_value_sp)
606 new_value_sp->SetName(ConstString(name));
607 }
608 sb_value.SetSP(new_value_sp);
609 return sb_value;
610}
611
613 lldb::addr_t address,
614 SBType sb_type) {
615 LLDB_INSTRUMENT_VA(this, name, address, sb_type);
616
617 lldb::SBValue sb_value;
618 ValueLocker locker;
619 lldb::ValueObjectSP value_sp(GetSP(locker));
620 lldb::ValueObjectSP new_value_sp;
621 lldb::TypeImplSP type_impl_sp(sb_type.GetSP());
622 if (value_sp && type_impl_sp) {
623 CompilerType ast_type(type_impl_sp->GetCompilerType(true));
624 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
625 new_value_sp = ValueObject::CreateValueObjectFromAddress(name, address,
626 exe_ctx, ast_type);
627 }
628 sb_value.SetSP(new_value_sp);
629 return sb_value;
630}
631
633 SBType sb_type) {
634 LLDB_INSTRUMENT_VA(this, name, data, sb_type);
635
636 lldb::SBValue sb_value;
637 lldb::ValueObjectSP new_value_sp;
638 ValueLocker locker;
639 lldb::ValueObjectSP value_sp(GetSP(locker));
640 lldb::TypeImplSP type_impl_sp(sb_type.GetSP());
641 if (value_sp && type_impl_sp) {
642 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
644 name, **data, exe_ctx, type_impl_sp->GetCompilerType(true));
645 new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
646 }
647 sb_value.SetSP(new_value_sp);
648 return sb_value;
649}
650
651lldb::SBValue SBValue::CreateBoolValue(const char *name, bool value) {
652 LLDB_INSTRUMENT_VA(this, name);
653
654 lldb::SBValue sb_value;
655 lldb::ValueObjectSP new_value_sp;
656 ValueLocker locker;
657 lldb::ValueObjectSP value_sp(GetSP(locker));
658 lldb::TargetSP target_sp = m_opaque_sp->GetTargetSP();
659 if (value_sp && target_sp) {
660 new_value_sp =
661 ValueObject::CreateValueObjectFromBool(target_sp, value, name);
662 }
663 sb_value.SetSP(new_value_sp);
664 return sb_value;
665}
666
668 LLDB_INSTRUMENT_VA(this, idx);
669
671 TargetSP target_sp;
672 if (m_opaque_sp)
673 target_sp = m_opaque_sp->GetTargetSP();
674
675 if (target_sp)
676 use_dynamic = target_sp->GetPreferDynamicValue();
677
678 return GetChildAtIndex(idx, use_dynamic, /*treat_as_array=*/false);
679}
680
682 lldb::DynamicValueType use_dynamic,
683 bool treat_as_array) {
684 LLDB_INSTRUMENT_VA(this, idx, use_dynamic, treat_as_array);
685 ValueLocker locker;
686 lldb::ValueObjectSP value_sp(GetSP(locker));
687
688 lldb::ValueObjectSP child_sp;
689 if (value_sp) {
690 const bool can_create = true;
691 if (treat_as_array &&
692 (value_sp->IsPointerType() || value_sp->IsArrayType()))
693 child_sp = value_sp->GetSyntheticArrayMember(idx, can_create);
694 else
695 child_sp = value_sp->GetChildAtIndex(idx);
696 }
697
698 SBValue sb_value;
699 sb_value.SetSP(child_sp, use_dynamic, GetPreferSyntheticValue());
700
701 return sb_value;
702}
703
704uint32_t SBValue::GetIndexOfChildWithName(const char *name) {
705 LLDB_INSTRUMENT_VA(this, name);
706
707 ValueLocker locker;
708 lldb::ValueObjectSP value_sp(GetSP(locker));
709 if (value_sp) {
710 if (auto idx_or_err = value_sp->GetIndexOfChildWithName(name))
711 return *idx_or_err;
712 else
713 llvm::consumeError(idx_or_err.takeError());
714 }
715 return UINT32_MAX;
716}
717
719 LLDB_INSTRUMENT_VA(this, name);
720
721 lldb::DynamicValueType use_dynamic_value = eNoDynamicValues;
722 TargetSP target_sp;
723 if (m_opaque_sp)
724 target_sp = m_opaque_sp->GetTargetSP();
725
726 if (target_sp)
727 use_dynamic_value = target_sp->GetPreferDynamicValue();
728 return GetChildMemberWithName(name, use_dynamic_value);
729}
730
733 lldb::DynamicValueType use_dynamic_value) {
734 LLDB_INSTRUMENT_VA(this, name, use_dynamic_value);
735
736 lldb::ValueObjectSP child_sp;
737
738 ValueLocker locker;
739 lldb::ValueObjectSP value_sp(GetSP(locker));
740 if (value_sp) {
741 child_sp = value_sp->GetChildMemberWithName(name);
742 }
743
744 SBValue sb_value;
745 sb_value.SetSP(child_sp, use_dynamic_value, GetPreferSyntheticValue());
746
747 return sb_value;
748}
749
751 LLDB_INSTRUMENT_VA(this, use_dynamic);
752
753 SBValue value_sb;
754 if (IsValid()) {
755 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), use_dynamic,
756 m_opaque_sp->GetUseSynthetic()));
757 value_sb.SetSP(proxy_sp);
758 }
759 return value_sb;
760}
761
763 LLDB_INSTRUMENT_VA(this);
764
765 SBValue value_sb;
766 if (IsValid()) {
767 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
769 m_opaque_sp->GetUseSynthetic()));
770 value_sb.SetSP(proxy_sp);
771 }
772 return value_sb;
773}
774
776 LLDB_INSTRUMENT_VA(this);
777
778 SBValue value_sb;
779 if (IsValid()) {
780 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
781 m_opaque_sp->GetUseDynamic(), false));
782 value_sb.SetSP(proxy_sp);
783 }
784 return value_sb;
785}
786
788 LLDB_INSTRUMENT_VA(this);
789
790 SBValue value_sb;
791 if (IsValid()) {
792 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
793 m_opaque_sp->GetUseDynamic(), true));
794 value_sb.SetSP(proxy_sp);
795 if (!value_sb.IsSynthetic()) {
796 return {};
797 }
798 }
799 return value_sb;
800}
801
803 LLDB_INSTRUMENT_VA(this);
804
805 if (!IsValid())
806 return eNoDynamicValues;
807 return m_opaque_sp->GetUseDynamic();
808}
809
811 LLDB_INSTRUMENT_VA(this, use_dynamic);
812
813 if (IsValid())
814 return m_opaque_sp->SetUseDynamic(use_dynamic);
815}
816
818 LLDB_INSTRUMENT_VA(this);
819
820 if (!IsValid())
821 return false;
822 return m_opaque_sp->GetUseSynthetic();
823}
824
825void SBValue::SetPreferSyntheticValue(bool use_synthetic) {
826 LLDB_INSTRUMENT_VA(this, use_synthetic);
827
828 if (IsValid())
829 return m_opaque_sp->SetUseSynthetic(use_synthetic);
830}
831
833 LLDB_INSTRUMENT_VA(this);
834
835 ValueLocker locker;
836 lldb::ValueObjectSP value_sp(GetSP(locker));
837 if (value_sp)
838 return value_sp->IsDynamic();
839 return false;
840}
841
843 LLDB_INSTRUMENT_VA(this);
844
845 ValueLocker locker;
846 lldb::ValueObjectSP value_sp(GetSP(locker));
847 if (value_sp)
848 return value_sp->IsSynthetic();
849 return false;
850}
851
853 LLDB_INSTRUMENT_VA(this);
854
855 ValueLocker locker;
856 lldb::ValueObjectSP value_sp(GetSP(locker));
857 if (value_sp)
858 return value_sp->IsSyntheticChildrenGenerated();
859 return false;
860}
861
863 LLDB_INSTRUMENT_VA(this, is);
864
865 ValueLocker locker;
866 lldb::ValueObjectSP value_sp(GetSP(locker));
867 if (value_sp)
868 return value_sp->SetSyntheticChildrenGenerated(is);
869}
870
872 LLDB_INSTRUMENT_VA(this, expr_path);
873
874 lldb::ValueObjectSP child_sp;
875 ValueLocker locker;
876 lldb::ValueObjectSP value_sp(GetSP(locker));
877 if (value_sp) {
878 // using default values for all the fancy options, just do it if you can
879 child_sp = value_sp->GetValueForExpressionPath(expr_path);
880 }
881
882 SBValue sb_value;
883 sb_value.SetSP(child_sp, GetPreferDynamicValue(), GetPreferSyntheticValue());
884
885 return sb_value;
886}
887
888int64_t SBValue::GetValueAsSigned(SBError &error, int64_t fail_value) {
889 LLDB_INSTRUMENT_VA(this, error, fail_value);
890
891 error.Clear();
892 ValueLocker locker;
893 lldb::ValueObjectSP value_sp(GetSP(locker));
894 if (value_sp) {
895 bool success = true;
896 uint64_t ret_val = fail_value;
897 ret_val = value_sp->GetValueAsSigned(fail_value, &success);
898 if (!success)
899 error = Status::FromErrorString("could not resolve value");
900 return ret_val;
901 } else
902 error = Status::FromErrorStringWithFormat("could not get SBValue: %s",
903 locker.GetError().AsCString());
904
905 return fail_value;
906}
907
908uint64_t SBValue::GetValueAsUnsigned(SBError &error, uint64_t fail_value) {
909 LLDB_INSTRUMENT_VA(this, error, fail_value);
910
911 error.Clear();
912 ValueLocker locker;
913 lldb::ValueObjectSP value_sp(GetSP(locker));
914 if (value_sp) {
915 bool success = true;
916 uint64_t ret_val = fail_value;
917 ret_val = value_sp->GetValueAsUnsigned(fail_value, &success);
918 if (!success)
919 error = Status::FromErrorString("could not resolve value");
920 return ret_val;
921 } else
922 error = Status::FromErrorStringWithFormat("could not get SBValue: %s",
923 locker.GetError().AsCString());
924
925 return fail_value;
926}
927
928int64_t SBValue::GetValueAsSigned(int64_t fail_value) {
929 LLDB_INSTRUMENT_VA(this, fail_value);
930
931 ValueLocker locker;
932 lldb::ValueObjectSP value_sp(GetSP(locker));
933 if (value_sp) {
934 return value_sp->GetValueAsSigned(fail_value);
935 }
936 return fail_value;
937}
938
939uint64_t SBValue::GetValueAsUnsigned(uint64_t fail_value) {
940 LLDB_INSTRUMENT_VA(this, fail_value);
941
942 ValueLocker locker;
943 lldb::ValueObjectSP value_sp(GetSP(locker));
944 if (value_sp) {
945 return value_sp->GetValueAsUnsigned(fail_value);
946 }
947 return fail_value;
948}
949
951 addr_t fail_value = LLDB_INVALID_ADDRESS;
952 ValueLocker locker;
953 lldb::ValueObjectSP value_sp(GetSP(locker));
954 if (value_sp) {
955 bool success = true;
956 uint64_t ret_val = fail_value;
957 ret_val = value_sp->GetValueAsUnsigned(fail_value, &success);
958 if (!success)
959 return fail_value;
960 ProcessSP process_sp = m_opaque_sp->GetProcessSP();
961 if (!process_sp)
962 return ret_val;
963 return process_sp->FixDataAddress(ret_val);
964 }
965
966 return fail_value;
967}
968
970 LLDB_INSTRUMENT_VA(this);
971
972 bool has_children = false;
973 ValueLocker locker;
974 lldb::ValueObjectSP value_sp(GetSP(locker));
975 if (value_sp)
976 has_children = value_sp->MightHaveChildren();
977
978 return has_children;
979}
980
982 LLDB_INSTRUMENT_VA(this);
983
984 bool is_support = false;
985 ValueLocker locker;
986 lldb::ValueObjectSP value_sp(GetSP(locker));
987 if (value_sp)
988 is_support = value_sp->IsRuntimeSupportValue();
989
990 return is_support;
991}
992
994 LLDB_INSTRUMENT_VA(this);
995
997}
998
999uint32_t SBValue::GetNumChildren(uint32_t max) {
1000 LLDB_INSTRUMENT_VA(this, max);
1001
1002 uint32_t num_children = 0;
1003
1004 ValueLocker locker;
1005 lldb::ValueObjectSP value_sp(GetSP(locker));
1006 if (value_sp)
1007 num_children = value_sp->GetNumChildrenIgnoringErrors(max);
1008
1009 return num_children;
1010}
1011
1013 LLDB_INSTRUMENT_VA(this);
1014
1015 SBValue sb_value;
1016 ValueLocker locker;
1017 lldb::ValueObjectSP value_sp(GetSP(locker));
1018 if (value_sp) {
1019 Status error;
1020 sb_value = value_sp->Dereference(error);
1021 }
1022
1023 return sb_value;
1024}
1025
1026// Deprecated - please use GetType().IsPointerType() instead.
1027bool SBValue::TypeIsPointerType() {
1028 LLDB_INSTRUMENT_VA(this);
1029
1030 return GetType().IsPointerType();
1031}
1032
1034 LLDB_INSTRUMENT_VA(this);
1035
1036 ValueLocker locker;
1037 lldb::ValueObjectSP value_sp(GetSP(locker));
1038 if (value_sp)
1039 return value_sp->GetCompilerType().GetOpaqueQualType();
1040 return nullptr;
1041}
1042
1044 LLDB_INSTRUMENT_VA(this);
1045
1046 SBTarget sb_target;
1047 TargetSP target_sp;
1048 if (m_opaque_sp) {
1049 target_sp = m_opaque_sp->GetTargetSP();
1050 sb_target.SetSP(target_sp);
1051 }
1052
1053 return sb_target;
1054}
1055
1057 LLDB_INSTRUMENT_VA(this);
1058
1059 SBProcess sb_process;
1060 ProcessSP process_sp;
1061 if (m_opaque_sp) {
1062 process_sp = m_opaque_sp->GetProcessSP();
1063 sb_process.SetSP(process_sp);
1064 }
1065
1066 return sb_process;
1067}
1068
1070 LLDB_INSTRUMENT_VA(this);
1071
1072 SBThread sb_thread;
1073 ThreadSP thread_sp;
1074 if (m_opaque_sp) {
1075 thread_sp = m_opaque_sp->GetThreadSP();
1076 sb_thread.SetThread(thread_sp);
1077 }
1078
1079 return sb_thread;
1080}
1081
1083 LLDB_INSTRUMENT_VA(this);
1084
1085 SBFrame sb_frame;
1086 StackFrameSP frame_sp;
1087 if (m_opaque_sp) {
1088 frame_sp = m_opaque_sp->GetFrameSP();
1089 sb_frame.SetFrameSP(frame_sp);
1090 }
1091
1092 return sb_frame;
1093}
1094
1096 // IsValid means that the SBValue has a value in it. But that's not the
1097 // only time that ValueObjects are useful. We also want to return the value
1098 // if there's an error state in it.
1099 if (!m_opaque_sp || (!m_opaque_sp->IsValid()
1100 && (m_opaque_sp->GetRootSP()
1101 && !m_opaque_sp->GetRootSP()->GetError().Fail()))) {
1102 locker.GetError() = Status::FromErrorString("No value");
1103 return ValueObjectSP();
1104 }
1105 return locker.GetLockedSP(*m_opaque_sp.get());
1106}
1107
1109 LLDB_INSTRUMENT_VA(this);
1110
1111 ValueLocker locker;
1112 return GetSP(locker);
1113}
1114
1115void SBValue::SetSP(ValueImplSP impl_sp) { m_opaque_sp = impl_sp; }
1116
1118 if (sp) {
1119 lldb::TargetSP target_sp(sp->GetTargetSP());
1120 if (target_sp) {
1121 lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1122 bool use_synthetic =
1123 target_sp->TargetProperties::GetEnableSyntheticValue();
1124 m_opaque_sp = std::make_shared<ValueImpl>(sp, use_dynamic, use_synthetic);
1125 } else
1126 m_opaque_sp = std::make_shared<ValueImpl>(sp, eNoDynamicValues, true);
1127 } else
1128 m_opaque_sp = std::make_shared<ValueImpl>(sp, eNoDynamicValues, false);
1129}
1130
1132 lldb::DynamicValueType use_dynamic) {
1133 if (sp) {
1134 lldb::TargetSP target_sp(sp->GetTargetSP());
1135 if (target_sp) {
1136 bool use_synthetic =
1137 target_sp->TargetProperties::GetEnableSyntheticValue();
1138 SetSP(sp, use_dynamic, use_synthetic);
1139 } else
1140 SetSP(sp, use_dynamic, true);
1141 } else
1142 SetSP(sp, use_dynamic, false);
1143}
1144
1145void SBValue::SetSP(const lldb::ValueObjectSP &sp, bool use_synthetic) {
1146 if (sp) {
1147 lldb::TargetSP target_sp(sp->GetTargetSP());
1148 if (target_sp) {
1149 lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1150 SetSP(sp, use_dynamic, use_synthetic);
1151 } else
1152 SetSP(sp, eNoDynamicValues, use_synthetic);
1153 } else
1154 SetSP(sp, eNoDynamicValues, use_synthetic);
1155}
1156
1158 lldb::DynamicValueType use_dynamic, bool use_synthetic) {
1159 m_opaque_sp = std::make_shared<ValueImpl>(sp, use_dynamic, use_synthetic);
1160}
1161
1163 lldb::DynamicValueType use_dynamic, bool use_synthetic,
1164 const char *name) {
1165 m_opaque_sp =
1166 std::make_shared<ValueImpl>(sp, use_dynamic, use_synthetic, name);
1167}
1168
1170 LLDB_INSTRUMENT_VA(this, description);
1171
1172 ValueLocker locker;
1173 lldb::ValueObjectSP value_sp(GetSP(locker));
1174 if (value_sp) {
1175 value_sp->GetExpressionPath(description.ref());
1176 return true;
1177 }
1178 return false;
1179}
1180
1182 bool qualify_cxx_base_classes) {
1183 LLDB_INSTRUMENT_VA(this, description, qualify_cxx_base_classes);
1184
1185 ValueLocker locker;
1186 lldb::ValueObjectSP value_sp(GetSP(locker));
1187 if (value_sp) {
1188 value_sp->GetExpressionPath(description.ref());
1189 return true;
1190 }
1191 return false;
1192}
1193
1195 LLDB_INSTRUMENT_VA(this, expr);
1196
1197 ValueLocker locker;
1198 lldb::ValueObjectSP value_sp(GetSP(locker));
1199 if (!value_sp)
1200 return SBValue();
1201
1202 lldb::TargetSP target_sp = value_sp->GetTargetSP();
1203 if (!target_sp)
1204 return SBValue();
1205
1207 options.SetFetchDynamicValue(target_sp->GetPreferDynamicValue());
1208 options.SetUnwindOnError(true);
1209 options.SetIgnoreBreakpoints(true);
1210
1211 return EvaluateExpression(expr, options, nullptr);
1212}
1213
1216 const SBExpressionOptions &options) const {
1217 LLDB_INSTRUMENT_VA(this, expr, options);
1218
1219 return EvaluateExpression(expr, options, nullptr);
1220}
1221
1223 const SBExpressionOptions &options,
1224 const char *name) const {
1225 LLDB_INSTRUMENT_VA(this, expr, options, name);
1226
1227 if (!expr || expr[0] == '\0') {
1228 return SBValue();
1229 }
1230
1231
1232 ValueLocker locker;
1233 lldb::ValueObjectSP value_sp(GetSP(locker));
1234 if (!value_sp) {
1235 return SBValue();
1236 }
1237
1238 lldb::TargetSP target_sp = value_sp->GetTargetSP();
1239 if (!target_sp) {
1240 return SBValue();
1241 }
1242
1243 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1244 ExecutionContext exe_ctx(target_sp.get());
1245
1246 StackFrame *frame = exe_ctx.GetFramePtr();
1247 if (!frame) {
1248 return SBValue();
1249 }
1250
1251 ValueObjectSP res_val_sp;
1252 target_sp->EvaluateExpression(expr, frame, res_val_sp, options.ref(), nullptr,
1253 value_sp.get());
1254
1255 if (name)
1256 res_val_sp->SetName(ConstString(name));
1257
1258 SBValue result;
1259 result.SetSP(res_val_sp, options.GetFetchDynamicValue());
1260 return result;
1261}
1262
1264 LLDB_INSTRUMENT_VA(this, description);
1265
1266 return GetDescription(description, eDescriptionLevelFull);
1267}
1268
1271 lldb::DynamicValueType dyn, bool use_synthetic) {
1272 DumpValueObjectOptions options;
1273 switch (description_level) {
1275 return options;
1277 options.SetAllowOnelinerMode(true);
1278 options.SetHideRootName(true);
1279 options.SetHideRootType(true);
1280 break;
1282 options.SetShowTypes(true);
1283 options.SetShowLocation(true);
1284 break;
1285 default:
1286 break;
1287 }
1288 options.SetUseDynamicType(dyn);
1289 options.SetUseSyntheticValue(use_synthetic);
1290 return options;
1291}
1292
1294 lldb::DescriptionLevel description_level) {
1295 LLDB_INSTRUMENT_VA(this, description, description_level);
1296
1297 Stream &strm = description.ref();
1298
1299 ValueLocker locker;
1300 lldb::ValueObjectSP value_sp(GetSP(locker));
1301 if (value_sp) {
1302 const DumpValueObjectOptions options =
1303 GetDumpOptions(description_level, m_opaque_sp->GetUseDynamic(),
1304 m_opaque_sp->GetUseSynthetic());
1305 if (llvm::Error error = value_sp->Dump(strm, options)) {
1306 strm << "error: " << toString(std::move(error));
1307 return false;
1308 }
1309 } else {
1310 strm.PutCString("No value");
1311 }
1312
1313 return true;
1314}
1315
1317 LLDB_INSTRUMENT_VA(this);
1318
1319 ValueLocker locker;
1320 lldb::ValueObjectSP value_sp(GetSP(locker));
1321 if (value_sp)
1322 return value_sp->GetFormat();
1323 return eFormatDefault;
1324}
1325
1327 LLDB_INSTRUMENT_VA(this, format);
1328
1329 ValueLocker locker;
1330 lldb::ValueObjectSP value_sp(GetSP(locker));
1331 if (value_sp)
1332 value_sp->SetFormat(format);
1333}
1334
1336 LLDB_INSTRUMENT_VA(this);
1337
1338 SBValue sb_value;
1339 ValueLocker locker;
1340 lldb::ValueObjectSP value_sp(GetSP(locker));
1341 if (value_sp) {
1342 Status error;
1343 sb_value.SetSP(value_sp->AddressOf(error), GetPreferDynamicValue(),
1345 }
1346
1347 return sb_value;
1348}
1349
1351 LLDB_INSTRUMENT_VA(this);
1352
1354 ValueLocker locker;
1355 lldb::ValueObjectSP value_sp(GetSP(locker));
1356 if (value_sp)
1357 return value_sp->GetLoadAddress();
1358
1359 return value;
1360}
1361
1363 LLDB_INSTRUMENT_VA(this);
1364
1365 Address addr;
1366 ValueLocker locker;
1367 lldb::ValueObjectSP value_sp(GetSP(locker));
1368 if (value_sp) {
1369 TargetSP target_sp(value_sp->GetTargetSP());
1370 if (target_sp) {
1371 auto [value, addr_type] =
1372 value_sp->GetAddressOf(/*scalar_is_load_address=*/true);
1373 if (addr_type == eAddressTypeFile) {
1374 ModuleSP module_sp(value_sp->GetModule());
1375 if (module_sp)
1376 module_sp->ResolveFileAddress(value, addr);
1377 } else if (addr_type == eAddressTypeLoad) {
1378 // no need to check the return value on this.. if it can actually do
1379 // the resolve addr will be in the form (section,offset), otherwise it
1380 // will simply be returned as (NULL, value)
1381 addr.SetLoadAddress(value, target_sp.get());
1382 }
1383 }
1384 }
1385
1386 return SBAddress(addr);
1387}
1388
1389lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) {
1390 LLDB_INSTRUMENT_VA(this, item_idx, item_count);
1391
1392 lldb::SBData sb_data;
1393 ValueLocker locker;
1394 lldb::ValueObjectSP value_sp(GetSP(locker));
1395 if (value_sp) {
1396 TargetSP target_sp(value_sp->GetTargetSP());
1397 if (target_sp) {
1398 DataExtractorSP data_sp(new DataExtractor());
1399 value_sp->GetPointeeData(*data_sp, item_idx, item_count);
1400 if (data_sp->GetByteSize() > 0)
1401 *sb_data = data_sp;
1402 }
1403 }
1404
1405 return sb_data;
1406}
1407
1409 LLDB_INSTRUMENT_VA(this);
1410
1411 lldb::SBData sb_data;
1412 ValueLocker locker;
1413 lldb::ValueObjectSP value_sp(GetSP(locker));
1414 if (value_sp) {
1415 DataExtractorSP data_sp(new DataExtractor());
1416 Status error;
1417 value_sp->GetData(*data_sp, error);
1418 if (error.Success())
1419 *sb_data = data_sp;
1420 }
1421
1422 return sb_data;
1423}
1424
1426 LLDB_INSTRUMENT_VA(this, data, error);
1427
1428 ValueLocker locker;
1429 lldb::ValueObjectSP value_sp(GetSP(locker));
1430 bool ret = true;
1431
1432 if (value_sp) {
1433 DataExtractor *data_extractor = data.get();
1434
1435 if (!data_extractor) {
1436 error = Status::FromErrorString("No data to set");
1437 ret = false;
1438 } else {
1439 Status set_error;
1440
1441 value_sp->SetData(*data_extractor, set_error);
1442
1443 if (!set_error.Success()) {
1444 error = Status::FromErrorStringWithFormat("Couldn't set data: %s",
1445 set_error.AsCString());
1446 ret = false;
1447 }
1448 }
1449 } else {
1451 "Couldn't set data: could not get SBValue: %s",
1452 locker.GetError().AsCString());
1453 ret = false;
1454 }
1455
1456 return ret;
1457}
1458
1459lldb::SBValue SBValue::Clone(const char *new_name) {
1460 LLDB_INSTRUMENT_VA(this, new_name);
1461
1462 ValueLocker locker;
1463 lldb::ValueObjectSP value_sp(GetSP(locker));
1464
1465 if (value_sp)
1466 return lldb::SBValue(value_sp->Clone(ConstString(new_name)));
1467 else
1468 return lldb::SBValue();
1469}
1470
1472 LLDB_INSTRUMENT_VA(this);
1473
1474 ValueLocker locker;
1475 lldb::ValueObjectSP value_sp(GetSP(locker));
1476 SBDeclaration decl_sb;
1477 if (value_sp) {
1478 Declaration decl;
1479 if (value_sp->GetDeclaration(decl))
1480 decl_sb.SetDeclaration(decl);
1481 }
1482 return decl_sb;
1483}
1484
1485lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write,
1486 SBError &error) {
1487 LLDB_INSTRUMENT_VA(this, resolve_location, read, write, error);
1488
1489 SBWatchpoint sb_watchpoint;
1490
1491 // If the SBValue is not valid, there's no point in even trying to watch it.
1492 ValueLocker locker;
1493 lldb::ValueObjectSP value_sp(GetSP(locker));
1494 TargetSP target_sp(GetTarget().GetSP());
1495 if (value_sp && target_sp) {
1496 // Read and Write cannot both be false.
1497 if (!read && !write)
1498 return sb_watchpoint;
1499
1500 // If the value is not in scope, don't try and watch and invalid value
1501 if (!IsInScope())
1502 return sb_watchpoint;
1503
1504 addr_t addr = GetLoadAddress();
1505 if (addr == LLDB_INVALID_ADDRESS)
1506 return sb_watchpoint;
1507 size_t byte_size = GetByteSize();
1508 if (byte_size == 0)
1509 return sb_watchpoint;
1510
1511 uint32_t watch_type = 0;
1512 if (read) {
1513 watch_type |= LLDB_WATCH_TYPE_READ;
1514 // read + write, the most likely intention
1515 // is to catch all writes to this, not just
1516 // value modifications.
1517 if (write)
1518 watch_type |= LLDB_WATCH_TYPE_WRITE;
1519 } else {
1520 if (write)
1521 watch_type |= LLDB_WATCH_TYPE_MODIFY;
1522 }
1523
1524 Status rc;
1525 CompilerType type(value_sp->GetCompilerType());
1526 WatchpointSP watchpoint_sp =
1527 target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc);
1528 error.SetError(std::move(rc));
1529
1530 if (watchpoint_sp) {
1531 sb_watchpoint.SetSP(watchpoint_sp);
1532 Declaration decl;
1533 if (value_sp->GetDeclaration(decl)) {
1534 if (decl.GetFile()) {
1535 StreamString ss;
1536 // True to show fullpath for declaration file.
1537 decl.DumpStopContext(&ss, true);
1538 watchpoint_sp->SetDeclInfo(std::string(ss.GetString()));
1539 }
1540 }
1541 }
1542 } else if (target_sp) {
1543 error = Status::FromErrorStringWithFormat("could not get SBValue: %s",
1544 locker.GetError().AsCString());
1545 } else {
1547 "could not set watchpoint, a target is required");
1548 }
1549
1550 return sb_watchpoint;
1551}
1552
1553// FIXME: Remove this method impl (as well as the decl in .h) once it is no
1554// longer needed.
1555// Backward compatibility fix in the interim.
1556lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read,
1557 bool write) {
1558 LLDB_INSTRUMENT_VA(this, resolve_location, read, write);
1559
1560 SBError error;
1561 return Watch(resolve_location, read, write, error);
1562}
1563
1564lldb::SBWatchpoint SBValue::WatchPointee(bool resolve_location, bool read,
1565 bool write, SBError &error) {
1566 LLDB_INSTRUMENT_VA(this, resolve_location, read, write, error);
1567
1568 SBWatchpoint sb_watchpoint;
1569 if (IsInScope() && GetType().IsPointerType())
1570 sb_watchpoint = Dereference().Watch(resolve_location, read, write, error);
1571 return sb_watchpoint;
1572}
1573
1575 LLDB_INSTRUMENT_VA(this);
1576
1577 ValueLocker locker;
1578 lldb::ValueObjectSP value_sp(GetSP(locker));
1579 SBValue persisted_sb;
1580 if (value_sp) {
1581 persisted_sb.SetSP(value_sp->Persist());
1582 }
1583 return persisted_sb;
1584}
1585
1587 SBValue vtable_sb;
1588 ValueLocker locker;
1589 lldb::ValueObjectSP value_sp(GetSP(locker));
1590 if (!value_sp)
1591 return vtable_sb;
1592
1593 vtable_sb.SetSP(value_sp->GetVTable());
1594 return vtable_sb;
1595}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_INSTRUMENT_VA(...)
static DumpValueObjectOptions GetDumpOptions(lldb::DescriptionLevel description_level, lldb::DynamicValueType dyn, bool use_synthetic)
Definition SBValue.cpp:1270
StackFrameSP GetFrameSP()
Definition SBValue.cpp:191
TargetSP GetTargetSP()
Definition SBValue.cpp:170
lldb::DynamicValueType m_use_dynamic
Definition SBValue.cpp:200
lldb::ValueObjectSP GetRootSP()
Definition SBValue.cpp:105
void SetUseSynthetic(bool use_synthetic)
Definition SBValue.cpp:160
ValueImpl()=default
ThreadSP GetThreadSP()
Definition SBValue.cpp:184
bool IsValid()
Definition SBValue.cpp:85
ProcessSP GetProcessSP()
Definition SBValue.cpp:177
ValueImpl(const ValueImpl &rhs)=default
ValueImpl(lldb::ValueObjectSP in_valobj_sp, lldb::DynamicValueType use_dynamic, bool use_synthetic, const char *name=nullptr)
Definition SBValue.cpp:59
lldb::ValueObjectSP GetSP(Process::StopLocker &stop_locker, std::unique_lock< std::recursive_mutex > &lock, Status &error)
Definition SBValue.cpp:107
bool GetUseSynthetic()
Definition SBValue.cpp:164
ValueImpl & operator=(const ValueImpl &rhs)
Definition SBValue.cpp:75
lldb::DynamicValueType GetUseDynamic()
Definition SBValue.cpp:162
void SetUseDynamic(lldb::DynamicValueType use_dynamic)
Definition SBValue.cpp:156
ConstString m_name
Definition SBValue.cpp:202
lldb::ValueObjectSP m_valobj_sp
Definition SBValue.cpp:199
bool m_use_synthetic
Definition SBValue.cpp:201
ValueLocker()=default
Status & GetError()
Definition SBValue.cpp:213
ValueObjectSP GetLockedSP(ValueImpl &in_value)
Definition SBValue.cpp:209
Status m_lock_error
Definition SBValue.cpp:218
Process::StopLocker m_stop_locker
Definition SBValue.cpp:216
std::unique_lock< std::recursive_mutex > m_lock
Definition SBValue.cpp:217
lldb_private::DataExtractor * get() const
Definition SBData.cpp:49
void SetDeclaration(const lldb_private::Declaration &lldb_object_ref)
void SetError(uint32_t err, lldb::ErrorType type)
Definition SBError.cpp:124
void SetFetchDynamicValue(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
lldb_private::EvaluateExpressionOptions & ref() const
void SetIgnoreBreakpoints(bool ignore=true)
void SetUnwindOnError(bool unwind=true)
lldb::DynamicValueType GetFetchDynamicValue() const
void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp)
Definition SBFrame.cpp:90
void SetSP(const lldb::ProcessSP &process_sp)
lldb_private::Stream & ref()
Definition SBStream.cpp:178
const char * GetData()
Definition SBStream.cpp:44
void SetSP(const lldb::TargetSP &target_sp)
Definition SBTarget.cpp:591
void SetThread(const lldb::ThreadSP &lldb_object_sp)
Definition SBThread.cpp:315
void SetSP(const lldb::TypeFilterImplSP &typefilter_impl_sp)
void SetSP(const lldb::TypeFormatImplSP &typeformat_impl_sp)
lldb_private::TypeSummaryOptions & ref()
void SetSP(const lldb::TypeSummaryImplSP &typefilter_impl_sp)
void SetSP(const lldb::ScriptedSyntheticChildrenSP &typefilter_impl_sp)
lldb::TypeImplSP GetSP()
Definition SBType.cpp:82
bool IsPointerType()
Definition SBType.cpp:148
void SetSP(const lldb::TypeImplSP &type_impl_sp)
Definition SBType.cpp:84
bool IsValid() const
Definition SBType.cpp:113
lldb::addr_t GetValueAsAddress()
Definition SBValue.cpp:950
bool IsInScope()
Definition SBValue.cpp:339
bool SetData(lldb::SBData &data, lldb::SBError &error)
Definition SBValue.cpp:1425
bool GetDescription(lldb::SBStream &description)
Definition SBValue.cpp:1263
bool GetValueDidChange()
Definition SBValue.cpp:406
lldb::SBValue EvaluateExpression(const char *expr) const
Definition SBValue.cpp:1194
lldb::SBValue GetChildAtIndex(uint32_t idx)
Definition SBValue.cpp:667
lldb::SBTypeFilter GetTypeFilter()
Definition SBValue.cpp:511
lldb::SBAddress GetAddress()
Definition SBValue.cpp:1362
lldb::SBData GetPointeeData(uint32_t item_idx=0, uint32_t item_count=1)
Get an SBData wrapping what this SBValue points to.
Definition SBValue.cpp:1389
const char * GetTypeName()
Definition SBValue.cpp:303
bool GetExpressionPath(lldb::SBStream &description)
Definition SBValue.cpp:1169
SBError GetError()
Definition SBValue.cpp:266
lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data, lldb::SBType type)
Definition SBValue.cpp:632
lldb::SBValue Persist()
Definition SBValue.cpp:1574
void SetSP(const lldb::ValueObjectSP &sp)
Definition SBValue.cpp:1117
lldb::SBValue CreateValueFromAddress(const char *name, lldb::addr_t address, lldb::SBType type)
Definition SBValue.cpp:612
const char * GetDisplayTypeName()
Definition SBValue.cpp:314
lldb::SBValue CreateValueFromExpression(const char *name, const char *expression)
Definition SBValue.cpp:583
lldb::SBData GetData()
Get an SBData wrapping the contents of this SBValue.
Definition SBValue.cpp:1408
lldb::SBValue Clone(const char *new_name)
Creates a copy of the SBValue with a new name and setting the current SBValue as its parent.
Definition SBValue.cpp:1459
void SetSyntheticChildrenGenerated(bool)
Definition SBValue.cpp:862
lldb::SBProcess GetProcess()
Definition SBValue.cpp:1056
const char * GetLocation()
Definition SBValue.cpp:445
lldb::SBValue CreateBoolValue(const char *name, bool value)
Definition SBValue.cpp:651
bool IsSynthetic()
Definition SBValue.cpp:842
friend class SBTarget
Definition SBValue.h:446
size_t GetByteSize()
Definition SBValue.cpp:325
lldb::SBValue & operator=(const lldb::SBValue &rhs)
Definition SBValue.cpp:235
int64_t GetValueAsSigned(lldb::SBError &error, int64_t fail_value=0)
Definition SBValue.cpp:888
lldb::SBWatchpoint WatchPointee(bool resolve_location, bool read, bool write, SBError &error)
Watch this value that this value points to in memory.
Definition SBValue.cpp:1564
lldb::SBWatchpoint Watch(bool resolve_location, bool read, bool write, SBError &error)
Watch this value if it resides in memory.
Definition SBValue.cpp:1485
lldb::SBTypeFormat GetTypeFormat()
Definition SBValue.cpp:479
lldb::user_id_t GetID()
Definition SBValue.cpp:282
lldb::SBFrame GetFrame()
Definition SBValue.cpp:1082
const char * GetValue()
Definition SBValue.cpp:353
bool MightHaveChildren()
Find out if a SBValue might have children.
Definition SBValue.cpp:969
lldb::SBTypeSummary GetTypeSummary()
Definition SBValue.cpp:495
lldb::SBValue GetDynamicValue(lldb::DynamicValueType use_dynamic)
Definition SBValue.cpp:750
bool IsDynamic()
Definition SBValue.cpp:832
bool IsSyntheticChildrenGenerated()
Definition SBValue.cpp:852
const char * GetName()
Definition SBValue.cpp:292
lldb::SBValue GetSyntheticValue()
Definition SBValue.cpp:787
lldb::SBValue CreateChildAtOffset(const char *name, uint32_t offset, lldb::SBType type)
Definition SBValue.cpp:551
lldb::SBValue Dereference()
Definition SBValue.cpp:1012
std::shared_ptr< ValueImpl > ValueImplSP
Definition SBValue.h:510
lldb::SBValue GetStaticValue()
Definition SBValue.cpp:762
lldb::SBValue Cast(lldb::SBType type)
Definition SBValue.cpp:570
friend class SBThread
Definition SBValue.h:447
lldb::SBValue GetNonSyntheticValue()
Definition SBValue.cpp:775
bool GetPreferSyntheticValue()
Definition SBValue.cpp:817
uint32_t GetIndexOfChildWithName(const char *name)
Definition SBValue.cpp:704
lldb::SBValue GetVTable()
If this value represents a C++ class that has a vtable, return an value that represents the virtual f...
Definition SBValue.cpp:1586
const char * GetObjectDescription()
Definition SBValue.cpp:375
const char * GetSummary()
Definition SBValue.cpp:420
lldb::ValueObjectSP GetSP() const
Same as the protected version of GetSP that takes a locker, except that we make the locker locally in...
Definition SBValue.cpp:1108
lldb::SBTypeSynthetic GetTypeSynthetic()
Definition SBValue.cpp:531
void SetFormat(lldb::Format format)
Definition SBValue.cpp:1326
lldb::SBValue AddressOf()
Definition SBValue.cpp:1335
friend class SBFrame
Definition SBValue.h:444
bool SetValueFromCString(const char *value_str, lldb::SBError &error)
Definition SBValue.cpp:457
lldb::DynamicValueType GetPreferDynamicValue()
Definition SBValue.cpp:802
lldb::SBThread GetThread()
Definition SBValue.cpp:1069
ValueImplSP m_opaque_sp
Definition SBValue.h:511
lldb::SBValue GetChildMemberWithName(const char *name)
Definition SBValue.cpp:718
lldb::SBTarget GetTarget()
Definition SBValue.cpp:1043
uint64_t GetValueAsUnsigned(lldb::SBError &error, uint64_t fail_value=0)
Definition SBValue.cpp:908
uint32_t GetNumChildren()
Return the number of children of this variable.
Definition SBValue.cpp:993
void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic)
Definition SBValue.cpp:810
ValueType GetValueType()
Definition SBValue.cpp:363
void * GetOpaqueType()
Definition SBValue.cpp:1033
friend class SBType
Definition SBValue.h:448
bool IsValid()
Definition SBValue.cpp:246
lldb::SBValue GetValueForExpressionPath(const char *expr_path)
Definition SBValue.cpp:871
lldb::addr_t GetLoadAddress()
Definition SBValue.cpp:1350
lldb::SBType GetType()
Definition SBValue.cpp:391
void SetPreferSyntheticValue(bool use_synthetic)
Definition SBValue.cpp:825
lldb::SBDeclaration GetDeclaration()
Definition SBValue.cpp:1471
lldb::Format GetFormat()
Definition SBValue.cpp:1316
bool IsRuntimeSupportValue()
Definition SBValue.cpp:981
void SetSP(const lldb::WatchpointSP &sp)
A section + offset based address class.
Definition Address.h:62
bool SetLoadAddress(lldb::addr_t load_addr, Target *target, bool allow_section_end=false)
Set the address to represent load_addr.
Definition Address.cpp:1035
Generic representation of a type in a programming language.
A uniqued constant string class.
Definition ConstString.h:40
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
const char * GetCString() const
Get the string value as a C string.
An data extractor class.
A class that describes the declaration location of a lldb object.
Definition Declaration.h:24
bool DumpStopContext(Stream *s, bool show_fullpaths) const
FileSpec & GetFile()
Get accessor for file specification.
DumpValueObjectOptions & SetShowTypes(bool show=false)
DumpValueObjectOptions & SetHideRootType(bool hide_root_type=false)
DumpValueObjectOptions & SetUseSyntheticValue(bool use_synthetic=true)
DumpValueObjectOptions & SetHideRootName(bool hide_root_name)
DumpValueObjectOptions & SetUseDynamicType(lldb::DynamicValueType dyn=lldb::eNoDynamicValues)
DumpValueObjectOptions & SetAllowOnelinerMode(bool oneliner=false)
DumpValueObjectOptions & SetShowLocation(bool show=false)
void SetKeepInMemory(bool keep=true)
Definition Target.h:382
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
ProcessRunLock::ProcessRunLocker StopLocker
Definition Process.h:393
This base class provides an interface to stack frames.
Definition StackFrame.h:44
An error handling class.
Definition Status.h:118
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition Status.cpp:106
static Status FromErrorString(const char *str)
Definition Status.h:141
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition Status.cpp:195
bool Success() const
Test for success condition.
Definition Status.cpp:304
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
Definition Stream.h:28
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition Stream.cpp:65
std::recursive_mutex & GetAPIMutex()
Definition Target.cpp:5318
static lldb::ValueObjectSP CreateValueObjectFromBool(lldb::TargetSP target, bool value, llvm::StringRef name)
Create a value object containing the given boolean value.
static lldb::ValueObjectSP CreateValueObjectFromExpression(llvm::StringRef name, llvm::StringRef expression, const ExecutionContext &exe_ctx)
static lldb::ValueObjectSP CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type, bool do_deref=true)
Given an address either create a value object containing the value at that address,...
static lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type)
#define LLDB_WATCH_TYPE_WRITE
#define LLDB_INVALID_UID
#define LLDB_WATCH_TYPE_MODIFY
#define LLDB_WATCH_TYPE_READ
#define LLDB_INVALID_ADDRESS
#define UINT32_MAX
A class that represents a running process on the host machine.
@ eAddressTypeFile
Address is an address as found in an object or symbol file.
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
const char * toString(AppleArm64ExceptionClass EC)
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::TypeSummaryImpl > TypeSummaryImplSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelBrief
@ eDescriptionLevelInitial
@ eDescriptionLevelFull
@ eDescriptionLevelVerbose
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::TypeFormatImpl > TypeFormatImplSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Format
Display format definitions.
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
class LLDB_API SBAddress
Definition SBDefines.h:45
std::shared_ptr< lldb_private::SyntheticChildren > SyntheticChildrenSP
uint64_t user_id_t
Definition lldb-types.h:82
std::shared_ptr< lldb_private::ScriptedSyntheticChildren > ScriptedSyntheticChildrenSP
std::shared_ptr< lldb_private::TypeFilterImpl > TypeFilterImplSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::TypeImpl > TypeImplSP
std::shared_ptr< lldb_private::Target > TargetSP
class LLDB_API SBValue
Definition SBDefines.h:135
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::Module > ModuleSP