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_
15 #include <initializer_list>
18 // Other libraries and framework includes
21 #include "lldb/lldb-private.h"
22 #include "lldb/Core/DataExtractor.h"
23 #include "lldb/Core/Error.h"
24 #include "lldb/Core/Flags.h"
25 #include "lldb/Core/ConstString.h"
26 #include "lldb/Core/UserID.h"
27 #include "lldb/Core/Value.h"
28 #include "lldb/Target/ExecutionContext.h"
29 #include "lldb/Target/ExecutionContextScope.h"
30 #include "lldb/Target/Process.h"
31 #include "lldb/Target/StackID.h"
32 #include "lldb/Utility/SharedCluster.h"
34 namespace lldb_private {
38 /// This abstract class provides an interface to a particular value, be it a register, a local or global variable,
39 /// that is evaluated in some particular scope. The ValueObject also has the capibility of being the "child" of
40 /// some other variable object, and in turn of having children.
41 /// If a ValueObject is a root variable object - having no parent - then it must be constructed with respect to some
42 /// particular ExecutionContextScope. If it is a child, it inherits the ExecutionContextScope from its parent.
43 /// The ValueObject will update itself if necessary before fetching its value, summary, object description, etc.
44 /// But it will always update itself in the ExecutionContextScope with which it was originally created.
46 /// A brief note on life cycle management for ValueObjects. This is a little tricky because a ValueObject can contain
47 /// various other ValueObjects - the Dynamic Value, its children, the dereference value, etc. Any one of these can be
48 /// handed out as a shared pointer, but for that contained value object to be valid, the root object and potentially other
49 /// of the value objects need to stay around.
50 /// We solve this problem by handing out shared pointers to the Value Object and any of its dependents using a shared
51 /// ClusterManager. This treats each shared pointer handed out for the entire cluster as a reference to the whole
52 /// cluster. The whole cluster will stay around until the last reference is released.
54 /// The ValueObject mostly handle this automatically, if a value object is made with a Parent ValueObject, then it adds
55 /// itself to the ClusterManager of the parent.
57 /// It does mean that external to the ValueObjects we should only ever make available ValueObjectSP's, never ValueObjects
58 /// or pointers to them. So all the "Root level" ValueObject derived constructors should be private, and
59 /// should implement a Create function that new's up object and returns a Shared Pointer that it gets from the GetSP() method.
61 /// However, if you are making an derived ValueObject that will be contained in a parent value object, you should just
62 /// hold onto a pointer to it internally, and by virtue of passing the parent ValueObject into its constructor, it will
63 /// be added to the ClusterManager for the parent. Then if you ever hand out a Shared Pointer to the contained ValueObject,
64 /// just do so by calling GetSP() on the contained object.
66 class ValueObject : public UserID
70 enum GetExpressionPathFormat
72 eGetExpressionPathFormatDereferencePointers = 1,
73 eGetExpressionPathFormatHonorPointers
76 enum ValueObjectRepresentationStyle
78 eValueObjectRepresentationStyleValue = 1,
79 eValueObjectRepresentationStyleSummary,
80 eValueObjectRepresentationStyleLanguageSpecific,
81 eValueObjectRepresentationStyleLocation,
82 eValueObjectRepresentationStyleChildrenCount,
83 eValueObjectRepresentationStyleType,
84 eValueObjectRepresentationStyleName,
85 eValueObjectRepresentationStyleExpressionPath
88 enum ExpressionPathScanEndReason
90 eExpressionPathScanEndReasonEndOfString = 1, // out of data to parse
91 eExpressionPathScanEndReasonNoSuchChild, // child element not found
92 eExpressionPathScanEndReasonEmptyRangeNotAllowed, // [] only allowed for arrays
93 eExpressionPathScanEndReasonDotInsteadOfArrow, // . used when -> should be used
94 eExpressionPathScanEndReasonArrowInsteadOfDot, // -> used when . should be used
95 eExpressionPathScanEndReasonFragileIVarNotAllowed, // ObjC ivar expansion not allowed
96 eExpressionPathScanEndReasonRangeOperatorNotAllowed, // [] not allowed by options
97 eExpressionPathScanEndReasonRangeOperatorInvalid, // [] not valid on objects other than scalars, pointers or arrays
98 eExpressionPathScanEndReasonArrayRangeOperatorMet, // [] is good for arrays, but I cannot parse it
99 eExpressionPathScanEndReasonBitfieldRangeOperatorMet, // [] is good for bitfields, but I cannot parse after it
100 eExpressionPathScanEndReasonUnexpectedSymbol, // something is malformed in the expression
101 eExpressionPathScanEndReasonTakingAddressFailed, // impossible to apply & operator
102 eExpressionPathScanEndReasonDereferencingFailed, // impossible to apply * operator
103 eExpressionPathScanEndReasonRangeOperatorExpanded, // [] was expanded into a VOList
104 eExpressionPathScanEndReasonSyntheticValueMissing, // getting the synthetic children failed
105 eExpressionPathScanEndReasonUnknown = 0xFFFF
108 enum ExpressionPathEndResultType
110 eExpressionPathEndResultTypePlain = 1, // anything but...
111 eExpressionPathEndResultTypeBitfield, // a bitfield
112 eExpressionPathEndResultTypeBoundedRange, // a range [low-high]
113 eExpressionPathEndResultTypeUnboundedRange, // a range []
114 eExpressionPathEndResultTypeValueObjectList, // several items in a VOList
115 eExpressionPathEndResultTypeInvalid = 0xFFFF
118 enum ExpressionPathAftermath
120 eExpressionPathAftermathNothing = 1, // just return it
121 eExpressionPathAftermathDereference, // dereference the target
122 eExpressionPathAftermathTakeAddress // take target's address
125 enum ClearUserVisibleDataItems
127 eClearUserVisibleDataItemsNothing = 1u << 0,
128 eClearUserVisibleDataItemsValue = 1u << 1,
129 eClearUserVisibleDataItemsSummary = 1u << 2,
130 eClearUserVisibleDataItemsLocation = 1u << 3,
131 eClearUserVisibleDataItemsDescription = 1u << 4,
132 eClearUserVisibleDataItemsSyntheticChildren = 1u << 5,
133 eClearUserVisibleDataItemsAllStrings = eClearUserVisibleDataItemsValue | eClearUserVisibleDataItemsSummary | eClearUserVisibleDataItemsLocation | eClearUserVisibleDataItemsDescription,
134 eClearUserVisibleDataItemsAll = 0xFFFF
137 struct GetValueForExpressionPathOptions
139 bool m_check_dot_vs_arrow_syntax;
140 bool m_no_fragile_ivar;
141 bool m_allow_bitfields_syntax;
142 bool m_no_synthetic_children;
144 GetValueForExpressionPathOptions(bool dot = false,
145 bool no_ivar = false,
146 bool bitfield = true,
147 bool no_synth = false) :
148 m_check_dot_vs_arrow_syntax(dot),
149 m_no_fragile_ivar(no_ivar),
150 m_allow_bitfields_syntax(bitfield),
151 m_no_synthetic_children(no_synth)
155 GetValueForExpressionPathOptions&
156 DoCheckDotVsArrowSyntax()
158 m_check_dot_vs_arrow_syntax = true;
162 GetValueForExpressionPathOptions&
163 DontCheckDotVsArrowSyntax()
165 m_check_dot_vs_arrow_syntax = false;
169 GetValueForExpressionPathOptions&
172 m_no_fragile_ivar = false;
176 GetValueForExpressionPathOptions&
177 DontAllowFragileIVar()
179 m_no_fragile_ivar = true;
183 GetValueForExpressionPathOptions&
184 DoAllowBitfieldSyntax()
186 m_allow_bitfields_syntax = true;
190 GetValueForExpressionPathOptions&
191 DontAllowBitfieldSyntax()
193 m_allow_bitfields_syntax = false;
197 GetValueForExpressionPathOptions&
198 DoAllowSyntheticChildren()
200 m_no_synthetic_children = false;
204 GetValueForExpressionPathOptions&
205 DontAllowSyntheticChildren()
207 m_no_synthetic_children = true;
211 static const GetValueForExpressionPathOptions
214 static GetValueForExpressionPathOptions g_default_options;
216 return g_default_options;
221 struct DumpValueObjectOptions
223 uint32_t m_max_ptr_depth;
224 uint32_t m_max_depth;
226 bool m_show_location;
228 lldb::DynamicValueType m_use_dynamic;
229 bool m_use_synthetic;
230 bool m_scope_already_checked;
232 uint32_t m_omit_summary_depth;
234 lldb::Format m_format;
235 lldb::TypeSummaryImplSP m_summary_sp;
236 std::string m_root_valobj_name;
237 bool m_hide_root_type;
241 DumpValueObjectOptions() :
243 m_max_depth(UINT32_MAX),
245 m_show_location(false),
247 m_use_dynamic(lldb::eNoDynamicValues),
248 m_use_synthetic(true),
249 m_scope_already_checked(false),
250 m_flat_output(false),
251 m_omit_summary_depth(0),
253 m_format (lldb::eFormatDefault),
255 m_root_valobj_name(),
256 m_hide_root_type(false), // provide a special compact display for "po"
257 m_hide_name(false), // provide a special compact display for "po"
258 m_hide_value(false) // provide a special compact display for "po"
261 static const DumpValueObjectOptions
264 static DumpValueObjectOptions g_default_options;
266 return g_default_options;
269 DumpValueObjectOptions (const DumpValueObjectOptions& rhs) :
270 m_max_ptr_depth(rhs.m_max_ptr_depth),
271 m_max_depth(rhs.m_max_depth),
272 m_show_types(rhs.m_show_types),
273 m_show_location(rhs.m_show_location),
274 m_use_objc(rhs.m_use_objc),
275 m_use_dynamic(rhs.m_use_dynamic),
276 m_use_synthetic(rhs.m_use_synthetic),
277 m_scope_already_checked(rhs.m_scope_already_checked),
278 m_flat_output(rhs.m_flat_output),
279 m_omit_summary_depth(rhs.m_omit_summary_depth),
280 m_ignore_cap(rhs.m_ignore_cap),
281 m_format(rhs.m_format),
282 m_summary_sp(rhs.m_summary_sp),
283 m_root_valobj_name(rhs.m_root_valobj_name),
284 m_hide_root_type(rhs.m_hide_root_type),
285 m_hide_name(rhs.m_hide_name),
286 m_hide_value(rhs.m_hide_value)
289 DumpValueObjectOptions&
290 SetMaximumPointerDepth(uint32_t depth = 0)
292 m_max_ptr_depth = depth;
296 DumpValueObjectOptions&
297 SetMaximumDepth(uint32_t depth = 0)
303 DumpValueObjectOptions&
304 SetShowTypes(bool show = false)
310 DumpValueObjectOptions&
311 SetShowLocation(bool show = false)
313 m_show_location = show;
317 DumpValueObjectOptions&
318 SetUseObjectiveC(bool use = false)
324 DumpValueObjectOptions&
325 SetShowSummary(bool show = true)
328 SetOmitSummaryDepth(UINT32_MAX);
330 SetOmitSummaryDepth(0);
334 DumpValueObjectOptions&
335 SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues)
341 DumpValueObjectOptions&
342 SetUseSyntheticValue(bool use_synthetic = true)
344 m_use_synthetic = use_synthetic;
348 DumpValueObjectOptions&
349 SetScopeChecked(bool check = true)
351 m_scope_already_checked = check;
355 DumpValueObjectOptions&
356 SetFlatOutput(bool flat = false)
358 m_flat_output = flat;
362 DumpValueObjectOptions&
363 SetOmitSummaryDepth(uint32_t depth = 0)
365 m_omit_summary_depth = depth;
369 DumpValueObjectOptions&
370 SetIgnoreCap(bool ignore = false)
372 m_ignore_cap = ignore;
376 DumpValueObjectOptions&
377 SetRawDisplay(bool raw = false)
381 SetUseSyntheticValue(false);
382 SetOmitSummaryDepth(UINT32_MAX);
389 SetUseSyntheticValue(true);
390 SetOmitSummaryDepth(0);
398 DumpValueObjectOptions&
399 SetFormat (lldb::Format format = lldb::eFormatDefault)
405 DumpValueObjectOptions&
406 SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP())
408 m_summary_sp = summary;
412 DumpValueObjectOptions&
413 SetRootValueObjectName (const char* name = NULL)
416 m_root_valobj_name.assign(name);
418 m_root_valobj_name.clear();
422 DumpValueObjectOptions&
423 SetHideRootType (bool hide_root_type = false)
425 m_hide_root_type = hide_root_type;
429 DumpValueObjectOptions&
430 SetHideName (bool hide_name = false)
432 m_hide_name = hide_name;
436 DumpValueObjectOptions&
437 SetHideValue (bool hide_value = false)
439 m_hide_value = hide_value;
444 class EvaluationPoint
450 EvaluationPoint (ExecutionContextScope *exe_scope, bool use_selected = false);
452 EvaluationPoint (const EvaluationPoint &rhs);
456 const ExecutionContextRef &
457 GetExecutionContextRef() const
459 return m_exe_ctx_ref;
462 // Set the EvaluationPoint to the values in exe_scope,
463 // Return true if the Evaluation Point changed.
464 // Since the ExecutionContextScope is always going to be valid currently,
465 // the Updated Context will also always be valid.
468 // SetContext (ExecutionContextScope *exe_scope);
474 m_mod_id.SetInvalid();
480 return !m_mod_id.IsValid();
490 SetUpdateID (ProcessModID new_id)
496 IsFirstEvaluation () const
498 return m_first_update;
504 m_needs_update = true;
513 SyncWithProcessState();
514 return m_needs_update;
520 if (!m_mod_id.IsValid())
522 else if (SyncWithProcessState ())
524 if (!m_mod_id.IsValid())
533 // Use the stop id to mark us as invalid, leave the thread id and the stack id around for logging and
535 m_mod_id.SetInvalid();
537 // Can't update an invalid state.
538 m_needs_update = false;
544 SyncWithProcessState ();
546 ProcessModID m_mod_id; // This is the stop id when this ValueObject was last evaluated.
547 ExecutionContextRef m_exe_ctx_ref;
552 const EvaluationPoint &
553 GetUpdatePoint () const
555 return m_update_point;
561 return m_update_point;
564 const ExecutionContextRef &
565 GetExecutionContextRef() const
567 return m_update_point.GetExecutionContextRef();
573 return m_update_point.GetExecutionContextRef().GetTargetSP();
579 return m_update_point.GetExecutionContextRef().GetProcessSP();
585 return m_update_point.GetExecutionContextRef().GetThreadSP();
591 return m_update_point.GetExecutionContextRef().GetFrameSP();
597 virtual ~ValueObject();
602 //------------------------------------------------------------------
603 // Sublasses must implement the functions below.
604 //------------------------------------------------------------------
608 virtual lldb::ValueType
609 GetValueType() const = 0;
611 //------------------------------------------------------------------
612 // Sublasses can implement the functions below.
613 //------------------------------------------------------------------
618 GetQualifiedTypeName();
620 virtual lldb::LanguageType
621 GetObjectRuntimeLanguage();
624 GetTypeInfo (ClangASTType *pointee_or_element_clang_type = NULL);
636 IsPointerOrReferenceType ();
639 IsPossibleDynamicType ();
651 IsDereferenceOfParent ()
657 IsIntegerType (bool &is_signed);
660 GetBaseClassPath (Stream &s);
663 GetExpressionPath (Stream &s, bool qualify_cxx_base_classes, GetExpressionPathFormat = eGetExpressionPathFormatDereferencePointers);
666 GetValueForExpressionPath(const char* expression,
667 const char** first_unparsed = NULL,
668 ExpressionPathScanEndReason* reason_to_stop = NULL,
669 ExpressionPathEndResultType* final_value_type = NULL,
670 const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(),
671 ExpressionPathAftermath* final_task_on_target = NULL);
674 GetValuesForExpressionPath(const char* expression,
675 lldb::ValueObjectListSP& list,
676 const char** first_unparsed = NULL,
677 ExpressionPathScanEndReason* reason_to_stop = NULL,
678 ExpressionPathEndResultType* final_value_type = NULL,
679 const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(),
680 ExpressionPathAftermath* final_task_on_target = NULL);
695 GetBitfieldBitSize ()
701 GetBitfieldBitOffset ()
709 return (GetBitfieldBitSize() != 0) || (GetBitfieldBitOffset() != 0);
713 IsArrayItemForPointer()
715 return m_is_array_item_for_pointer;
719 GetValueAsCString ();
722 GetValueAsCString (lldb::Format format,
723 std::string& destination);
726 GetValueAsUnsigned (uint64_t fail_value, bool *success = NULL);
729 SetValueFromCString (const char *value_str, Error& error);
731 // Return the module associated with this value object in case the
732 // value is from an executable file and might have its data in
733 // sections of the file. This can be used for variables.
734 virtual lldb::ModuleSP
741 GetDeclaration (Declaration &decl);
743 //------------------------------------------------------------------
744 // The functions below should NOT be modified by sublasses
745 //------------------------------------------------------------------
752 virtual lldb::ValueObjectSP
753 GetChildAtIndex (size_t idx, bool can_create);
755 // this will always create the children if necessary
757 GetChildAtIndexPath (const std::initializer_list<size_t> &idxs,
758 size_t* index_of_error = NULL);
761 GetChildAtIndexPath (const std::vector<size_t> &idxs,
762 size_t* index_of_error = NULL);
765 GetChildAtIndexPath (const std::initializer_list< std::pair<size_t, bool> > &idxs,
766 size_t* index_of_error = NULL);
769 GetChildAtIndexPath (const std::vector< std::pair<size_t, bool> > &idxs,
770 size_t* index_of_error = NULL);
772 virtual lldb::ValueObjectSP
773 GetChildMemberWithName (const ConstString &name, bool can_create);
776 GetIndexOfChildWithName (const ConstString &name);
788 ResolveValue (Scalar &scalar);
791 GetLocationAsCString ();
794 GetSummaryAsCString ();
797 GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
798 std::string& destination);
801 GetObjectDescription ();
804 HasSpecialPrintableRepresentation (ValueObjectRepresentationStyle val_obj_display,
805 lldb::Format custom_format);
807 enum PrintableRepresentationSpecialCases
809 ePrintableRepresentationSpecialCasesDisable = 0,
810 ePrintableRepresentationSpecialCasesAllow = 1,
811 ePrintableRepresentationSpecialCasesOnly = 3
815 DumpPrintableRepresentation (Stream& s,
816 ValueObjectRepresentationStyle val_obj_display = eValueObjectRepresentationStyleSummary,
817 lldb::Format custom_format = lldb::eFormatInvalid,
818 PrintableRepresentationSpecialCases special = ePrintableRepresentationSpecialCasesAllow);
820 GetValueIsValid () const;
823 GetValueDidChange ();
826 UpdateValueIfNeeded (bool update_format = true);
829 UpdateFormatsIfNeeded();
834 return m_manager->GetSharedPointer(this);
838 SetName (const ConstString &name);
841 GetAddressOf (bool scalar_is_load_address = true,
842 AddressType *address_type = NULL);
845 GetPointerValue (AddressType *address_type = NULL);
848 GetSyntheticChild (const ConstString &key) const;
851 GetSyntheticArrayMember (size_t index, bool can_create);
854 GetSyntheticArrayMemberFromPointer (size_t index, bool can_create);
857 GetSyntheticArrayMemberFromArray (size_t index, bool can_create);
860 GetSyntheticBitFieldChild (uint32_t from, uint32_t to, bool can_create);
863 GetSyntheticExpressionPathChild(const char* expression, bool can_create);
865 virtual lldb::ValueObjectSP
866 GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create);
868 virtual lldb::ValueObjectSP
869 GetDynamicValue (lldb::DynamicValueType valueType);
871 lldb::DynamicValueType
872 GetDynamicValueType ();
874 virtual lldb::ValueObjectSP
877 virtual lldb::ValueObjectSP
878 GetNonSyntheticValue ();
881 GetSyntheticValue (bool use_synthetic = true);
887 IsSynthetic() { return false; }
889 virtual lldb::ValueObjectSP
890 CreateConstantValue (const ConstString &name);
892 virtual lldb::ValueObjectSP
893 Dereference (Error &error);
895 virtual lldb::ValueObjectSP
896 AddressOf (Error &error);
901 return LLDB_INVALID_ADDRESS;
905 SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
906 AddressType address_type = eAddressTypeLoad)
910 virtual lldb::ValueObjectSP
911 Cast (const ClangASTType &clang_ast_type);
913 virtual lldb::ValueObjectSP
914 CastPointerType (const char *name,
915 ClangASTType &ast_type);
917 virtual lldb::ValueObjectSP
918 CastPointerType (const char *name,
919 lldb::TypeSP &type_sp);
921 // The backing bits of this value object were updated, clear any
922 // descriptive string, so we know we have to refetch them
926 ClearUserVisibleData(eClearUserVisibleDataItemsValue |
927 eClearUserVisibleDataItemsSummary |
928 eClearUserVisibleDataItemsDescription);
937 virtual SymbolContextScope *
938 GetSymbolContextScope();
941 DumpValueObject (Stream &s,
942 ValueObject *valobj);
944 DumpValueObject (Stream &s,
946 const DumpValueObjectOptions& options);
948 static lldb::ValueObjectSP
949 CreateValueObjectFromExpression (const char* name,
950 const char* expression,
951 const ExecutionContext& exe_ctx);
953 static lldb::ValueObjectSP
954 CreateValueObjectFromAddress (const char* name,
956 const ExecutionContext& exe_ctx,
959 static lldb::ValueObjectSP
960 CreateValueObjectFromData (const char* name,
962 const ExecutionContext& exe_ctx,
966 LogValueObject (Log *log,
967 ValueObject *valobj);
970 LogValueObject (Log *log,
972 const DumpValueObjectOptions& options);
975 // returns true if this is a char* or a char[]
976 // if it is a char* and check_pointer is true,
977 // it also checks that the pointer is valid
979 IsCStringContainer (bool check_pointer = false);
982 ReadPointedString (Stream& s,
984 uint32_t max_length = 0,
985 bool honor_array = true,
986 lldb::Format item_format = lldb::eFormatCharArray);
989 GetPointeeData (DataExtractor& data,
990 uint32_t item_idx = 0,
991 uint32_t item_count = 1);
994 GetData (DataExtractor& data);
997 SetData (DataExtractor &data, Error &error);
1000 GetIsConstant () const
1002 return m_update_point.IsConstant();
1008 m_update_point.SetIsConstant();
1015 SetFormat (lldb::Format format)
1017 if (format != m_format)
1018 ClearUserVisibleData(eClearUserVisibleDataItemsValue);
1022 lldb::TypeSummaryImplSP
1025 UpdateFormatsIfNeeded();
1026 return m_type_summary_sp;
1030 SetSummaryFormat(lldb::TypeSummaryImplSP format)
1032 m_type_summary_sp = format;
1033 ClearUserVisibleData(eClearUserVisibleDataItemsSummary);
1037 SetValueFormat(lldb::TypeFormatImplSP format)
1039 m_type_format_sp = format;
1040 ClearUserVisibleData(eClearUserVisibleDataItemsValue);
1043 lldb::TypeFormatImplSP
1046 UpdateFormatsIfNeeded();
1047 return m_type_format_sp;
1051 SetSyntheticChildren(const lldb::SyntheticChildrenSP &synth_sp)
1053 if (synth_sp.get() == m_synthetic_children_sp.get())
1055 ClearUserVisibleData(eClearUserVisibleDataItemsSyntheticChildren);
1056 m_synthetic_children_sp = synth_sp;
1059 lldb::SyntheticChildrenSP
1060 GetSyntheticChildren()
1062 UpdateFormatsIfNeeded();
1063 return m_synthetic_children_sp;
1066 // Use GetParent for display purposes, but if you want to tell the parent to update itself
1067 // then use m_parent. The ValueObjectDynamicValue's parent is not the correct parent for
1068 // displaying, they are really siblings, so for display it needs to route through to its grandparent.
1069 virtual ValueObject *
1075 virtual const ValueObject *
1082 GetNonBaseClassParent();
1085 SetAddressTypeOfChildren(AddressType at)
1087 m_address_type_of_ptr_or_ref_children = at;
1091 GetAddressTypeOfChildren();
1094 SetHasCompleteType()
1096 m_did_calculate_complete_objc_class_type = true;
1099 //------------------------------------------------------------------
1100 /// Find out if a ValueObject might have children.
1102 /// This call is much more efficient than CalculateNumChildren() as
1103 /// it doesn't need to complete the underlying type. This is designed
1104 /// to be used in a UI environment in order to detect if the
1105 /// disclosure triangle should be displayed or not.
1107 /// This function returns true for class, union, structure,
1108 /// pointers, references, arrays and more. Again, it does so without
1109 /// doing any expensive type completion.
1112 /// Returns \b true if the ValueObject might have children, or \b
1113 /// false otherwise.
1114 //------------------------------------------------------------------
1116 MightHaveChildren();
1119 typedef ClusterManager<ValueObject> ValueObjectManager;
1121 class ChildrenManager
1125 m_mutex(Mutex::eMutexTypeRecursive),
1131 HasChildAtIndex (size_t idx)
1133 Mutex::Locker locker(m_mutex);
1134 ChildrenIterator iter = m_children.find(idx);
1135 ChildrenIterator end = m_children.end();
1136 return (iter != end);
1140 GetChildAtIndex (size_t idx)
1142 Mutex::Locker locker(m_mutex);
1143 ChildrenIterator iter = m_children.find(idx);
1144 ChildrenIterator end = m_children.end();
1148 return iter->second;
1152 SetChildAtIndex (size_t idx, ValueObject* valobj)
1154 ChildrenPair pair(idx,valobj); // we do not need to be mutex-protected to make a pair
1155 Mutex::Locker locker(m_mutex);
1156 m_children.insert(pair);
1160 SetChildrenCount (size_t count)
1162 m_children_count = count;
1168 return m_children_count;
1174 m_children_count = 0;
1175 Mutex::Locker locker(m_mutex);
1180 typedef std::map<size_t, ValueObject*> ChildrenMap;
1181 typedef ChildrenMap::iterator ChildrenIterator;
1182 typedef ChildrenMap::value_type ChildrenPair;
1184 ChildrenMap m_children;
1185 size_t m_children_count;
1188 //------------------------------------------------------------------
1189 // Classes that inherit from ValueObject can see and modify these
1190 //------------------------------------------------------------------
1191 ValueObject * m_parent; // The parent value object, or NULL if this has no parent
1192 ValueObject * m_root; // The root of the hierarchy for this ValueObject (or NULL if never calculated)
1193 EvaluationPoint m_update_point; // Stores both the stop id and the full context at which this value was last
1194 // updated. When we are asked to update the value object, we check whether
1195 // the context & stop id are the same before updating.
1196 ConstString m_name; // The name of this object
1197 DataExtractor m_data; // A data extractor that can be used to extract the value.
1199 Error m_error; // An error object that can describe any errors that occur when updating values.
1200 std::string m_value_str; // Cached value string that will get cleared if/when the value is updated.
1201 std::string m_old_value_str;// Cached old value string from the last time the value was gotten
1202 std::string m_location_str; // Cached location string that will get cleared if/when the value is updated.
1203 std::string m_summary_str; // Cached summary string that will get cleared if/when the value is updated.
1204 std::string m_object_desc_str; // Cached result of the "object printer". This differs from the summary
1205 // in that the summary is consed up by us, the object_desc_string is builtin.
1207 ClangASTType m_override_type;// If the type of the value object should be overridden, the type to impose.
1209 ValueObjectManager *m_manager; // This object is managed by the root object (any ValueObject that gets created
1210 // without a parent.) The manager gets passed through all the generations of
1211 // dependent objects, and will keep the whole cluster of objects alive as long
1212 // as a shared pointer to any of them has been handed out. Shared pointers to
1213 // value objects must always be made with the GetSP method.
1215 ChildrenManager m_children;
1216 std::map<ConstString, ValueObject *> m_synthetic_children;
1218 ValueObject* m_dynamic_value;
1219 ValueObject* m_synthetic_value;
1220 ValueObject* m_deref_valobj;
1222 lldb::ValueObjectSP m_addr_of_valobj_sp; // We have to hold onto a shared pointer to this one because it is created
1223 // as an independent ValueObjectConstResult, which isn't managed by us.
1225 lldb::Format m_format;
1226 lldb::Format m_last_format;
1227 uint32_t m_last_format_mgr_revision;
1228 lldb::TypeSummaryImplSP m_type_summary_sp;
1229 lldb::TypeFormatImplSP m_type_format_sp;
1230 lldb::SyntheticChildrenSP m_synthetic_children_sp;
1231 ProcessModID m_user_id_of_forced_summary;
1232 AddressType m_address_type_of_ptr_or_ref_children;
1234 bool m_value_is_valid:1,
1235 m_value_did_change:1,
1236 m_children_count_valid:1,
1237 m_old_value_valid:1,
1238 m_is_deref_of_parent:1,
1239 m_is_array_item_for_pointer:1,
1240 m_is_bitfield_for_scalar:1,
1241 m_is_child_at_offset:1,
1242 m_is_getting_summary:1,
1243 m_did_calculate_complete_objc_class_type:1;
1245 friend class ClangExpressionDeclMap; // For GetValue
1246 friend class ClangExpressionVariable; // For SetName
1247 friend class Target; // For SetName
1248 friend class ValueObjectConstResultImpl;
1250 //------------------------------------------------------------------
1251 // Constructors and Destructors
1252 //------------------------------------------------------------------
1254 // Use the no-argument constructor to make a constant variable object (with no ExecutionContextScope.)
1258 // Use this constructor to create a "root variable object". The ValueObject will be locked to this context
1259 // through-out its lifespan.
1261 ValueObject (ExecutionContextScope *exe_scope,
1262 AddressType child_ptr_or_ref_addr_type = eAddressTypeLoad);
1264 // Use this constructor to create a ValueObject owned by another ValueObject. It will inherit the ExecutionContext
1267 ValueObject (ValueObject &parent);
1269 ValueObjectManager *
1279 CalculateDynamicValue (lldb::DynamicValueType use_dynamic);
1281 virtual lldb::DynamicValueType
1282 GetDynamicValueTypeImpl ()
1284 return lldb::eNoDynamicValues;
1288 HasDynamicValueTypeInfo ()
1294 CalculateSyntheticValue (bool use_synthetic = true);
1296 // Should only be called by ValueObject::GetChildAtIndex()
1297 // Returns a ValueObject managed by this ValueObject's manager.
1298 virtual ValueObject *
1299 CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index);
1301 // Should only be called by ValueObject::GetNumChildren()
1303 CalculateNumChildren() = 0;
1306 SetNumChildren (size_t num_children);
1309 SetValueDidChange (bool value_changed);
1312 SetValueIsValid (bool valid);
1315 ClearUserVisibleData(uint32_t items = ValueObject::eClearUserVisibleDataItemsAllStrings);
1318 AddSyntheticChild (const ConstString &key,
1319 ValueObject *valobj);
1322 GetDataExtractor ();
1325 ClearDynamicTypeInformation ();
1327 //------------------------------------------------------------------
1328 // Sublasses must implement the functions below.
1329 //------------------------------------------------------------------
1331 virtual ClangASTType
1332 GetClangTypeImpl () = 0;
1335 GetLocationAsCStringImpl (const Value& value,
1336 const DataExtractor& data);
1339 //------------------------------------------------------------------
1340 // For ValueObject only
1341 //------------------------------------------------------------------
1343 virtual ClangASTType
1344 MaybeCalculateCompleteType ();
1347 GetValueForExpressionPath_Impl(const char* expression_cstr,
1348 const char** first_unparsed,
1349 ExpressionPathScanEndReason* reason_to_stop,
1350 ExpressionPathEndResultType* final_value_type,
1351 const GetValueForExpressionPathOptions& options,
1352 ExpressionPathAftermath* final_task_on_target);
1354 // this method will ONLY expand [] expressions into a VOList and return
1355 // the number of elements it added to the VOList
1356 // it will NOT loop through expanding the follow-up of the expression_cstr
1357 // for all objects in the list
1359 ExpandArraySliceExpression(const char* expression_cstr,
1360 const char** first_unparsed,
1361 lldb::ValueObjectSP root,
1362 lldb::ValueObjectListSP& list,
1363 ExpressionPathScanEndReason* reason_to_stop,
1364 ExpressionPathEndResultType* final_value_type,
1365 const GetValueForExpressionPathOptions& options,
1366 ExpressionPathAftermath* final_task_on_target);
1369 DISALLOW_COPY_AND_ASSIGN (ValueObject);
1373 } // namespace lldb_private
1375 #endif // liblldb_ValueObject_h_