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