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 return ConstString(value_sp->GetObjectDescription()).GetCString();
383}
384
386 LLDB_INSTRUMENT_VA(this);
387
388 SBType sb_type;
389 ValueLocker locker;
390 lldb::ValueObjectSP value_sp(GetSP(locker));
391 TypeImplSP type_sp;
392 if (value_sp) {
393 type_sp = std::make_shared<TypeImpl>(value_sp->GetTypeImpl());
394 sb_type.SetSP(type_sp);
395 }
396
397 return sb_type;
398}
399
401 LLDB_INSTRUMENT_VA(this);
402
403 bool result = false;
404 ValueLocker locker;
405 lldb::ValueObjectSP value_sp(GetSP(locker));
406 if (value_sp) {
407 if (value_sp->UpdateValueIfNeeded(false))
408 result = value_sp->GetValueDidChange();
409 }
410
411 return result;
412}
413
414const char *SBValue::GetSummary() {
415 LLDB_INSTRUMENT_VA(this);
416
417 ValueLocker locker;
418 lldb::ValueObjectSP value_sp(GetSP(locker));
419 if (!value_sp)
420 return nullptr;
421
422 return ConstString(value_sp->GetSummaryAsCString()).GetCString();
423}
424
427 LLDB_INSTRUMENT_VA(this, stream, options);
428
429 ValueLocker locker;
430 lldb::ValueObjectSP value_sp(GetSP(locker));
431 if (value_sp) {
432 std::string buffer;
433 if (value_sp->GetSummaryAsCString(buffer, options.ref()) && !buffer.empty())
434 stream.Printf("%s", buffer.c_str());
435 }
436 return ConstString(stream.GetData()).GetCString();
437}
438
439const char *SBValue::GetLocation() {
440 LLDB_INSTRUMENT_VA(this);
441
442 ValueLocker locker;
443 lldb::ValueObjectSP value_sp(GetSP(locker));
444 if (!value_sp)
445 return nullptr;
446
447 return ConstString(value_sp->GetLocationAsCString()).GetCString();
448}
449
450// Deprecated - use the one that takes an lldb::SBError
451bool SBValue::SetValueFromCString(const char *value_str) {
452 LLDB_INSTRUMENT_VA(this, value_str);
453
454 lldb::SBError dummy;
455 return SetValueFromCString(value_str, dummy);
456}
457
458bool SBValue::SetValueFromCString(const char *value_str, lldb::SBError &error) {
459 LLDB_INSTRUMENT_VA(this, value_str, error);
460
461 bool success = false;
462 ValueLocker locker;
463 lldb::ValueObjectSP value_sp(GetSP(locker));
464 if (value_sp) {
465 success = value_sp->SetValueFromCString(value_str, error.ref());
466 } else
467 error.SetErrorStringWithFormat("Could not get value: %s",
468 locker.GetError().AsCString());
469
470 return success;
471}
472
474 LLDB_INSTRUMENT_VA(this);
475
476 lldb::SBTypeFormat format;
477 ValueLocker locker;
478 lldb::ValueObjectSP value_sp(GetSP(locker));
479 if (value_sp) {
480 if (value_sp->UpdateValueIfNeeded(true)) {
481 lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
482 if (format_sp)
483 format.SetSP(format_sp);
484 }
485 }
486 return format;
487}
488
490 LLDB_INSTRUMENT_VA(this);
491
492 lldb::SBTypeSummary summary;
493 ValueLocker locker;
494 lldb::ValueObjectSP value_sp(GetSP(locker));
495 if (value_sp) {
496 if (value_sp->UpdateValueIfNeeded(true)) {
497 lldb::TypeSummaryImplSP summary_sp = value_sp->GetSummaryFormat();
498 if (summary_sp)
499 summary.SetSP(summary_sp);
500 }
501 }
502 return summary;
503}
504
506 LLDB_INSTRUMENT_VA(this);
507
508 lldb::SBTypeFilter filter;
509 ValueLocker locker;
510 lldb::ValueObjectSP value_sp(GetSP(locker));
511 if (value_sp) {
512 if (value_sp->UpdateValueIfNeeded(true)) {
513 lldb::SyntheticChildrenSP synthetic_sp = value_sp->GetSyntheticChildren();
514
515 if (synthetic_sp && !synthetic_sp->IsScripted()) {
516 TypeFilterImplSP filter_sp =
517 std::static_pointer_cast<TypeFilterImpl>(synthetic_sp);
518 filter.SetSP(filter_sp);
519 }
520 }
521 }
522 return filter;
523}
524
526 LLDB_INSTRUMENT_VA(this);
527
528 lldb::SBTypeSynthetic synthetic;
529 ValueLocker locker;
530 lldb::ValueObjectSP value_sp(GetSP(locker));
531 if (value_sp) {
532 if (value_sp->UpdateValueIfNeeded(true)) {
533 lldb::SyntheticChildrenSP children_sp = value_sp->GetSyntheticChildren();
534
535 if (children_sp && children_sp->IsScripted()) {
537 std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
538 synthetic.SetSP(synth_sp);
539 }
540 }
541 }
542 return synthetic;
543}
544
545lldb::SBValue SBValue::CreateChildAtOffset(const char *name, uint32_t offset,
546 SBType type) {
547 LLDB_INSTRUMENT_VA(this, name, offset, type);
548
549 lldb::SBValue sb_value;
550 ValueLocker locker;
551 lldb::ValueObjectSP value_sp(GetSP(locker));
552 lldb::ValueObjectSP new_value_sp;
553 if (value_sp) {
554 TypeImplSP type_sp(type.GetSP());
555 if (type.IsValid()) {
556 sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(
557 offset, type_sp->GetCompilerType(false), true),
559 }
560 }
561 return sb_value;
562}
563
565 LLDB_INSTRUMENT_VA(this, type);
566
567 lldb::SBValue sb_value;
568 ValueLocker locker;
569 lldb::ValueObjectSP value_sp(GetSP(locker));
570 TypeImplSP type_sp(type.GetSP());
571 if (value_sp && type_sp)
572 sb_value.SetSP(value_sp->Cast(type_sp->GetCompilerType(false)),
574 return sb_value;
575}
576
578 const char *expression) {
579 LLDB_INSTRUMENT_VA(this, name, expression);
580
581 SBExpressionOptions options;
582 options.ref().SetKeepInMemory(true);
583 return CreateValueFromExpression(name, expression, options);
584}
585
587 const char *expression,
588 SBExpressionOptions &options) {
589 LLDB_INSTRUMENT_VA(this, name, expression, options);
590
591 lldb::SBValue sb_value;
592 ValueLocker locker;
593 lldb::ValueObjectSP value_sp(GetSP(locker));
594 lldb::ValueObjectSP new_value_sp;
595 if (value_sp) {
596 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
598 name, expression, exe_ctx, options.ref());
599 if (new_value_sp)
600 new_value_sp->SetName(ConstString(name));
601 }
602 sb_value.SetSP(new_value_sp);
603 return sb_value;
604}
605
607 lldb::addr_t address,
608 SBType sb_type) {
609 LLDB_INSTRUMENT_VA(this, name, address, sb_type);
610
611 lldb::SBValue sb_value;
612 ValueLocker locker;
613 lldb::ValueObjectSP value_sp(GetSP(locker));
614 lldb::ValueObjectSP new_value_sp;
615 lldb::TypeImplSP type_impl_sp(sb_type.GetSP());
616 if (value_sp && type_impl_sp) {
617 CompilerType ast_type(type_impl_sp->GetCompilerType(true));
618 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
619 new_value_sp = ValueObject::CreateValueObjectFromAddress(name, address,
620 exe_ctx, ast_type);
621 }
622 sb_value.SetSP(new_value_sp);
623 return sb_value;
624}
625
627 SBType sb_type) {
628 LLDB_INSTRUMENT_VA(this, name, data, sb_type);
629
630 lldb::SBValue sb_value;
631 lldb::ValueObjectSP new_value_sp;
632 ValueLocker locker;
633 lldb::ValueObjectSP value_sp(GetSP(locker));
634 lldb::TypeImplSP type_impl_sp(sb_type.GetSP());
635 if (value_sp && type_impl_sp) {
636 ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
638 name, **data, exe_ctx, type_impl_sp->GetCompilerType(true));
639 new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
640 }
641 sb_value.SetSP(new_value_sp);
642 return sb_value;
643}
644
646 LLDB_INSTRUMENT_VA(this, idx);
647
648 const bool can_create_synthetic = false;
650 TargetSP target_sp;
651 if (m_opaque_sp)
652 target_sp = m_opaque_sp->GetTargetSP();
653
654 if (target_sp)
655 use_dynamic = target_sp->GetPreferDynamicValue();
656
657 return GetChildAtIndex(idx, use_dynamic, can_create_synthetic);
658}
659
661 lldb::DynamicValueType use_dynamic,
662 bool can_create_synthetic) {
663 LLDB_INSTRUMENT_VA(this, idx, use_dynamic, can_create_synthetic);
664
665 lldb::ValueObjectSP child_sp;
666
667 ValueLocker locker;
668 lldb::ValueObjectSP value_sp(GetSP(locker));
669 if (value_sp) {
670 const bool can_create = true;
671 child_sp = value_sp->GetChildAtIndex(idx);
672 if (can_create_synthetic && !child_sp) {
673 child_sp = value_sp->GetSyntheticArrayMember(idx, can_create);
674 }
675 }
676
677 SBValue sb_value;
678 sb_value.SetSP(child_sp, use_dynamic, GetPreferSyntheticValue());
679
680 return sb_value;
681}
682
683uint32_t SBValue::GetIndexOfChildWithName(const char *name) {
684 LLDB_INSTRUMENT_VA(this, name);
685
686 uint32_t idx = UINT32_MAX;
687 ValueLocker locker;
688 lldb::ValueObjectSP value_sp(GetSP(locker));
689 if (value_sp) {
690 idx = value_sp->GetIndexOfChildWithName(name);
691 }
692 return idx;
693}
694
696 LLDB_INSTRUMENT_VA(this, name);
697
698 lldb::DynamicValueType use_dynamic_value = eNoDynamicValues;
699 TargetSP target_sp;
700 if (m_opaque_sp)
701 target_sp = m_opaque_sp->GetTargetSP();
702
703 if (target_sp)
704 use_dynamic_value = target_sp->GetPreferDynamicValue();
705 return GetChildMemberWithName(name, use_dynamic_value);
706}
707
710 lldb::DynamicValueType use_dynamic_value) {
711 LLDB_INSTRUMENT_VA(this, name, use_dynamic_value);
712
713 lldb::ValueObjectSP child_sp;
714
715 ValueLocker locker;
716 lldb::ValueObjectSP value_sp(GetSP(locker));
717 if (value_sp) {
718 child_sp = value_sp->GetChildMemberWithName(name);
719 }
720
721 SBValue sb_value;
722 sb_value.SetSP(child_sp, use_dynamic_value, GetPreferSyntheticValue());
723
724 return sb_value;
725}
726
728 LLDB_INSTRUMENT_VA(this, use_dynamic);
729
730 SBValue value_sb;
731 if (IsValid()) {
732 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), use_dynamic,
733 m_opaque_sp->GetUseSynthetic()));
734 value_sb.SetSP(proxy_sp);
735 }
736 return value_sb;
737}
738
740 LLDB_INSTRUMENT_VA(this);
741
742 SBValue value_sb;
743 if (IsValid()) {
744 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
746 m_opaque_sp->GetUseSynthetic()));
747 value_sb.SetSP(proxy_sp);
748 }
749 return value_sb;
750}
751
753 LLDB_INSTRUMENT_VA(this);
754
755 SBValue value_sb;
756 if (IsValid()) {
757 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
758 m_opaque_sp->GetUseDynamic(), false));
759 value_sb.SetSP(proxy_sp);
760 }
761 return value_sb;
762}
763
765 LLDB_INSTRUMENT_VA(this);
766
767 if (!IsValid())
768 return eNoDynamicValues;
769 return m_opaque_sp->GetUseDynamic();
770}
771
773 LLDB_INSTRUMENT_VA(this, use_dynamic);
774
775 if (IsValid())
776 return m_opaque_sp->SetUseDynamic(use_dynamic);
777}
778
780 LLDB_INSTRUMENT_VA(this);
781
782 if (!IsValid())
783 return false;
784 return m_opaque_sp->GetUseSynthetic();
785}
786
787void SBValue::SetPreferSyntheticValue(bool use_synthetic) {
788 LLDB_INSTRUMENT_VA(this, use_synthetic);
789
790 if (IsValid())
791 return m_opaque_sp->SetUseSynthetic(use_synthetic);
792}
793
795 LLDB_INSTRUMENT_VA(this);
796
797 ValueLocker locker;
798 lldb::ValueObjectSP value_sp(GetSP(locker));
799 if (value_sp)
800 return value_sp->IsDynamic();
801 return false;
802}
803
805 LLDB_INSTRUMENT_VA(this);
806
807 ValueLocker locker;
808 lldb::ValueObjectSP value_sp(GetSP(locker));
809 if (value_sp)
810 return value_sp->IsSynthetic();
811 return false;
812}
813
815 LLDB_INSTRUMENT_VA(this);
816
817 ValueLocker locker;
818 lldb::ValueObjectSP value_sp(GetSP(locker));
819 if (value_sp)
820 return value_sp->IsSyntheticChildrenGenerated();
821 return false;
822}
823
825 LLDB_INSTRUMENT_VA(this, is);
826
827 ValueLocker locker;
828 lldb::ValueObjectSP value_sp(GetSP(locker));
829 if (value_sp)
830 return value_sp->SetSyntheticChildrenGenerated(is);
831}
832
834 LLDB_INSTRUMENT_VA(this, expr_path);
835
836 lldb::ValueObjectSP child_sp;
837 ValueLocker locker;
838 lldb::ValueObjectSP value_sp(GetSP(locker));
839 if (value_sp) {
840 // using default values for all the fancy options, just do it if you can
841 child_sp = value_sp->GetValueForExpressionPath(expr_path);
842 }
843
844 SBValue sb_value;
845 sb_value.SetSP(child_sp, GetPreferDynamicValue(), GetPreferSyntheticValue());
846
847 return sb_value;
848}
849
850int64_t SBValue::GetValueAsSigned(SBError &error, int64_t fail_value) {
851 LLDB_INSTRUMENT_VA(this, error, fail_value);
852
853 error.Clear();
854 ValueLocker locker;
855 lldb::ValueObjectSP value_sp(GetSP(locker));
856 if (value_sp) {
857 bool success = true;
858 uint64_t ret_val = fail_value;
859 ret_val = value_sp->GetValueAsSigned(fail_value, &success);
860 if (!success)
861 error.SetErrorString("could not resolve value");
862 return ret_val;
863 } else
864 error.SetErrorStringWithFormat("could not get SBValue: %s",
865 locker.GetError().AsCString());
866
867 return fail_value;
868}
869
870uint64_t SBValue::GetValueAsUnsigned(SBError &error, uint64_t fail_value) {
871 LLDB_INSTRUMENT_VA(this, error, fail_value);
872
873 error.Clear();
874 ValueLocker locker;
875 lldb::ValueObjectSP value_sp(GetSP(locker));
876 if (value_sp) {
877 bool success = true;
878 uint64_t ret_val = fail_value;
879 ret_val = value_sp->GetValueAsUnsigned(fail_value, &success);
880 if (!success)
881 error.SetErrorString("could not resolve value");
882 return ret_val;
883 } else
884 error.SetErrorStringWithFormat("could not get SBValue: %s",
885 locker.GetError().AsCString());
886
887 return fail_value;
888}
889
890int64_t SBValue::GetValueAsSigned(int64_t fail_value) {
891 LLDB_INSTRUMENT_VA(this, fail_value);
892
893 ValueLocker locker;
894 lldb::ValueObjectSP value_sp(GetSP(locker));
895 if (value_sp) {
896 return value_sp->GetValueAsSigned(fail_value);
897 }
898 return fail_value;
899}
900
901uint64_t SBValue::GetValueAsUnsigned(uint64_t fail_value) {
902 LLDB_INSTRUMENT_VA(this, fail_value);
903
904 ValueLocker locker;
905 lldb::ValueObjectSP value_sp(GetSP(locker));
906 if (value_sp) {
907 return value_sp->GetValueAsUnsigned(fail_value);
908 }
909 return fail_value;
910}
911
913 addr_t fail_value = LLDB_INVALID_ADDRESS;
914 ValueLocker locker;
915 lldb::ValueObjectSP value_sp(GetSP(locker));
916 if (value_sp) {
917 bool success = true;
918 uint64_t ret_val = fail_value;
919 ret_val = value_sp->GetValueAsUnsigned(fail_value, &success);
920 if (!success)
921 return fail_value;
922 ProcessSP process_sp = m_opaque_sp->GetProcessSP();
923 if (!process_sp)
924 return ret_val;
925 return process_sp->FixDataAddress(ret_val);
926 }
927
928 return fail_value;
929}
930
932 LLDB_INSTRUMENT_VA(this);
933
934 bool has_children = false;
935 ValueLocker locker;
936 lldb::ValueObjectSP value_sp(GetSP(locker));
937 if (value_sp)
938 has_children = value_sp->MightHaveChildren();
939
940 return has_children;
941}
942
944 LLDB_INSTRUMENT_VA(this);
945
946 bool is_support = false;
947 ValueLocker locker;
948 lldb::ValueObjectSP value_sp(GetSP(locker));
949 if (value_sp)
950 is_support = value_sp->IsRuntimeSupportValue();
951
952 return is_support;
953}
954
956 LLDB_INSTRUMENT_VA(this);
957
959}
960
961uint32_t SBValue::GetNumChildren(uint32_t max) {
962 LLDB_INSTRUMENT_VA(this, max);
963
964 uint32_t num_children = 0;
965
966 ValueLocker locker;
967 lldb::ValueObjectSP value_sp(GetSP(locker));
968 if (value_sp)
969 num_children = value_sp->GetNumChildrenIgnoringErrors(max);
970
971 return num_children;
972}
973
975 LLDB_INSTRUMENT_VA(this);
976
977 SBValue sb_value;
978 ValueLocker locker;
979 lldb::ValueObjectSP value_sp(GetSP(locker));
980 if (value_sp) {
982 sb_value = value_sp->Dereference(error);
983 }
984
985 return sb_value;
986}
987
988// Deprecated - please use GetType().IsPointerType() instead.
989bool SBValue::TypeIsPointerType() {
990 LLDB_INSTRUMENT_VA(this);
991
992 return GetType().IsPointerType();
993}
994
996 LLDB_INSTRUMENT_VA(this);
997
998 ValueLocker locker;
999 lldb::ValueObjectSP value_sp(GetSP(locker));
1000 if (value_sp)
1001 return value_sp->GetCompilerType().GetOpaqueQualType();
1002 return nullptr;
1003}
1004
1006 LLDB_INSTRUMENT_VA(this);
1007
1008 SBTarget sb_target;
1009 TargetSP target_sp;
1010 if (m_opaque_sp) {
1011 target_sp = m_opaque_sp->GetTargetSP();
1012 sb_target.SetSP(target_sp);
1013 }
1014
1015 return sb_target;
1016}
1017
1019 LLDB_INSTRUMENT_VA(this);
1020
1021 SBProcess sb_process;
1022 ProcessSP process_sp;
1023 if (m_opaque_sp) {
1024 process_sp = m_opaque_sp->GetProcessSP();
1025 sb_process.SetSP(process_sp);
1026 }
1027
1028 return sb_process;
1029}
1030
1032 LLDB_INSTRUMENT_VA(this);
1033
1034 SBThread sb_thread;
1035 ThreadSP thread_sp;
1036 if (m_opaque_sp) {
1037 thread_sp = m_opaque_sp->GetThreadSP();
1038 sb_thread.SetThread(thread_sp);
1039 }
1040
1041 return sb_thread;
1042}
1043
1045 LLDB_INSTRUMENT_VA(this);
1046
1047 SBFrame sb_frame;
1048 StackFrameSP frame_sp;
1049 if (m_opaque_sp) {
1050 frame_sp = m_opaque_sp->GetFrameSP();
1051 sb_frame.SetFrameSP(frame_sp);
1052 }
1053
1054 return sb_frame;
1055}
1056
1058 // IsValid means that the SBValue has a value in it. But that's not the
1059 // only time that ValueObjects are useful. We also want to return the value
1060 // if there's an error state in it.
1061 if (!m_opaque_sp || (!m_opaque_sp->IsValid()
1062 && (m_opaque_sp->GetRootSP()
1063 && !m_opaque_sp->GetRootSP()->GetError().Fail()))) {
1064 locker.GetError().SetErrorString("No value");
1065 return ValueObjectSP();
1066 }
1067 return locker.GetLockedSP(*m_opaque_sp.get());
1068}
1069
1071 LLDB_INSTRUMENT_VA(this);
1072
1073 ValueLocker locker;
1074 return GetSP(locker);
1075}
1076
1077void SBValue::SetSP(ValueImplSP impl_sp) { m_opaque_sp = impl_sp; }
1078
1080 if (sp) {
1081 lldb::TargetSP target_sp(sp->GetTargetSP());
1082 if (target_sp) {
1083 lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1084 bool use_synthetic =
1085 target_sp->TargetProperties::GetEnableSyntheticValue();
1086 m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
1087 } else
1089 } else
1091}
1092
1094 lldb::DynamicValueType use_dynamic) {
1095 if (sp) {
1096 lldb::TargetSP target_sp(sp->GetTargetSP());
1097 if (target_sp) {
1098 bool use_synthetic =
1099 target_sp->TargetProperties::GetEnableSyntheticValue();
1100 SetSP(sp, use_dynamic, use_synthetic);
1101 } else
1102 SetSP(sp, use_dynamic, true);
1103 } else
1104 SetSP(sp, use_dynamic, false);
1105}
1106
1107void SBValue::SetSP(const lldb::ValueObjectSP &sp, bool use_synthetic) {
1108 if (sp) {
1109 lldb::TargetSP target_sp(sp->GetTargetSP());
1110 if (target_sp) {
1111 lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1112 SetSP(sp, use_dynamic, use_synthetic);
1113 } else
1114 SetSP(sp, eNoDynamicValues, use_synthetic);
1115 } else
1116 SetSP(sp, eNoDynamicValues, use_synthetic);
1117}
1118
1120 lldb::DynamicValueType use_dynamic, bool use_synthetic) {
1121 m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
1122}
1123
1125 lldb::DynamicValueType use_dynamic, bool use_synthetic,
1126 const char *name) {
1127 m_opaque_sp =
1128 ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic, name));
1129}
1130
1132 LLDB_INSTRUMENT_VA(this, description);
1133
1134 ValueLocker locker;
1135 lldb::ValueObjectSP value_sp(GetSP(locker));
1136 if (value_sp) {
1137 value_sp->GetExpressionPath(description.ref());
1138 return true;
1139 }
1140 return false;
1141}
1142
1144 bool qualify_cxx_base_classes) {
1145 LLDB_INSTRUMENT_VA(this, description, qualify_cxx_base_classes);
1146
1147 ValueLocker locker;
1148 lldb::ValueObjectSP value_sp(GetSP(locker));
1149 if (value_sp) {
1150 value_sp->GetExpressionPath(description.ref());
1151 return true;
1152 }
1153 return false;
1154}
1155
1157 LLDB_INSTRUMENT_VA(this, expr);
1158
1159 ValueLocker locker;
1160 lldb::ValueObjectSP value_sp(GetSP(locker));
1161 if (!value_sp)
1162 return SBValue();
1163
1164 lldb::TargetSP target_sp = value_sp->GetTargetSP();
1165 if (!target_sp)
1166 return SBValue();
1167
1169 options.SetFetchDynamicValue(target_sp->GetPreferDynamicValue());
1170 options.SetUnwindOnError(true);
1171 options.SetIgnoreBreakpoints(true);
1172
1173 return EvaluateExpression(expr, options, nullptr);
1174}
1175
1178 const SBExpressionOptions &options) const {
1179 LLDB_INSTRUMENT_VA(this, expr, options);
1180
1181 return EvaluateExpression(expr, options, nullptr);
1182}
1183
1185 const SBExpressionOptions &options,
1186 const char *name) const {
1187 LLDB_INSTRUMENT_VA(this, expr, options, name);
1188
1189 if (!expr || expr[0] == '\0') {
1190 return SBValue();
1191 }
1192
1193
1194 ValueLocker locker;
1195 lldb::ValueObjectSP value_sp(GetSP(locker));
1196 if (!value_sp) {
1197 return SBValue();
1198 }
1199
1200 lldb::TargetSP target_sp = value_sp->GetTargetSP();
1201 if (!target_sp) {
1202 return SBValue();
1203 }
1204
1205 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1206 ExecutionContext exe_ctx(target_sp.get());
1207
1208 StackFrame *frame = exe_ctx.GetFramePtr();
1209 if (!frame) {
1210 return SBValue();
1211 }
1212
1213 ValueObjectSP res_val_sp;
1214 target_sp->EvaluateExpression(expr, frame, res_val_sp, options.ref(), nullptr,
1215 value_sp.get());
1216
1217 if (name)
1218 res_val_sp->SetName(ConstString(name));
1219
1220 SBValue result;
1221 result.SetSP(res_val_sp, options.GetFetchDynamicValue());
1222 return result;
1223}
1224
1226 LLDB_INSTRUMENT_VA(this, description);
1227
1228 Stream &strm = description.ref();
1229
1230 ValueLocker locker;
1231 lldb::ValueObjectSP value_sp(GetSP(locker));
1232 if (value_sp) {
1233 DumpValueObjectOptions options;
1234 options.SetUseDynamicType(m_opaque_sp->GetUseDynamic());
1235 options.SetUseSyntheticValue(m_opaque_sp->GetUseSynthetic());
1236 value_sp->Dump(strm, options);
1237 } else {
1238 strm.PutCString("No value");
1239 }
1240
1241 return true;
1242}
1243
1245 LLDB_INSTRUMENT_VA(this);
1246
1247 ValueLocker locker;
1248 lldb::ValueObjectSP value_sp(GetSP(locker));
1249 if (value_sp)
1250 return value_sp->GetFormat();
1251 return eFormatDefault;
1252}
1253
1255 LLDB_INSTRUMENT_VA(this, format);
1256
1257 ValueLocker locker;
1258 lldb::ValueObjectSP value_sp(GetSP(locker));
1259 if (value_sp)
1260 value_sp->SetFormat(format);
1261}
1262
1264 LLDB_INSTRUMENT_VA(this);
1265
1266 SBValue sb_value;
1267 ValueLocker locker;
1268 lldb::ValueObjectSP value_sp(GetSP(locker));
1269 if (value_sp) {
1270 Status error;
1271 sb_value.SetSP(value_sp->AddressOf(error), GetPreferDynamicValue(),
1273 }
1274
1275 return sb_value;
1276}
1277
1279 LLDB_INSTRUMENT_VA(this);
1280
1282 ValueLocker locker;
1283 lldb::ValueObjectSP value_sp(GetSP(locker));
1284 if (value_sp) {
1285 TargetSP target_sp(value_sp->GetTargetSP());
1286 if (target_sp) {
1287 const bool scalar_is_load_address = true;
1288 AddressType addr_type;
1289 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
1290 if (addr_type == eAddressTypeFile) {
1291 ModuleSP module_sp(value_sp->GetModule());
1292 if (!module_sp)
1293 value = LLDB_INVALID_ADDRESS;
1294 else {
1295 Address addr;
1296 module_sp->ResolveFileAddress(value, addr);
1297 value = addr.GetLoadAddress(target_sp.get());
1298 }
1299 } else if (addr_type == eAddressTypeHost ||
1300 addr_type == eAddressTypeInvalid)
1301 value = LLDB_INVALID_ADDRESS;
1302 }
1303 }
1304
1305 return value;
1306}
1307
1309 LLDB_INSTRUMENT_VA(this);
1310
1311 Address addr;
1312 ValueLocker locker;
1313 lldb::ValueObjectSP value_sp(GetSP(locker));
1314 if (value_sp) {
1315 TargetSP target_sp(value_sp->GetTargetSP());
1316 if (target_sp) {
1318 const bool scalar_is_load_address = true;
1319 AddressType addr_type;
1320 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
1321 if (addr_type == eAddressTypeFile) {
1322 ModuleSP module_sp(value_sp->GetModule());
1323 if (module_sp)
1324 module_sp->ResolveFileAddress(value, addr);
1325 } else if (addr_type == eAddressTypeLoad) {
1326 // no need to check the return value on this.. if it can actually do
1327 // the resolve addr will be in the form (section,offset), otherwise it
1328 // will simply be returned as (NULL, value)
1329 addr.SetLoadAddress(value, target_sp.get());
1330 }
1331 }
1332 }
1333
1334 return SBAddress(addr);
1335}
1336
1337lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) {
1338 LLDB_INSTRUMENT_VA(this, item_idx, item_count);
1339
1340 lldb::SBData sb_data;
1341 ValueLocker locker;
1342 lldb::ValueObjectSP value_sp(GetSP(locker));
1343 if (value_sp) {
1344 TargetSP target_sp(value_sp->GetTargetSP());
1345 if (target_sp) {
1346 DataExtractorSP data_sp(new DataExtractor());
1347 value_sp->GetPointeeData(*data_sp, item_idx, item_count);
1348 if (data_sp->GetByteSize() > 0)
1349 *sb_data = data_sp;
1350 }
1351 }
1352
1353 return sb_data;
1354}
1355
1357 LLDB_INSTRUMENT_VA(this);
1358
1359 lldb::SBData sb_data;
1360 ValueLocker locker;
1361 lldb::ValueObjectSP value_sp(GetSP(locker));
1362 if (value_sp) {
1363 DataExtractorSP data_sp(new DataExtractor());
1364 Status error;
1365 value_sp->GetData(*data_sp, error);
1366 if (error.Success())
1367 *sb_data = data_sp;
1368 }
1369
1370 return sb_data;
1371}
1372
1374 LLDB_INSTRUMENT_VA(this, data, error);
1375
1376 ValueLocker locker;
1377 lldb::ValueObjectSP value_sp(GetSP(locker));
1378 bool ret = true;
1379
1380 if (value_sp) {
1381 DataExtractor *data_extractor = data.get();
1382
1383 if (!data_extractor) {
1384 error.SetErrorString("No data to set");
1385 ret = false;
1386 } else {
1387 Status set_error;
1388
1389 value_sp->SetData(*data_extractor, set_error);
1390
1391 if (!set_error.Success()) {
1392 error.SetErrorStringWithFormat("Couldn't set data: %s",
1393 set_error.AsCString());
1394 ret = false;
1395 }
1396 }
1397 } else {
1398 error.SetErrorStringWithFormat(
1399 "Couldn't set data: could not get SBValue: %s",
1400 locker.GetError().AsCString());
1401 ret = false;
1402 }
1403
1404 return ret;
1405}
1406
1407lldb::SBValue SBValue::Clone(const char *new_name) {
1408 LLDB_INSTRUMENT_VA(this, new_name);
1409
1410 ValueLocker locker;
1411 lldb::ValueObjectSP value_sp(GetSP(locker));
1412
1413 if (value_sp)
1414 return lldb::SBValue(value_sp->Clone(ConstString(new_name)));
1415 else
1416 return lldb::SBValue();
1417}
1418
1420 LLDB_INSTRUMENT_VA(this);
1421
1422 ValueLocker locker;
1423 lldb::ValueObjectSP value_sp(GetSP(locker));
1424 SBDeclaration decl_sb;
1425 if (value_sp) {
1426 Declaration decl;
1427 if (value_sp->GetDeclaration(decl))
1428 decl_sb.SetDeclaration(decl);
1429 }
1430 return decl_sb;
1431}
1432
1433lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write,
1434 SBError &error) {
1435 LLDB_INSTRUMENT_VA(this, resolve_location, read, write, error);
1436
1437 SBWatchpoint sb_watchpoint;
1438
1439 // If the SBValue is not valid, there's no point in even trying to watch it.
1440 ValueLocker locker;
1441 lldb::ValueObjectSP value_sp(GetSP(locker));
1442 TargetSP target_sp(GetTarget().GetSP());
1443 if (value_sp && target_sp) {
1444 // Read and Write cannot both be false.
1445 if (!read && !write)
1446 return sb_watchpoint;
1447
1448 // If the value is not in scope, don't try and watch and invalid value
1449 if (!IsInScope())
1450 return sb_watchpoint;
1451
1452 addr_t addr = GetLoadAddress();
1453 if (addr == LLDB_INVALID_ADDRESS)
1454 return sb_watchpoint;
1455 size_t byte_size = GetByteSize();
1456 if (byte_size == 0)
1457 return sb_watchpoint;
1458
1459 uint32_t watch_type = 0;
1460 if (read) {
1461 watch_type |= LLDB_WATCH_TYPE_READ;
1462 // read + write, the most likely intention
1463 // is to catch all writes to this, not just
1464 // value modifications.
1465 if (write)
1466 watch_type |= LLDB_WATCH_TYPE_WRITE;
1467 } else {
1468 if (write)
1469 watch_type |= LLDB_WATCH_TYPE_MODIFY;
1470 }
1471
1472 Status rc;
1473 CompilerType type(value_sp->GetCompilerType());
1474 WatchpointSP watchpoint_sp =
1475 target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc);
1476 error.SetError(rc);
1477
1478 if (watchpoint_sp) {
1479 sb_watchpoint.SetSP(watchpoint_sp);
1480 Declaration decl;
1481 if (value_sp->GetDeclaration(decl)) {
1482 if (decl.GetFile()) {
1483 StreamString ss;
1484 // True to show fullpath for declaration file.
1485 decl.DumpStopContext(&ss, true);
1486 watchpoint_sp->SetDeclInfo(std::string(ss.GetString()));
1487 }
1488 }
1489 }
1490 } else if (target_sp) {
1491 error.SetErrorStringWithFormat("could not get SBValue: %s",
1492 locker.GetError().AsCString());
1493 } else {
1494 error.SetErrorString("could not set watchpoint, a target is required");
1495 }
1496
1497 return sb_watchpoint;
1498}
1499
1500// FIXME: Remove this method impl (as well as the decl in .h) once it is no
1501// longer needed.
1502// Backward compatibility fix in the interim.
1503lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read,
1504 bool write) {
1505 LLDB_INSTRUMENT_VA(this, resolve_location, read, write);
1506
1507 SBError error;
1508 return Watch(resolve_location, read, write, error);
1509}
1510
1511lldb::SBWatchpoint SBValue::WatchPointee(bool resolve_location, bool read,
1512 bool write, SBError &error) {
1513 LLDB_INSTRUMENT_VA(this, resolve_location, read, write, error);
1514
1515 SBWatchpoint sb_watchpoint;
1516 if (IsInScope() && GetType().IsPointerType())
1517 sb_watchpoint = Dereference().Watch(resolve_location, read, write, error);
1518 return sb_watchpoint;
1519}
1520
1522 LLDB_INSTRUMENT_VA(this);
1523
1524 ValueLocker locker;
1525 lldb::ValueObjectSP value_sp(GetSP(locker));
1526 SBValue persisted_sb;
1527 if (value_sp) {
1528 persisted_sb.SetSP(value_sp->Persist());
1529 }
1530 return persisted_sb;
1531}
1532
1534 SBValue vtable_sb;
1535 ValueLocker locker;
1536 lldb::ValueObjectSP value_sp(GetSP(locker));
1537 if (!value_sp)
1538 return vtable_sb;
1539
1540 vtable_sb.SetSP(value_sp->GetVTable());
1541 return vtable_sb;
1542}
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:105
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:912
bool IsInScope()
Definition: SBValue.cpp:338
bool SetData(lldb::SBData &data, lldb::SBError &error)
Definition: SBValue.cpp:1373
bool GetDescription(lldb::SBStream &description)
Definition: SBValue.cpp:1225
bool GetValueDidChange()
Definition: SBValue.cpp:400
lldb::SBValue EvaluateExpression(const char *expr) const
Definition: SBValue.cpp:1156
lldb::SBValue GetChildAtIndex(uint32_t idx)
Definition: SBValue.cpp:645
lldb::SBTypeFilter GetTypeFilter()
Definition: SBValue.cpp:505
lldb::SBAddress GetAddress()
Definition: SBValue.cpp:1308
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:1337
const char * GetTypeName()
Definition: SBValue.cpp:302
bool GetExpressionPath(lldb::SBStream &description)
Definition: SBValue.cpp:1131
SBError GetError()
Definition: SBValue.cpp:265
lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data, lldb::SBType type)
Definition: SBValue.cpp:626
lldb::SBValue Persist()
Definition: SBValue.cpp:1521
void SetSP(const lldb::ValueObjectSP &sp)
Definition: SBValue.cpp:1079
lldb::SBValue CreateValueFromAddress(const char *name, lldb::addr_t address, lldb::SBType type)
Definition: SBValue.cpp:606
const char * GetDisplayTypeName()
Definition: SBValue.cpp:313
lldb::SBValue CreateValueFromExpression(const char *name, const char *expression)
Definition: SBValue.cpp:577
lldb::SBData GetData()
Get an SBData wrapping the contents of this SBValue.
Definition: SBValue.cpp:1356
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:1407
void SetSyntheticChildrenGenerated(bool)
Definition: SBValue.cpp:824
void Clear()
Definition: SBValue.cpp:259
lldb::SBProcess GetProcess()
Definition: SBValue.cpp:1018
const char * GetLocation()
Definition: SBValue.cpp:439
bool IsSynthetic()
Definition: SBValue.cpp:804
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:850
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:1511
lldb::SBWatchpoint Watch(bool resolve_location, bool read, bool write, SBError &error)
Watch this value if it resides in memory.
Definition: SBValue.cpp:1433
lldb::SBTypeFormat GetTypeFormat()
Definition: SBValue.cpp:473
lldb::user_id_t GetID()
Definition: SBValue.cpp:281
lldb::SBFrame GetFrame()
Definition: SBValue.cpp:1044
const char * GetValue()
Definition: SBValue.cpp:352
bool MightHaveChildren()
Find out if a SBValue might have children.
Definition: SBValue.cpp:931
lldb::SBTypeSummary GetTypeSummary()
Definition: SBValue.cpp:489
lldb::SBValue GetDynamicValue(lldb::DynamicValueType use_dynamic)
Definition: SBValue.cpp:727
bool IsDynamic()
Definition: SBValue.cpp:794
bool IsSyntheticChildrenGenerated()
Definition: SBValue.cpp:814
const char * GetName()
Definition: SBValue.cpp:291
lldb::SBValue CreateChildAtOffset(const char *name, uint32_t offset, lldb::SBType type)
Definition: SBValue.cpp:545
lldb::SBValue Dereference()
Definition: SBValue.cpp:974
std::shared_ptr< ValueImpl > ValueImplSP
Definition: SBValue.h:492
lldb::SBValue GetStaticValue()
Definition: SBValue.cpp:739
lldb::SBValue Cast(lldb::SBType type)
Definition: SBValue.cpp:564
lldb::SBValue GetNonSyntheticValue()
Definition: SBValue.cpp:752
bool GetPreferSyntheticValue()
Definition: SBValue.cpp:779
uint32_t GetIndexOfChildWithName(const char *name)
Definition: SBValue.cpp:683
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:1533
const char * GetObjectDescription()
Definition: SBValue.cpp:374
const char * GetSummary()
Definition: SBValue.cpp:414
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:1070
lldb::SBTypeSynthetic GetTypeSynthetic()
Definition: SBValue.cpp:525
void SetFormat(lldb::Format format)
Definition: SBValue.cpp:1254
lldb::SBValue AddressOf()
Definition: SBValue.cpp:1263
bool SetValueFromCString(const char *value_str, lldb::SBError &error)
Definition: SBValue.cpp:451
lldb::DynamicValueType GetPreferDynamicValue()
Definition: SBValue.cpp:764
lldb::SBThread GetThread()
Definition: SBValue.cpp:1031
ValueImplSP m_opaque_sp
Definition: SBValue.h:493
lldb::SBValue GetChildMemberWithName(const char *name)
Definition: SBValue.cpp:695
lldb::SBTarget GetTarget()
Definition: SBValue.cpp:1005
uint64_t GetValueAsUnsigned(lldb::SBError &error, uint64_t fail_value=0)
Definition: SBValue.cpp:870
uint32_t GetNumChildren()
Definition: SBValue.cpp:955
void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic)
Definition: SBValue.cpp:772
ValueType GetValueType()
Definition: SBValue.cpp:362
void * GetOpaqueType()
Definition: SBValue.cpp:995
bool IsValid()
Definition: SBValue.cpp:245
lldb::SBValue GetValueForExpressionPath(const char *expr_path)
Definition: SBValue.cpp:833
lldb::addr_t GetLoadAddress()
Definition: SBValue.cpp:1278
lldb::SBType GetType()
Definition: SBValue.cpp:385
void SetPreferSyntheticValue(bool use_synthetic)
Definition: SBValue.cpp:787
lldb::SBDeclaration GetDeclaration()
Definition: SBValue.cpp:1419
lldb::Format GetFormat()
Definition: SBValue.cpp:1244
bool IsRuntimeSupportValue()
Definition: SBValue.cpp:943
void SetSP(const lldb::WatchpointSP &sp)
A section + offset based address class.
Definition: Address.h:62
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:313
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
bool IsEmpty() const
Test for empty string.
Definition: ConstString.h:302
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:214
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:130
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:233
bool Success() const
Test for success condition.
Definition: Status.cpp:279
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:4946
static lldb::ValueObjectSP CreateValueObjectFromExpression(llvm::StringRef name, llvm::StringRef expression, const ExecutionContext &exe_ctx)
static lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type)
static lldb::ValueObjectSP CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address, 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.
Definition: SBAttachInfo.h:14
@ 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.
@ eAddressTypeHost
Address is an address in the process that is running this code.
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
Definition: lldb-forward.h:412
std::shared_ptr< lldb_private::TypeSummaryImpl > TypeSummaryImplSP
Definition: lldb-forward.h:463
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:438
std::shared_ptr< lldb_private::TypeFormatImpl > TypeFormatImplSP
Definition: lldb-forward.h:460
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:472
Format
Display format definitions.
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:381
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
Definition: lldb-forward.h:477
std::shared_ptr< lldb_private::SyntheticChildren > SyntheticChildrenSP
Definition: lldb-forward.h:433
uint64_t user_id_t
Definition: lldb-types.h:82
std::shared_ptr< lldb_private::ScriptedSyntheticChildren > ScriptedSyntheticChildrenSP
Definition: lldb-forward.h:466
std::shared_ptr< lldb_private::TypeFilterImpl > TypeFilterImplSP
Definition: lldb-forward.h:456
uint64_t addr_t
Definition: lldb-types.h:81
std::shared_ptr< lldb_private::TypeImpl > TypeImplSP
Definition: lldb-forward.h:452
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:436
@ eNoDynamicValues
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
Definition: lldb-forward.h:330
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:365
@ eValueTypeInvalid