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