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