1 //===-- ValueObject.h -------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ValueObject_h_
11 #define liblldb_ValueObject_h_
18 // Other libraries and framework includes
19 #include "llvm/ADT/SmallVector.h"
22 #include "lldb/lldb-private.h"
23 #include "lldb/Core/DataExtractor.h"
24 #include "lldb/Core/Error.h"
25 #include "lldb/Core/Flags.h"
26 #include "lldb/Core/ConstString.h"
27 #include "lldb/Core/UserID.h"
28 #include "lldb/Core/Value.h"
29 #include "lldb/Target/ExecutionContext.h"
30 #include "lldb/Target/ExecutionContextScope.h"
31 #include "lldb/Target/Process.h"
32 #include "lldb/Target/StackID.h"
33 #include "lldb/Utility/SharedCluster.h"
35 namespace lldb_private {
39 /// This abstract class provides an interface to a particular value, be it a register, a local or global variable,
40 /// that is evaluated in some particular scope. The ValueObject also has the capability of being the "child" of
41 /// some other variable object, and in turn of having children.
42 /// If a ValueObject is a root variable object - having no parent - then it must be constructed with respect to some
43 /// particular ExecutionContextScope. If it is a child, it inherits the ExecutionContextScope from its parent.
44 /// The ValueObject will update itself if necessary before fetching its value, summary, object description, etc.
45 /// But it will always update itself in the ExecutionContextScope with which it was originally created.
47 /// A brief note on life cycle management for ValueObjects. This is a little tricky because a ValueObject can contain
48 /// various other ValueObjects - the Dynamic Value, its children, the dereference value, etc. Any one of these can be
49 /// handed out as a shared pointer, but for that contained value object to be valid, the root object and potentially other
50 /// of the value objects need to stay around.
51 /// We solve this problem by handing out shared pointers to the Value Object and any of its dependents using a shared
52 /// ClusterManager. This treats each shared pointer handed out for the entire cluster as a reference to the whole
53 /// cluster. The whole cluster will stay around until the last reference is released.
55 /// The ValueObject mostly handle this automatically, if a value object is made with a Parent ValueObject, then it adds
56 /// itself to the ClusterManager of the parent.
58 /// It does mean that external to the ValueObjects we should only ever make available ValueObjectSP's, never ValueObjects
59 /// or pointers to them. So all the "Root level" ValueObject derived constructors should be private, and
60 /// should implement a Create function that new's up object and returns a Shared Pointer that it gets from the GetSP() method.
62 /// However, if you are making an derived ValueObject that will be contained in a parent value object, you should just
63 /// hold onto a pointer to it internally, and by virtue of passing the parent ValueObject into its constructor, it will
64 /// be added to the ClusterManager for the parent. Then if you ever hand out a Shared Pointer to the contained ValueObject,
65 /// just do so by calling GetSP() on the contained object.
67 class ValueObject : public UserID
71 enum GetExpressionPathFormat
73 eGetExpressionPathFormatDereferencePointers = 1,
74 eGetExpressionPathFormatHonorPointers
77 enum ValueObjectRepresentationStyle
79 eValueObjectRepresentationStyleValue = 1,
80 eValueObjectRepresentationStyleSummary,
81 eValueObjectRepresentationStyleLanguageSpecific,
82 eValueObjectRepresentationStyleLocation,
83 eValueObjectRepresentationStyleChildrenCount,
84 eValueObjectRepresentationStyleType,
85 eValueObjectRepresentationStyleName,
86 eValueObjectRepresentationStyleExpressionPath
89 enum ExpressionPathScanEndReason
91 eExpressionPathScanEndReasonEndOfString = 1, // out of data to parse
92 eExpressionPathScanEndReasonNoSuchChild, // child element not found
93 eExpressionPathScanEndReasonNoSuchSyntheticChild, // (synthetic) child element not found
94 eExpressionPathScanEndReasonEmptyRangeNotAllowed, // [] only allowed for arrays
95 eExpressionPathScanEndReasonDotInsteadOfArrow, // . used when -> should be used
96 eExpressionPathScanEndReasonArrowInsteadOfDot, // -> used when . should be used
97 eExpressionPathScanEndReasonFragileIVarNotAllowed, // ObjC ivar expansion not allowed
98 eExpressionPathScanEndReasonRangeOperatorNotAllowed, // [] not allowed by options
99 eExpressionPathScanEndReasonRangeOperatorInvalid, // [] not valid on objects other than scalars, pointers or arrays
100 eExpressionPathScanEndReasonArrayRangeOperatorMet, // [] is good for arrays, but I cannot parse it
101 eExpressionPathScanEndReasonBitfieldRangeOperatorMet, // [] is good for bitfields, but I cannot parse after it
102 eExpressionPathScanEndReasonUnexpectedSymbol, // something is malformed in the expression
103 eExpressionPathScanEndReasonTakingAddressFailed, // impossible to apply & operator
104 eExpressionPathScanEndReasonDereferencingFailed, // impossible to apply * operator
105 eExpressionPathScanEndReasonRangeOperatorExpanded, // [] was expanded into a VOList
106 eExpressionPathScanEndReasonSyntheticValueMissing, // getting the synthetic children failed
107 eExpressionPathScanEndReasonUnknown = 0xFFFF
110 enum ExpressionPathEndResultType
112 eExpressionPathEndResultTypePlain = 1, // anything but...
113 eExpressionPathEndResultTypeBitfield, // a bitfield
114 eExpressionPathEndResultTypeBoundedRange, // a range [low-high]
115 eExpressionPathEndResultTypeUnboundedRange, // a range []
116 eExpressionPathEndResultTypeValueObjectList, // several items in a VOList
117 eExpressionPathEndResultTypeInvalid = 0xFFFF
120 enum ExpressionPathAftermath
122 eExpressionPathAftermathNothing = 1, // just return it
123 eExpressionPathAftermathDereference, // dereference the target
124 eExpressionPathAftermathTakeAddress // take target's address
127 enum ClearUserVisibleDataItems
129 eClearUserVisibleDataItemsNothing = 1u << 0,
130 eClearUserVisibleDataItemsValue = 1u << 1,
131 eClearUserVisibleDataItemsSummary = 1u << 2,
132 eClearUserVisibleDataItemsLocation = 1u << 3,
133 eClearUserVisibleDataItemsDescription = 1u << 4,
134 eClearUserVisibleDataItemsSyntheticChildren = 1u << 5,
135 eClearUserVisibleDataItemsValidator = 1u << 6,
136 eClearUserVisibleDataItemsAllStrings = eClearUserVisibleDataItemsValue | eClearUserVisibleDataItemsSummary | eClearUserVisibleDataItemsLocation | eClearUserVisibleDataItemsDescription,
137 eClearUserVisibleDataItemsAll = 0xFFFF
140 struct GetValueForExpressionPathOptions
142 bool m_check_dot_vs_arrow_syntax;
143 bool m_no_fragile_ivar;
144 bool m_allow_bitfields_syntax;
145 bool m_no_synthetic_children;
147 GetValueForExpressionPathOptions(bool dot = false,
148 bool no_ivar = false,
149 bool bitfield = true,
150 bool no_synth = false) :
151 m_check_dot_vs_arrow_syntax(dot),
152 m_no_fragile_ivar(no_ivar),
153 m_allow_bitfields_syntax(bitfield),
154 m_no_synthetic_children(no_synth)
158 GetValueForExpressionPathOptions&
159 DoCheckDotVsArrowSyntax()
161 m_check_dot_vs_arrow_syntax = true;
165 GetValueForExpressionPathOptions&
166 DontCheckDotVsArrowSyntax()
168 m_check_dot_vs_arrow_syntax = false;
172 GetValueForExpressionPathOptions&
175 m_no_fragile_ivar = false;
179 GetValueForExpressionPathOptions&
180 DontAllowFragileIVar()
182 m_no_fragile_ivar = true;
186 GetValueForExpressionPathOptions&
187 DoAllowBitfieldSyntax()
189 m_allow_bitfields_syntax = true;
193 GetValueForExpressionPathOptions&
194 DontAllowBitfieldSyntax()
196 m_allow_bitfields_syntax = false;
200 GetValueForExpressionPathOptions&
201 DoAllowSyntheticChildren()
203 m_no_synthetic_children = false;
207 GetValueForExpressionPathOptions&
208 DontAllowSyntheticChildren()
210 m_no_synthetic_children = true;
214 static const GetValueForExpressionPathOptions
217 static GetValueForExpressionPathOptions g_default_options;
219 return g_default_options;
224 class EvaluationPoint
230 EvaluationPoint (ExecutionContextScope *exe_scope, bool use_selected = false);
232 EvaluationPoint (const EvaluationPoint &rhs);
236 const ExecutionContextRef &
237 GetExecutionContextRef() const
239 return m_exe_ctx_ref;
242 // Set the EvaluationPoint to the values in exe_scope,
243 // Return true if the Evaluation Point changed.
244 // Since the ExecutionContextScope is always going to be valid currently,
245 // the Updated Context will also always be valid.
248 // SetContext (ExecutionContextScope *exe_scope);
254 m_mod_id.SetInvalid();
260 return !m_mod_id.IsValid();
270 SetUpdateID (ProcessModID new_id)
278 m_needs_update = true;
287 SyncWithProcessState();
288 return m_needs_update;
294 if (!m_mod_id.IsValid())
296 else if (SyncWithProcessState ())
298 if (!m_mod_id.IsValid())
307 // Use the stop id to mark us as invalid, leave the thread id and the stack id around for logging and
309 m_mod_id.SetInvalid();
311 // Can't update an invalid state.
312 m_needs_update = false;
318 SyncWithProcessState ();
320 ProcessModID m_mod_id; // This is the stop id when this ValueObject was last evaluated.
321 ExecutionContextRef m_exe_ctx_ref;
325 const EvaluationPoint &
326 GetUpdatePoint () const
328 return m_update_point;
334 return m_update_point;
337 const ExecutionContextRef &
338 GetExecutionContextRef() const
340 return m_update_point.GetExecutionContextRef();
346 return m_update_point.GetExecutionContextRef().GetTargetSP();
352 return m_update_point.GetExecutionContextRef().GetProcessSP();
358 return m_update_point.GetExecutionContextRef().GetThreadSP();
364 return m_update_point.GetExecutionContextRef().GetFrameSP();
370 virtual ~ValueObject();
375 // this vends a TypeImpl that is useful at the SB API layer
382 //------------------------------------------------------------------
383 // Subclasses must implement the functions below.
384 //------------------------------------------------------------------
388 virtual lldb::ValueType
389 GetValueType() const = 0;
391 //------------------------------------------------------------------
392 // Subclasses can implement the functions below.
393 //------------------------------------------------------------------
398 GetDisplayTypeName();
401 GetQualifiedTypeName();
403 virtual lldb::LanguageType
404 GetObjectRuntimeLanguage();
407 GetTypeInfo (ClangASTType *pointee_or_element_clang_type = NULL);
419 IsPointerOrReferenceType ();
422 IsPossibleDynamicType ();
434 IsBaseClass (uint32_t& depth);
437 IsDereferenceOfParent ()
443 IsIntegerType (bool &is_signed);
446 GetBaseClassPath (Stream &s);
449 GetExpressionPath (Stream &s, bool qualify_cxx_base_classes, GetExpressionPathFormat = eGetExpressionPathFormatDereferencePointers);
452 GetValueForExpressionPath(const char* expression,
453 const char** first_unparsed = NULL,
454 ExpressionPathScanEndReason* reason_to_stop = NULL,
455 ExpressionPathEndResultType* final_value_type = NULL,
456 const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(),
457 ExpressionPathAftermath* final_task_on_target = NULL);
460 GetValuesForExpressionPath(const char* expression,
461 lldb::ValueObjectListSP& list,
462 const char** first_unparsed = NULL,
463 ExpressionPathScanEndReason* reason_to_stop = NULL,
464 ExpressionPathEndResultType* final_value_type = NULL,
465 const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(),
466 ExpressionPathAftermath* final_task_on_target = NULL);
474 virtual lldb::offset_t
481 GetBitfieldBitSize ()
487 GetBitfieldBitOffset ()
495 return (GetBitfieldBitSize() != 0) || (GetBitfieldBitOffset() != 0);
499 IsArrayItemForPointer()
501 return m_is_array_item_for_pointer;
505 GetValueAsCString ();
508 GetValueAsCString (const lldb_private::TypeFormatImpl& format,
509 std::string& destination);
512 GetValueAsCString (lldb::Format format,
513 std::string& destination);
516 GetValueAsUnsigned (uint64_t fail_value, bool *success = NULL);
519 GetValueAsSigned (int64_t fail_value, bool *success = NULL);
522 SetValueFromCString (const char *value_str, Error& error);
524 // Return the module associated with this value object in case the
525 // value is from an executable file and might have its data in
526 // sections of the file. This can be used for variables.
527 virtual lldb::ModuleSP
534 GetDeclaration (Declaration &decl);
536 //------------------------------------------------------------------
537 // The functions below should NOT be modified by subclasses
538 //------------------------------------------------------------------
545 virtual lldb::ValueObjectSP
546 GetChildAtIndex (size_t idx, bool can_create);
548 // this will always create the children if necessary
550 GetChildAtIndexPath (const std::initializer_list<size_t> &idxs,
551 size_t* index_of_error = NULL);
554 GetChildAtIndexPath (const std::vector<size_t> &idxs,
555 size_t* index_of_error = NULL);
558 GetChildAtIndexPath (const std::initializer_list< std::pair<size_t, bool> > &idxs,
559 size_t* index_of_error = NULL);
562 GetChildAtIndexPath (const std::vector< std::pair<size_t, bool> > &idxs,
563 size_t* index_of_error = NULL);
565 // this will always create the children if necessary
567 GetChildAtNamePath (const std::initializer_list<ConstString> &names,
568 ConstString* name_of_error = NULL);
571 GetChildAtNamePath (const std::vector<ConstString> &names,
572 ConstString* name_of_error = NULL);
575 GetChildAtNamePath (const std::initializer_list< std::pair<ConstString, bool> > &names,
576 ConstString* name_of_error = NULL);
579 GetChildAtNamePath (const std::vector< std::pair<ConstString, bool> > &names,
580 ConstString* name_of_error = NULL);
582 virtual lldb::ValueObjectSP
583 GetChildMemberWithName (const ConstString &name, bool can_create);
586 GetIndexOfChildWithName (const ConstString &name);
598 ResolveValue (Scalar &scalar);
601 GetLocationAsCString ();
604 GetSummaryAsCString ();
607 GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
608 std::string& destination);
611 GetSummaryAsCString (std::string& destination,
612 const TypeSummaryOptions& options);
615 GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
616 std::string& destination,
617 const TypeSummaryOptions& options);
619 std::pair<TypeValidatorResult, std::string>
620 GetValidationStatus ();
623 GetObjectDescription ();
626 HasSpecialPrintableRepresentation (ValueObjectRepresentationStyle val_obj_display,
627 lldb::Format custom_format);
629 enum PrintableRepresentationSpecialCases
631 ePrintableRepresentationSpecialCasesDisable = 0,
632 ePrintableRepresentationSpecialCasesAllow = 1,
633 ePrintableRepresentationSpecialCasesOnly = 3
637 DumpPrintableRepresentation (Stream& s,
638 ValueObjectRepresentationStyle val_obj_display = eValueObjectRepresentationStyleSummary,
639 lldb::Format custom_format = lldb::eFormatInvalid,
640 PrintableRepresentationSpecialCases special = ePrintableRepresentationSpecialCasesAllow,
641 bool do_dump_error = true);
643 GetValueIsValid () const;
646 GetValueDidChange ();
649 UpdateValueIfNeeded (bool update_format = true);
652 UpdateFormatsIfNeeded();
657 return m_manager->GetSharedPointer(this);
661 SetName (const ConstString &name);
664 GetAddressOf (bool scalar_is_load_address = true,
665 AddressType *address_type = NULL);
668 GetPointerValue (AddressType *address_type = NULL);
671 GetSyntheticChild (const ConstString &key) const;
674 GetSyntheticArrayMember (size_t index, bool can_create);
677 GetSyntheticArrayMemberFromPointer (size_t index, bool can_create);
680 GetSyntheticArrayMemberFromArray (size_t index, bool can_create);
683 GetSyntheticBitFieldChild (uint32_t from, uint32_t to, bool can_create);
686 GetSyntheticExpressionPathChild(const char* expression, bool can_create);
688 virtual lldb::ValueObjectSP
689 GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create);
691 virtual lldb::ValueObjectSP
692 GetSyntheticBase (uint32_t offset, const ClangASTType& type, bool can_create);
694 virtual lldb::ValueObjectSP
695 GetDynamicValue (lldb::DynamicValueType valueType);
697 lldb::DynamicValueType
698 GetDynamicValueType ();
700 virtual lldb::ValueObjectSP
703 virtual lldb::ValueObjectSP
704 GetNonSyntheticValue ();
707 GetSyntheticValue (bool use_synthetic = true);
713 IsSynthetic() { return false; }
716 GetQualifiedRepresentationIfAvailable (lldb::DynamicValueType dynValue,
719 virtual lldb::ValueObjectSP
720 CreateConstantValue (const ConstString &name);
722 virtual lldb::ValueObjectSP
723 Dereference (Error &error);
725 virtual lldb::ValueObjectSP
726 AddressOf (Error &error);
731 return LLDB_INVALID_ADDRESS;
735 SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
736 AddressType address_type = eAddressTypeLoad)
740 // Find the address of the C++ vtable pointer
742 GetCPPVTableAddress(AddressType &address_type);
744 virtual lldb::ValueObjectSP
745 Cast (const ClangASTType &clang_ast_type);
747 virtual lldb::ValueObjectSP
748 CastPointerType (const char *name,
749 ClangASTType &ast_type);
751 virtual lldb::ValueObjectSP
752 CastPointerType (const char *name,
753 lldb::TypeSP &type_sp);
755 // The backing bits of this value object were updated, clear any
756 // descriptive string, so we know we have to refetch them
760 ClearUserVisibleData(eClearUserVisibleDataItemsValue |
761 eClearUserVisibleDataItemsSummary |
762 eClearUserVisibleDataItemsDescription);
772 DoesProvideSyntheticValue ()
778 IsSyntheticChildrenGenerated ();
781 SetSyntheticChildrenGenerated (bool b);
783 virtual SymbolContextScope *
784 GetSymbolContextScope();
791 const DumpValueObjectOptions& options);
793 static lldb::ValueObjectSP
794 CreateValueObjectFromExpression (const char* name,
795 const char* expression,
796 const ExecutionContext& exe_ctx);
798 static lldb::ValueObjectSP
799 CreateValueObjectFromExpression (const char* name,
800 const char* expression,
801 const ExecutionContext& exe_ctx,
802 const EvaluateExpressionOptions& options);
804 static lldb::ValueObjectSP
805 CreateValueObjectFromAddress (const char* name,
807 const ExecutionContext& exe_ctx,
810 static lldb::ValueObjectSP
811 CreateValueObjectFromData (const char* name,
812 const DataExtractor& data,
813 const ExecutionContext& exe_ctx,
817 LogValueObject (Log *log);
820 LogValueObject (Log *log,
821 const DumpValueObjectOptions& options);
827 // returns true if this is a char* or a char[]
828 // if it is a char* and check_pointer is true,
829 // it also checks that the pointer is valid
831 IsCStringContainer (bool check_pointer = false);
834 ReadPointedString (lldb::DataBufferSP& buffer_sp,
836 uint32_t max_length = 0,
837 bool honor_array = true,
838 lldb::Format item_format = lldb::eFormatCharArray);
841 GetPointeeData (DataExtractor& data,
842 uint32_t item_idx = 0,
843 uint32_t item_count = 1);
846 GetData (DataExtractor& data, Error &error);
849 SetData (DataExtractor &data, Error &error);
852 GetIsConstant () const
854 return m_update_point.IsConstant();
860 m_update_point.SetIsConstant();
867 SetFormat (lldb::Format format)
869 if (format != m_format)
870 ClearUserVisibleData(eClearUserVisibleDataItemsValue);
875 virtual lldb::LanguageType
876 GetPreferredDisplayLanguage ();
878 lldb::TypeSummaryImplSP
881 UpdateFormatsIfNeeded();
882 return m_type_summary_sp;
886 SetSummaryFormat(lldb::TypeSummaryImplSP format)
888 m_type_summary_sp = format;
889 ClearUserVisibleData(eClearUserVisibleDataItemsSummary);
892 lldb::TypeValidatorImplSP
895 UpdateFormatsIfNeeded();
896 return m_type_validator_sp;
900 SetValidator(lldb::TypeValidatorImplSP format)
902 m_type_validator_sp = format;
903 ClearUserVisibleData(eClearUserVisibleDataItemsValidator);
907 SetValueFormat(lldb::TypeFormatImplSP format)
909 m_type_format_sp = format;
910 ClearUserVisibleData(eClearUserVisibleDataItemsValue);
913 lldb::TypeFormatImplSP
916 UpdateFormatsIfNeeded();
917 return m_type_format_sp;
921 SetSyntheticChildren(const lldb::SyntheticChildrenSP &synth_sp)
923 if (synth_sp.get() == m_synthetic_children_sp.get())
925 ClearUserVisibleData(eClearUserVisibleDataItemsSyntheticChildren);
926 m_synthetic_children_sp = synth_sp;
929 lldb::SyntheticChildrenSP
930 GetSyntheticChildren()
932 UpdateFormatsIfNeeded();
933 return m_synthetic_children_sp;
936 // Use GetParent for display purposes, but if you want to tell the parent to update itself
937 // then use m_parent. The ValueObjectDynamicValue's parent is not the correct parent for
938 // displaying, they are really siblings, so for display it needs to route through to its grandparent.
939 virtual ValueObject *
945 virtual const ValueObject *
952 GetNonBaseClassParent();
955 SetAddressTypeOfChildren(AddressType at)
957 m_address_type_of_ptr_or_ref_children = at;
961 GetAddressTypeOfChildren();
966 m_did_calculate_complete_objc_class_type = true;
969 //------------------------------------------------------------------
970 /// Find out if a ValueObject might have children.
972 /// This call is much more efficient than CalculateNumChildren() as
973 /// it doesn't need to complete the underlying type. This is designed
974 /// to be used in a UI environment in order to detect if the
975 /// disclosure triangle should be displayed or not.
977 /// This function returns true for class, union, structure,
978 /// pointers, references, arrays and more. Again, it does so without
979 /// doing any expensive type completion.
982 /// Returns \b true if the ValueObject might have children, or \b
984 //------------------------------------------------------------------
989 typedef ClusterManager<ValueObject> ValueObjectManager;
991 class ChildrenManager
995 m_mutex(Mutex::eMutexTypeRecursive),
1001 HasChildAtIndex (size_t idx)
1003 Mutex::Locker locker(m_mutex);
1004 ChildrenIterator iter = m_children.find(idx);
1005 ChildrenIterator end = m_children.end();
1006 return (iter != end);
1010 GetChildAtIndex (size_t idx)
1012 Mutex::Locker locker(m_mutex);
1013 ChildrenIterator iter = m_children.find(idx);
1014 ChildrenIterator end = m_children.end();
1018 return iter->second;
1022 SetChildAtIndex (size_t idx, ValueObject* valobj)
1024 ChildrenPair pair(idx,valobj); // we do not need to be mutex-protected to make a pair
1025 Mutex::Locker locker(m_mutex);
1026 m_children.insert(pair);
1030 SetChildrenCount (size_t count)
1038 return m_children_count;
1042 Clear(size_t new_count = 0)
1044 Mutex::Locker locker(m_mutex);
1045 m_children_count = new_count;
1050 typedef std::map<size_t, ValueObject*> ChildrenMap;
1051 typedef ChildrenMap::iterator ChildrenIterator;
1052 typedef ChildrenMap::value_type ChildrenPair;
1054 ChildrenMap m_children;
1055 size_t m_children_count;
1058 //------------------------------------------------------------------
1059 // Classes that inherit from ValueObject can see and modify these
1060 //------------------------------------------------------------------
1061 ValueObject * m_parent; // The parent value object, or NULL if this has no parent
1062 ValueObject * m_root; // The root of the hierarchy for this ValueObject (or NULL if never calculated)
1063 EvaluationPoint m_update_point; // Stores both the stop id and the full context at which this value was last
1064 // updated. When we are asked to update the value object, we check whether
1065 // the context & stop id are the same before updating.
1066 ConstString m_name; // The name of this object
1067 DataExtractor m_data; // A data extractor that can be used to extract the value.
1069 Error m_error; // An error object that can describe any errors that occur when updating values.
1070 std::string m_value_str; // Cached value string that will get cleared if/when the value is updated.
1071 std::string m_old_value_str;// Cached old value string from the last time the value was gotten
1072 std::string m_location_str; // Cached location string that will get cleared if/when the value is updated.
1073 std::string m_summary_str; // Cached summary string that will get cleared if/when the value is updated.
1074 std::string m_object_desc_str; // Cached result of the "object printer". This differs from the summary
1075 // in that the summary is consed up by us, the object_desc_string is builtin.
1077 llvm::Optional<std::pair<TypeValidatorResult, std::string>> m_validation_result;
1079 ClangASTType m_override_type;// If the type of the value object should be overridden, the type to impose.
1081 ValueObjectManager *m_manager; // This object is managed by the root object (any ValueObject that gets created
1082 // without a parent.) The manager gets passed through all the generations of
1083 // dependent objects, and will keep the whole cluster of objects alive as long
1084 // as a shared pointer to any of them has been handed out. Shared pointers to
1085 // value objects must always be made with the GetSP method.
1087 ChildrenManager m_children;
1088 std::map<ConstString, ValueObject *> m_synthetic_children;
1090 ValueObject* m_dynamic_value;
1091 ValueObject* m_synthetic_value;
1092 ValueObject* m_deref_valobj;
1094 lldb::ValueObjectSP m_addr_of_valobj_sp; // We have to hold onto a shared pointer to this one because it is created
1095 // as an independent ValueObjectConstResult, which isn't managed by us.
1097 lldb::Format m_format;
1098 lldb::Format m_last_format;
1099 uint32_t m_last_format_mgr_revision;
1100 lldb::TypeSummaryImplSP m_type_summary_sp;
1101 lldb::TypeFormatImplSP m_type_format_sp;
1102 lldb::SyntheticChildrenSP m_synthetic_children_sp;
1103 lldb::TypeValidatorImplSP m_type_validator_sp;
1104 ProcessModID m_user_id_of_forced_summary;
1105 AddressType m_address_type_of_ptr_or_ref_children;
1107 llvm::SmallVector<uint8_t, 16> m_value_checksum;
1109 bool m_value_is_valid:1,
1110 m_value_did_change:1,
1111 m_children_count_valid:1,
1112 m_old_value_valid:1,
1113 m_is_deref_of_parent:1,
1114 m_is_array_item_for_pointer:1,
1115 m_is_bitfield_for_scalar:1,
1116 m_is_child_at_offset:1,
1117 m_is_getting_summary:1,
1118 m_did_calculate_complete_objc_class_type:1,
1119 m_is_synthetic_children_generated:1;
1121 friend class ClangExpressionDeclMap; // For GetValue
1122 friend class ClangExpressionVariable; // For SetName
1123 friend class Target; // For SetName
1124 friend class ValueObjectConstResultImpl;
1126 //------------------------------------------------------------------
1127 // Constructors and Destructors
1128 //------------------------------------------------------------------
1130 // Use the no-argument constructor to make a constant variable object (with no ExecutionContextScope.)
1134 // Use this constructor to create a "root variable object". The ValueObject will be locked to this context
1135 // through-out its lifespan.
1137 ValueObject (ExecutionContextScope *exe_scope,
1138 AddressType child_ptr_or_ref_addr_type = eAddressTypeLoad);
1140 // Use this constructor to create a ValueObject owned by another ValueObject. It will inherit the ExecutionContext
1143 ValueObject (ValueObject &parent);
1145 ValueObjectManager *
1155 CalculateDynamicValue (lldb::DynamicValueType use_dynamic);
1157 virtual lldb::DynamicValueType
1158 GetDynamicValueTypeImpl ()
1160 return lldb::eNoDynamicValues;
1164 HasDynamicValueTypeInfo ()
1170 CalculateSyntheticValue (bool use_synthetic = true);
1172 // Should only be called by ValueObject::GetChildAtIndex()
1173 // Returns a ValueObject managed by this ValueObject's manager.
1174 virtual ValueObject *
1175 CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index);
1177 // Should only be called by ValueObject::GetNumChildren()
1179 CalculateNumChildren() = 0;
1182 SetNumChildren (size_t num_children);
1185 SetValueDidChange (bool value_changed);
1188 SetValueIsValid (bool valid);
1191 ClearUserVisibleData(uint32_t items = ValueObject::eClearUserVisibleDataItemsAllStrings);
1194 AddSyntheticChild (const ConstString &key,
1195 ValueObject *valobj);
1198 GetDataExtractor ();
1201 ClearDynamicTypeInformation ();
1203 //------------------------------------------------------------------
1204 // Subclasses must implement the functions below.
1205 //------------------------------------------------------------------
1207 virtual ClangASTType
1208 GetClangTypeImpl () = 0;
1211 GetLocationAsCStringImpl (const Value& value,
1212 const DataExtractor& data);
1218 //------------------------------------------------------------------
1219 // For ValueObject only
1220 //------------------------------------------------------------------
1222 virtual ClangASTType
1223 MaybeCalculateCompleteType ();
1226 GetValueForExpressionPath_Impl(const char* expression_cstr,
1227 const char** first_unparsed,
1228 ExpressionPathScanEndReason* reason_to_stop,
1229 ExpressionPathEndResultType* final_value_type,
1230 const GetValueForExpressionPathOptions& options,
1231 ExpressionPathAftermath* final_task_on_target);
1233 // this method will ONLY expand [] expressions into a VOList and return
1234 // the number of elements it added to the VOList
1235 // it will NOT loop through expanding the follow-up of the expression_cstr
1236 // for all objects in the list
1238 ExpandArraySliceExpression(const char* expression_cstr,
1239 const char** first_unparsed,
1240 lldb::ValueObjectSP root,
1241 lldb::ValueObjectListSP& list,
1242 ExpressionPathScanEndReason* reason_to_stop,
1243 ExpressionPathEndResultType* final_value_type,
1244 const GetValueForExpressionPathOptions& options,
1245 ExpressionPathAftermath* final_task_on_target);
1248 DISALLOW_COPY_AND_ASSIGN (ValueObject);
1252 } // namespace lldb_private
1254 #endif // liblldb_ValueObject_h_