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