File indexing completed on 2026-05-10 08:42:59
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_VALUEOBJECT_VALUEOBJECT_H
0010 #define LLDB_VALUEOBJECT_VALUEOBJECT_H
0011
0012 #include "lldb/Core/Value.h"
0013 #include "lldb/Symbol/CompilerType.h"
0014 #include "lldb/Symbol/Type.h"
0015 #include "lldb/Target/ExecutionContext.h"
0016 #include "lldb/Target/Process.h"
0017 #include "lldb/Utility/ConstString.h"
0018 #include "lldb/Utility/DataExtractor.h"
0019 #include "lldb/Utility/SharedCluster.h"
0020 #include "lldb/Utility/Status.h"
0021 #include "lldb/Utility/UserID.h"
0022 #include "lldb/lldb-defines.h"
0023 #include "lldb/lldb-enumerations.h"
0024 #include "lldb/lldb-forward.h"
0025 #include "lldb/lldb-private-enumerations.h"
0026 #include "lldb/lldb-types.h"
0027
0028 #include "llvm/ADT/ArrayRef.h"
0029 #include "llvm/ADT/SmallVector.h"
0030 #include "llvm/ADT/StringRef.h"
0031
0032 #include <functional>
0033 #include <initializer_list>
0034 #include <map>
0035 #include <mutex>
0036 #include <optional>
0037 #include <string>
0038 #include <utility>
0039
0040 #include <cstddef>
0041 #include <cstdint>
0042
0043 namespace lldb_private {
0044 class Declaration;
0045 class DumpValueObjectOptions;
0046 class EvaluateExpressionOptions;
0047 class ExecutionContextScope;
0048 class Log;
0049 class Scalar;
0050 class Stream;
0051 class SymbolContextScope;
0052 class TypeFormatImpl;
0053 class TypeSummaryImpl;
0054 class TypeSummaryOptions;
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105 class ValueObject {
0106 public:
0107 enum GetExpressionPathFormat {
0108 eGetExpressionPathFormatDereferencePointers = 1,
0109 eGetExpressionPathFormatHonorPointers
0110 };
0111
0112 enum ValueObjectRepresentationStyle {
0113 eValueObjectRepresentationStyleValue = 1,
0114 eValueObjectRepresentationStyleSummary,
0115 eValueObjectRepresentationStyleLanguageSpecific,
0116 eValueObjectRepresentationStyleLocation,
0117 eValueObjectRepresentationStyleChildrenCount,
0118 eValueObjectRepresentationStyleType,
0119 eValueObjectRepresentationStyleName,
0120 eValueObjectRepresentationStyleExpressionPath
0121 };
0122
0123 enum ExpressionPathScanEndReason {
0124
0125 eExpressionPathScanEndReasonEndOfString = 1,
0126
0127 eExpressionPathScanEndReasonNoSuchChild,
0128
0129 eExpressionPathScanEndReasonNoSuchSyntheticChild,
0130
0131 eExpressionPathScanEndReasonEmptyRangeNotAllowed,
0132
0133 eExpressionPathScanEndReasonDotInsteadOfArrow,
0134
0135 eExpressionPathScanEndReasonArrowInsteadOfDot,
0136
0137 eExpressionPathScanEndReasonFragileIVarNotAllowed,
0138
0139 eExpressionPathScanEndReasonRangeOperatorNotAllowed,
0140
0141 eExpressionPathScanEndReasonRangeOperatorInvalid,
0142
0143 eExpressionPathScanEndReasonArrayRangeOperatorMet,
0144
0145 eExpressionPathScanEndReasonBitfieldRangeOperatorMet,
0146
0147 eExpressionPathScanEndReasonUnexpectedSymbol,
0148
0149 eExpressionPathScanEndReasonTakingAddressFailed,
0150
0151 eExpressionPathScanEndReasonDereferencingFailed,
0152
0153 eExpressionPathScanEndReasonRangeOperatorExpanded,
0154
0155 eExpressionPathScanEndReasonSyntheticValueMissing,
0156 eExpressionPathScanEndReasonUnknown = 0xFFFF
0157 };
0158
0159 enum ExpressionPathEndResultType {
0160
0161 eExpressionPathEndResultTypePlain = 1,
0162
0163 eExpressionPathEndResultTypeBitfield,
0164
0165 eExpressionPathEndResultTypeBoundedRange,
0166
0167 eExpressionPathEndResultTypeUnboundedRange,
0168
0169 eExpressionPathEndResultTypeValueObjectList,
0170 eExpressionPathEndResultTypeInvalid = 0xFFFF
0171 };
0172
0173 enum ExpressionPathAftermath {
0174
0175 eExpressionPathAftermathNothing = 1,
0176
0177 eExpressionPathAftermathDereference,
0178
0179 eExpressionPathAftermathTakeAddress
0180 };
0181
0182 enum ClearUserVisibleDataItems {
0183 eClearUserVisibleDataItemsNothing = 1u << 0,
0184 eClearUserVisibleDataItemsValue = 1u << 1,
0185 eClearUserVisibleDataItemsSummary = 1u << 2,
0186 eClearUserVisibleDataItemsLocation = 1u << 3,
0187 eClearUserVisibleDataItemsDescription = 1u << 4,
0188 eClearUserVisibleDataItemsSyntheticChildren = 1u << 5,
0189 eClearUserVisibleDataItemsAllStrings =
0190 eClearUserVisibleDataItemsValue | eClearUserVisibleDataItemsSummary |
0191 eClearUserVisibleDataItemsLocation |
0192 eClearUserVisibleDataItemsDescription,
0193 eClearUserVisibleDataItemsAll = 0xFFFF
0194 };
0195
0196 struct GetValueForExpressionPathOptions {
0197 enum class SyntheticChildrenTraversal {
0198 None,
0199 ToSynthetic,
0200 FromSynthetic,
0201 Both
0202 };
0203
0204 bool m_check_dot_vs_arrow_syntax;
0205 bool m_no_fragile_ivar;
0206 bool m_allow_bitfields_syntax;
0207 SyntheticChildrenTraversal m_synthetic_children_traversal;
0208
0209 GetValueForExpressionPathOptions(
0210 bool dot = false, bool no_ivar = false, bool bitfield = true,
0211 SyntheticChildrenTraversal synth_traverse =
0212 SyntheticChildrenTraversal::ToSynthetic)
0213 : m_check_dot_vs_arrow_syntax(dot), m_no_fragile_ivar(no_ivar),
0214 m_allow_bitfields_syntax(bitfield),
0215 m_synthetic_children_traversal(synth_traverse) {}
0216
0217 GetValueForExpressionPathOptions &DoCheckDotVsArrowSyntax() {
0218 m_check_dot_vs_arrow_syntax = true;
0219 return *this;
0220 }
0221
0222 GetValueForExpressionPathOptions &DontCheckDotVsArrowSyntax() {
0223 m_check_dot_vs_arrow_syntax = false;
0224 return *this;
0225 }
0226
0227 GetValueForExpressionPathOptions &DoAllowFragileIVar() {
0228 m_no_fragile_ivar = false;
0229 return *this;
0230 }
0231
0232 GetValueForExpressionPathOptions &DontAllowFragileIVar() {
0233 m_no_fragile_ivar = true;
0234 return *this;
0235 }
0236
0237 GetValueForExpressionPathOptions &DoAllowBitfieldSyntax() {
0238 m_allow_bitfields_syntax = true;
0239 return *this;
0240 }
0241
0242 GetValueForExpressionPathOptions &DontAllowBitfieldSyntax() {
0243 m_allow_bitfields_syntax = false;
0244 return *this;
0245 }
0246
0247 GetValueForExpressionPathOptions &
0248 SetSyntheticChildrenTraversal(SyntheticChildrenTraversal traverse) {
0249 m_synthetic_children_traversal = traverse;
0250 return *this;
0251 }
0252
0253 static const GetValueForExpressionPathOptions DefaultOptions() {
0254 static GetValueForExpressionPathOptions g_default_options;
0255
0256 return g_default_options;
0257 }
0258 };
0259
0260 class EvaluationPoint {
0261 public:
0262 EvaluationPoint();
0263
0264 EvaluationPoint(ExecutionContextScope *exe_scope,
0265 bool use_selected = false);
0266
0267 EvaluationPoint(const EvaluationPoint &rhs);
0268
0269 ~EvaluationPoint();
0270
0271 const ExecutionContextRef &GetExecutionContextRef() const {
0272 return m_exe_ctx_ref;
0273 }
0274
0275 void SetIsConstant() {
0276 SetUpdated();
0277 m_mod_id.SetInvalid();
0278 }
0279
0280 bool IsConstant() const { return !m_mod_id.IsValid(); }
0281
0282 ProcessModID GetModID() const { return m_mod_id; }
0283
0284 void SetUpdateID(ProcessModID new_id) { m_mod_id = new_id; }
0285
0286 void SetNeedsUpdate() { m_needs_update = true; }
0287
0288 void SetUpdated();
0289
0290 bool NeedsUpdating(bool accept_invalid_exe_ctx) {
0291 SyncWithProcessState(accept_invalid_exe_ctx);
0292 return m_needs_update;
0293 }
0294
0295 bool IsValid() {
0296 const bool accept_invalid_exe_ctx = false;
0297 if (!m_mod_id.IsValid())
0298 return false;
0299 else if (SyncWithProcessState(accept_invalid_exe_ctx)) {
0300 if (!m_mod_id.IsValid())
0301 return false;
0302 }
0303 return true;
0304 }
0305
0306 void SetInvalid() {
0307
0308
0309 m_mod_id.SetInvalid();
0310
0311
0312 m_needs_update = false;
0313 }
0314
0315 private:
0316 bool SyncWithProcessState(bool accept_invalid_exe_ctx);
0317
0318 ProcessModID m_mod_id;
0319
0320 ExecutionContextRef m_exe_ctx_ref;
0321 bool m_needs_update = true;
0322 };
0323
0324 virtual ~ValueObject();
0325
0326 const EvaluationPoint &GetUpdatePoint() const { return m_update_point; }
0327
0328 EvaluationPoint &GetUpdatePoint() { return m_update_point; }
0329
0330 const ExecutionContextRef &GetExecutionContextRef() const {
0331 return m_update_point.GetExecutionContextRef();
0332 }
0333
0334 lldb::TargetSP GetTargetSP() const {
0335 return m_update_point.GetExecutionContextRef().GetTargetSP();
0336 }
0337
0338 lldb::ProcessSP GetProcessSP() const {
0339 return m_update_point.GetExecutionContextRef().GetProcessSP();
0340 }
0341
0342 lldb::ThreadSP GetThreadSP() const {
0343 return m_update_point.GetExecutionContextRef().GetThreadSP();
0344 }
0345
0346 lldb::StackFrameSP GetFrameSP() const {
0347 return m_update_point.GetExecutionContextRef().GetFrameSP();
0348 }
0349
0350 void SetNeedsUpdate();
0351
0352 CompilerType GetCompilerType() { return MaybeCalculateCompleteType(); }
0353
0354
0355 virtual TypeImpl GetTypeImpl() { return TypeImpl(GetCompilerType()); }
0356
0357 virtual bool CanProvideValue();
0358
0359
0360 virtual std::optional<uint64_t> GetByteSize() = 0;
0361
0362 virtual lldb::ValueType GetValueType() const = 0;
0363
0364
0365 virtual ConstString GetTypeName() { return GetCompilerType().GetTypeName(); }
0366
0367 virtual ConstString GetDisplayTypeName() { return GetTypeName(); }
0368
0369 virtual ConstString GetQualifiedTypeName() {
0370 return GetCompilerType().GetTypeName();
0371 }
0372
0373 lldb::LanguageType GetObjectRuntimeLanguage() {
0374 return GetCompilerType().GetMinimumLanguage();
0375 }
0376
0377 uint32_t
0378 GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr) {
0379 return GetCompilerType().GetTypeInfo(pointee_or_element_compiler_type);
0380 }
0381
0382 bool IsPointerType() { return GetCompilerType().IsPointerType(); }
0383
0384 bool IsArrayType() { return GetCompilerType().IsArrayType(); }
0385
0386 bool IsScalarType() { return GetCompilerType().IsScalarType(); }
0387
0388 bool IsPointerOrReferenceType() {
0389 return GetCompilerType().IsPointerOrReferenceType();
0390 }
0391
0392 bool IsPossibleDynamicType();
0393
0394 bool IsNilReference();
0395
0396 bool IsUninitializedReference();
0397
0398 virtual bool IsBaseClass() { return false; }
0399
0400 bool IsBaseClass(uint32_t &depth);
0401
0402 virtual bool IsDereferenceOfParent() { return false; }
0403
0404 bool IsIntegerType(bool &is_signed) {
0405 return GetCompilerType().IsIntegerType(is_signed);
0406 }
0407
0408 virtual void GetExpressionPath(
0409 Stream &s,
0410 GetExpressionPathFormat = eGetExpressionPathFormatDereferencePointers);
0411
0412 lldb::ValueObjectSP GetValueForExpressionPath(
0413 llvm::StringRef expression,
0414 ExpressionPathScanEndReason *reason_to_stop = nullptr,
0415 ExpressionPathEndResultType *final_value_type = nullptr,
0416 const GetValueForExpressionPathOptions &options =
0417 GetValueForExpressionPathOptions::DefaultOptions(),
0418 ExpressionPathAftermath *final_task_on_target = nullptr);
0419
0420 virtual bool IsInScope() { return true; }
0421
0422 virtual lldb::offset_t GetByteOffset() { return 0; }
0423
0424 virtual uint32_t GetBitfieldBitSize() { return 0; }
0425
0426 virtual uint32_t GetBitfieldBitOffset() { return 0; }
0427
0428 bool IsBitfield() {
0429 return (GetBitfieldBitSize() != 0) || (GetBitfieldBitOffset() != 0);
0430 }
0431
0432 virtual const char *GetValueAsCString();
0433
0434 virtual bool GetValueAsCString(const lldb_private::TypeFormatImpl &format,
0435 std::string &destination);
0436
0437 bool GetValueAsCString(lldb::Format format, std::string &destination);
0438
0439 virtual uint64_t GetValueAsUnsigned(uint64_t fail_value,
0440 bool *success = nullptr);
0441
0442 virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success = nullptr);
0443
0444
0445
0446 llvm::Expected<llvm::APSInt> GetValueAsAPSInt();
0447
0448
0449
0450 llvm::Expected<llvm::APFloat> GetValueAsAPFloat();
0451
0452
0453
0454 llvm::Expected<bool> GetValueAsBool();
0455
0456
0457
0458
0459
0460 void SetValueFromInteger(const llvm::APInt &value, Status &error);
0461
0462
0463
0464
0465
0466 void SetValueFromInteger(lldb::ValueObjectSP new_val_sp, Status &error);
0467
0468 virtual bool SetValueFromCString(const char *value_str, Status &error);
0469
0470
0471
0472
0473 virtual lldb::ModuleSP GetModule();
0474
0475 ValueObject *GetRoot();
0476
0477
0478
0479
0480 ValueObject *FollowParentChain(std::function<bool(ValueObject *)>);
0481
0482 virtual bool GetDeclaration(Declaration &decl);
0483
0484
0485 const Status &GetError();
0486
0487 ConstString GetName() const { return m_name; }
0488
0489
0490 lldb::user_id_t GetID() const { return m_id.GetID(); }
0491
0492 virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx,
0493 bool can_create = true);
0494
0495
0496 lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef<llvm::StringRef> names);
0497
0498 virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
0499 bool can_create = true);
0500
0501 virtual size_t GetIndexOfChildWithName(llvm::StringRef name);
0502
0503 llvm::Expected<uint32_t> GetNumChildren(uint32_t max = UINT32_MAX);
0504
0505
0506
0507
0508 uint32_t GetNumChildrenIgnoringErrors(uint32_t max = UINT32_MAX);
0509 bool HasChildren() { return GetNumChildrenIgnoringErrors() > 0; }
0510
0511 const Value &GetValue() const { return m_value; }
0512
0513 Value &GetValue() { return m_value; }
0514
0515 virtual bool ResolveValue(Scalar &scalar);
0516
0517
0518
0519
0520 virtual bool IsLogicalTrue(Status &error);
0521
0522 virtual const char *GetLocationAsCString() {
0523 return GetLocationAsCStringImpl(m_value, m_data);
0524 }
0525
0526 const char *
0527 GetSummaryAsCString(lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
0528
0529 bool
0530 GetSummaryAsCString(TypeSummaryImpl *summary_ptr, std::string &destination,
0531 lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
0532
0533 bool GetSummaryAsCString(std::string &destination,
0534 const TypeSummaryOptions &options);
0535
0536 bool GetSummaryAsCString(TypeSummaryImpl *summary_ptr,
0537 std::string &destination,
0538 const TypeSummaryOptions &options);
0539
0540 llvm::Expected<std::string> GetObjectDescription();
0541
0542 bool HasSpecialPrintableRepresentation(
0543 ValueObjectRepresentationStyle val_obj_display,
0544 lldb::Format custom_format);
0545
0546 enum class PrintableRepresentationSpecialCases : bool {
0547 eDisable = false,
0548 eAllow = true
0549 };
0550
0551 bool
0552 DumpPrintableRepresentation(Stream &s,
0553 ValueObjectRepresentationStyle val_obj_display =
0554 eValueObjectRepresentationStyleSummary,
0555 lldb::Format custom_format = lldb::eFormatInvalid,
0556 PrintableRepresentationSpecialCases special =
0557 PrintableRepresentationSpecialCases::eAllow,
0558 bool do_dump_error = true);
0559 bool GetValueIsValid() const { return m_flags.m_value_is_valid; }
0560
0561
0562
0563 bool GetValueDidChange() { return m_flags.m_value_did_change; }
0564
0565 bool UpdateValueIfNeeded(bool update_format = true);
0566
0567 bool UpdateFormatsIfNeeded();
0568
0569 lldb::ValueObjectSP GetSP() { return m_manager->GetSharedPointer(this); }
0570
0571
0572
0573
0574 void SetName(ConstString name) { m_name = name; }
0575
0576 virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
0577 AddressType *address_type = nullptr);
0578
0579 lldb::addr_t GetPointerValue(AddressType *address_type = nullptr);
0580
0581 lldb::ValueObjectSP GetSyntheticChild(ConstString key) const;
0582
0583 lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create);
0584
0585 lldb::ValueObjectSP GetSyntheticBitFieldChild(uint32_t from, uint32_t to,
0586 bool can_create);
0587
0588 lldb::ValueObjectSP GetSyntheticExpressionPathChild(const char *expression,
0589 bool can_create);
0590
0591 virtual lldb::ValueObjectSP
0592 GetSyntheticChildAtOffset(uint32_t offset, const CompilerType &type,
0593 bool can_create,
0594 ConstString name_const_str = ConstString());
0595
0596 virtual lldb::ValueObjectSP
0597 GetSyntheticBase(uint32_t offset, const CompilerType &type, bool can_create,
0598 ConstString name_const_str = ConstString());
0599
0600 virtual lldb::ValueObjectSP GetDynamicValue(lldb::DynamicValueType valueType);
0601
0602 lldb::DynamicValueType GetDynamicValueType();
0603
0604 virtual lldb::ValueObjectSP GetStaticValue() { return GetSP(); }
0605
0606 virtual lldb::ValueObjectSP GetNonSyntheticValue() { return GetSP(); }
0607
0608 lldb::ValueObjectSP GetSyntheticValue();
0609
0610 virtual bool HasSyntheticValue();
0611
0612 virtual bool IsSynthetic() { return false; }
0613
0614 lldb::ValueObjectSP
0615 GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue,
0616 bool synthValue);
0617
0618 virtual lldb::ValueObjectSP CreateConstantValue(ConstString name);
0619
0620 virtual lldb::ValueObjectSP Dereference(Status &error);
0621
0622
0623
0624
0625
0626 virtual lldb::ValueObjectSP Clone(ConstString new_name);
0627
0628 virtual lldb::ValueObjectSP AddressOf(Status &error);
0629
0630 virtual lldb::addr_t GetLiveAddress() { return LLDB_INVALID_ADDRESS; }
0631
0632 virtual void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
0633 AddressType address_type = eAddressTypeLoad) {}
0634
0635 lldb::ValueObjectSP Cast(const CompilerType &compiler_type);
0636
0637 virtual lldb::ValueObjectSP DoCast(const CompilerType &compiler_type);
0638
0639 virtual lldb::ValueObjectSP CastPointerType(const char *name,
0640 CompilerType &ast_type);
0641
0642 virtual lldb::ValueObjectSP CastPointerType(const char *name,
0643 lldb::TypeSP &type_sp);
0644
0645
0646 lldb::addr_t GetLoadAddress();
0647
0648
0649
0650
0651
0652 llvm::Expected<lldb::ValueObjectSP>
0653 CastDerivedToBaseType(CompilerType type,
0654 const llvm::ArrayRef<uint32_t> &base_type_indices);
0655
0656
0657
0658
0659
0660 llvm::Expected<lldb::ValueObjectSP> CastBaseToDerivedType(CompilerType type,
0661 uint64_t offset);
0662
0663
0664
0665 lldb::ValueObjectSP CastToBasicType(CompilerType type);
0666
0667
0668
0669 lldb::ValueObjectSP CastToEnumType(CompilerType type);
0670
0671
0672
0673
0674 lldb::ValueObjectSP GetVTable();
0675
0676
0677 void ValueUpdated() {
0678 ClearUserVisibleData(eClearUserVisibleDataItemsValue |
0679 eClearUserVisibleDataItemsSummary |
0680 eClearUserVisibleDataItemsDescription);
0681 }
0682
0683 virtual bool IsDynamic() { return false; }
0684
0685 virtual bool DoesProvideSyntheticValue() { return false; }
0686
0687 virtual bool IsSyntheticChildrenGenerated() {
0688 return m_flags.m_is_synthetic_children_generated;
0689 }
0690
0691 virtual void SetSyntheticChildrenGenerated(bool b) {
0692 m_flags.m_is_synthetic_children_generated = b;
0693 }
0694
0695 virtual SymbolContextScope *GetSymbolContextScope();
0696
0697 llvm::Error Dump(Stream &s);
0698
0699 llvm::Error Dump(Stream &s, const DumpValueObjectOptions &options);
0700
0701 static lldb::ValueObjectSP
0702 CreateValueObjectFromExpression(llvm::StringRef name,
0703 llvm::StringRef expression,
0704 const ExecutionContext &exe_ctx);
0705
0706 static lldb::ValueObjectSP
0707 CreateValueObjectFromExpression(llvm::StringRef name,
0708 llvm::StringRef expression,
0709 const ExecutionContext &exe_ctx,
0710 const EvaluateExpressionOptions &options);
0711
0712
0713
0714
0715
0716 static lldb::ValueObjectSP
0717 CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address,
0718 const ExecutionContext &exe_ctx,
0719 CompilerType type, bool do_deref = true);
0720
0721 static lldb::ValueObjectSP
0722 CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data,
0723 const ExecutionContext &exe_ctx, CompilerType type);
0724
0725
0726 static lldb::ValueObjectSP CreateValueObjectFromAPInt(lldb::TargetSP target,
0727 const llvm::APInt &v,
0728 CompilerType type,
0729 llvm::StringRef name);
0730
0731
0732 static lldb::ValueObjectSP
0733 CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat &v,
0734 CompilerType type, llvm::StringRef name);
0735
0736
0737 static lldb::ValueObjectSP CreateValueObjectFromBool(lldb::TargetSP target,
0738 bool value,
0739 llvm::StringRef name);
0740
0741
0742
0743 static lldb::ValueObjectSP CreateValueObjectFromNullptr(lldb::TargetSP target,
0744 CompilerType type,
0745 llvm::StringRef name);
0746
0747 lldb::ValueObjectSP Persist();
0748
0749
0750
0751 bool IsCStringContainer(bool check_pointer = false);
0752
0753 std::pair<size_t, bool>
0754 ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, Status &error,
0755 bool honor_array);
0756
0757 virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
0758 uint32_t item_count = 1);
0759
0760 virtual uint64_t GetData(DataExtractor &data, Status &error);
0761
0762 virtual bool SetData(DataExtractor &data, Status &error);
0763
0764 virtual bool GetIsConstant() const { return m_update_point.IsConstant(); }
0765
0766 bool NeedsUpdating() {
0767 const bool accept_invalid_exe_ctx =
0768 (CanUpdateWithInvalidExecutionContext() == eLazyBoolYes);
0769 return m_update_point.NeedsUpdating(accept_invalid_exe_ctx);
0770 }
0771
0772 void SetIsConstant() { m_update_point.SetIsConstant(); }
0773
0774 lldb::Format GetFormat() const;
0775
0776 virtual void SetFormat(lldb::Format format) {
0777 if (format != m_format)
0778 ClearUserVisibleData(eClearUserVisibleDataItemsValue);
0779 m_format = format;
0780 }
0781
0782 virtual lldb::LanguageType GetPreferredDisplayLanguage();
0783
0784 void SetPreferredDisplayLanguage(lldb::LanguageType lt) {
0785 m_preferred_display_language = lt;
0786 }
0787
0788 lldb::TypeSummaryImplSP GetSummaryFormat() {
0789 UpdateFormatsIfNeeded();
0790 return m_type_summary_sp;
0791 }
0792
0793 void SetSummaryFormat(lldb::TypeSummaryImplSP format) {
0794 m_type_summary_sp = std::move(format);
0795 ClearUserVisibleData(eClearUserVisibleDataItemsSummary);
0796 }
0797
0798 void SetDerefValobj(ValueObject *deref) { m_deref_valobj = deref; }
0799
0800 ValueObject *GetDerefValobj() { return m_deref_valobj; }
0801
0802 void SetValueFormat(lldb::TypeFormatImplSP format) {
0803 m_type_format_sp = std::move(format);
0804 ClearUserVisibleData(eClearUserVisibleDataItemsValue);
0805 }
0806
0807 lldb::TypeFormatImplSP GetValueFormat() {
0808 UpdateFormatsIfNeeded();
0809 return m_type_format_sp;
0810 }
0811
0812 void SetSyntheticChildren(const lldb::SyntheticChildrenSP &synth_sp) {
0813 if (synth_sp.get() == m_synthetic_children_sp.get())
0814 return;
0815 ClearUserVisibleData(eClearUserVisibleDataItemsSyntheticChildren);
0816 m_synthetic_children_sp = synth_sp;
0817 }
0818
0819 lldb::SyntheticChildrenSP GetSyntheticChildren() {
0820 UpdateFormatsIfNeeded();
0821 return m_synthetic_children_sp;
0822 }
0823
0824
0825
0826
0827
0828 virtual ValueObject *GetParent() { return m_parent; }
0829
0830 virtual const ValueObject *GetParent() const { return m_parent; }
0831
0832 ValueObject *GetNonBaseClassParent();
0833
0834 void SetAddressTypeOfChildren(AddressType at) {
0835 m_address_type_of_ptr_or_ref_children = at;
0836 }
0837
0838 AddressType GetAddressTypeOfChildren();
0839
0840 void SetHasCompleteType() {
0841 m_flags.m_did_calculate_complete_objc_class_type = true;
0842 }
0843
0844
0845
0846
0847
0848
0849
0850
0851
0852
0853
0854
0855
0856
0857
0858 virtual bool MightHaveChildren();
0859
0860 virtual lldb::VariableSP GetVariable() { return nullptr; }
0861
0862 virtual bool IsRuntimeSupportValue();
0863
0864 virtual uint64_t GetLanguageFlags() { return m_language_flags; }
0865
0866 virtual void SetLanguageFlags(uint64_t flags) { m_language_flags = flags; }
0867
0868 protected:
0869 typedef ClusterManager<ValueObject> ValueObjectManager;
0870
0871 class ChildrenManager {
0872 public:
0873 ChildrenManager() = default;
0874
0875 bool HasChildAtIndex(size_t idx) {
0876 std::lock_guard<std::recursive_mutex> guard(m_mutex);
0877 return (m_children.find(idx) != m_children.end());
0878 }
0879
0880 ValueObject *GetChildAtIndex(uint32_t idx) {
0881 std::lock_guard<std::recursive_mutex> guard(m_mutex);
0882 const auto iter = m_children.find(idx);
0883 return ((iter == m_children.end()) ? nullptr : iter->second);
0884 }
0885
0886 void SetChildAtIndex(size_t idx, ValueObject *valobj) {
0887
0888 ChildrenPair pair(idx, valobj);
0889 std::lock_guard<std::recursive_mutex> guard(m_mutex);
0890 m_children.insert(pair);
0891 }
0892
0893 void SetChildrenCount(size_t count) { Clear(count); }
0894
0895 size_t GetChildrenCount() { return m_children_count; }
0896
0897 void Clear(size_t new_count = 0) {
0898 std::lock_guard<std::recursive_mutex> guard(m_mutex);
0899 m_children_count = new_count;
0900 m_children.clear();
0901 }
0902
0903 private:
0904 typedef std::map<size_t, ValueObject *> ChildrenMap;
0905 typedef ChildrenMap::iterator ChildrenIterator;
0906 typedef ChildrenMap::value_type ChildrenPair;
0907 std::recursive_mutex m_mutex;
0908 ChildrenMap m_children;
0909 size_t m_children_count = 0;
0910 };
0911
0912
0913
0914
0915 ValueObject *m_parent = nullptr;
0916
0917
0918 ValueObject *m_root = nullptr;
0919
0920
0921
0922 EvaluationPoint m_update_point;
0923
0924 ConstString m_name;
0925
0926 DataExtractor m_data;
0927 Value m_value;
0928
0929
0930 Status m_error;
0931
0932 std::string m_value_str;
0933
0934 std::string m_old_value_str;
0935
0936 std::string m_location_str;
0937
0938 std::string m_summary_str;
0939
0940
0941 std::string m_object_desc_str;
0942
0943 CompilerType m_override_type;
0944
0945
0946
0947
0948
0949
0950
0951 ValueObjectManager *m_manager = nullptr;
0952
0953 ChildrenManager m_children;
0954 std::map<ConstString, ValueObject *> m_synthetic_children;
0955
0956 ValueObject *m_dynamic_value = nullptr;
0957 ValueObject *m_synthetic_value = nullptr;
0958 ValueObject *m_deref_valobj = nullptr;
0959
0960
0961
0962 lldb::ValueObjectSP m_addr_of_valobj_sp;
0963
0964 lldb::Format m_format = lldb::eFormatDefault;
0965 lldb::Format m_last_format = lldb::eFormatDefault;
0966 uint32_t m_last_format_mgr_revision = 0;
0967 lldb::TypeSummaryImplSP m_type_summary_sp;
0968 lldb::TypeFormatImplSP m_type_format_sp;
0969 lldb::SyntheticChildrenSP m_synthetic_children_sp;
0970 ProcessModID m_user_id_of_forced_summary;
0971 AddressType m_address_type_of_ptr_or_ref_children = eAddressTypeInvalid;
0972
0973 llvm::SmallVector<uint8_t, 16> m_value_checksum;
0974
0975 lldb::LanguageType m_preferred_display_language = lldb::eLanguageTypeUnknown;
0976
0977 uint64_t m_language_flags = 0;
0978
0979
0980 UserID m_id;
0981
0982
0983
0984 struct Bitflags {
0985 bool m_value_is_valid : 1, m_value_did_change : 1,
0986 m_children_count_valid : 1, m_old_value_valid : 1,
0987 m_is_deref_of_parent : 1, m_is_array_item_for_pointer : 1,
0988 m_is_bitfield_for_scalar : 1, m_is_child_at_offset : 1,
0989 m_is_getting_summary : 1, m_did_calculate_complete_objc_class_type : 1,
0990 m_is_synthetic_children_generated : 1;
0991 Bitflags() {
0992 m_value_is_valid = false;
0993 m_value_did_change = false;
0994 m_children_count_valid = false;
0995 m_old_value_valid = false;
0996 m_is_deref_of_parent = false;
0997 m_is_array_item_for_pointer = false;
0998 m_is_bitfield_for_scalar = false;
0999 m_is_child_at_offset = false;
1000 m_is_getting_summary = false;
1001 m_did_calculate_complete_objc_class_type = false;
1002 m_is_synthetic_children_generated = false;
1003 }
1004 } m_flags;
1005
1006 friend class ValueObjectChild;
1007 friend class ExpressionVariable;
1008 friend class Target;
1009 friend class ValueObjectConstResultImpl;
1010 friend class ValueObjectSynthetic;
1011
1012
1013
1014 ValueObject(ExecutionContextScope *exe_scope, ValueObjectManager &manager,
1015 AddressType child_ptr_or_ref_addr_type = eAddressTypeLoad);
1016
1017
1018
1019 ValueObject(ValueObject &parent);
1020
1021 ValueObjectManager *GetManager() { return m_manager; }
1022
1023 virtual bool UpdateValue() = 0;
1024
1025 virtual LazyBool CanUpdateWithInvalidExecutionContext() {
1026 return eLazyBoolCalculate;
1027 }
1028
1029 virtual void CalculateDynamicValue(lldb::DynamicValueType use_dynamic);
1030
1031 virtual lldb::DynamicValueType GetDynamicValueTypeImpl() {
1032 return lldb::eNoDynamicValues;
1033 }
1034
1035 virtual bool HasDynamicValueTypeInfo() { return false; }
1036
1037 virtual void CalculateSyntheticValue();
1038
1039
1040
1041
1042 virtual ValueObject *CreateChildAtIndex(size_t idx);
1043
1044
1045
1046
1047 virtual ValueObject *CreateSyntheticArrayMember(size_t idx);
1048
1049
1050 virtual llvm::Expected<uint32_t>
1051 CalculateNumChildren(uint32_t max = UINT32_MAX) = 0;
1052
1053 void SetNumChildren(uint32_t num_children);
1054
1055 void SetValueDidChange(bool value_changed) {
1056 m_flags.m_value_did_change = value_changed;
1057 }
1058
1059 void SetValueIsValid(bool valid) { m_flags.m_value_is_valid = valid; }
1060
1061 void ClearUserVisibleData(
1062 uint32_t items = ValueObject::eClearUserVisibleDataItemsAllStrings);
1063
1064 void AddSyntheticChild(ConstString key, ValueObject *valobj);
1065
1066 DataExtractor &GetDataExtractor();
1067
1068 void ClearDynamicTypeInformation();
1069
1070
1071
1072 virtual CompilerType GetCompilerTypeImpl() = 0;
1073
1074 const char *GetLocationAsCStringImpl(const Value &value,
1075 const DataExtractor &data);
1076
1077 bool IsChecksumEmpty() { return m_value_checksum.empty(); }
1078
1079 void SetPreferredDisplayLanguageIfNeeded(lldb::LanguageType);
1080
1081 protected:
1082 virtual void DoUpdateChildrenAddressType(ValueObject &valobj) {};
1083
1084 private:
1085 virtual CompilerType MaybeCalculateCompleteType();
1086 void UpdateChildrenAddressType() {
1087 GetRoot()->DoUpdateChildrenAddressType(*this);
1088 }
1089
1090 lldb::ValueObjectSP GetValueForExpressionPath_Impl(
1091 llvm::StringRef expression_cstr,
1092 ExpressionPathScanEndReason *reason_to_stop,
1093 ExpressionPathEndResultType *final_value_type,
1094 const GetValueForExpressionPathOptions &options,
1095 ExpressionPathAftermath *final_task_on_target);
1096
1097 ValueObject(const ValueObject &) = delete;
1098 const ValueObject &operator=(const ValueObject &) = delete;
1099 };
1100
1101 }
1102
1103 #endif