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