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