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