ValueObject.h revision 574c3d63822cc7fd52bf6f6a94b6882fec4c8ce9
1//===-- ValueObject.h -------------------------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef liblldb_ValueObject_h_
11#define liblldb_ValueObject_h_
12
13// C Includes
14// C++ Includes
15#include <map>
16#include <vector>
17// Other libraries and framework includes
18// Project includes
19
20#include "lldb/lldb-private.h"
21#include "lldb/Core/DataExtractor.h"
22#include "lldb/Core/Error.h"
23#include "lldb/Core/Flags.h"
24#include "lldb/Core/ConstString.h"
25#include "lldb/Core/UserID.h"
26#include "lldb/Core/Value.h"
27#include "lldb/Target/ExecutionContext.h"
28#include "lldb/Target/ExecutionContextScope.h"
29#include "lldb/Target/Process.h"
30#include "lldb/Target/StackID.h"
31#include "lldb/Utility/PriorityPointerPair.h"
32#include "lldb/Utility/SharedCluster.h"
33
34namespace lldb_private {
35
36/// ValueObject:
37///
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.
45
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.
53///
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.
56
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.
60///
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.
65
66class ValueObject : public UserID
67{
68public:
69
70    enum GetExpressionPathFormat
71    {
72        eDereferencePointers = 1,
73        eHonorPointers
74    };
75
76    enum ValueObjectRepresentationStyle
77    {
78        eDisplayValue = 1,
79        eDisplaySummary,
80        eDisplayLanguageSpecific,
81        eDisplayLocation,
82        eDisplayChildrenCount,
83    };
84
85    enum ExpressionPathScanEndReason
86    {
87        eEndOfString = 1,           // out of data to parse
88        eNoSuchChild,               // child element not found
89        eEmptyRangeNotAllowed,      // [] only allowed for arrays
90        eDotInsteadOfArrow,         // . used when -> should be used
91        eArrowInsteadOfDot,         // -> used when . should be used
92        eFragileIVarNotAllowed,     // ObjC ivar expansion not allowed
93        eRangeOperatorNotAllowed,   // [] not allowed by options
94        eRangeOperatorInvalid,      // [] not valid on objects other than scalars, pointers or arrays
95        eArrayRangeOperatorMet,     // [] is good for arrays, but I cannot parse it
96        eBitfieldRangeOperatorMet,  // [] is good for bitfields, but I cannot parse after it
97        eUnexpectedSymbol,          // something is malformed in the expression
98        eTakingAddressFailed,       // impossible to apply & operator
99        eDereferencingFailed,       // impossible to apply * operator
100        eRangeOperatorExpanded,     // [] was expanded into a VOList
101        eUnknown = 0xFFFF
102    };
103
104    enum ExpressionPathEndResultType
105    {
106        ePlain = 1,                 // anything but...
107        eBitfield,                  // a bitfield
108        eBoundedRange,              // a range [low-high]
109        eUnboundedRange,            // a range []
110        eValueObjectList,           // several items in a VOList
111        eInvalid = 0xFFFF
112    };
113
114    enum ExpressionPathAftermath
115    {
116        eNothing = 1,               // just return it
117        eDereference,               // dereference the target
118        eTakeAddress                // take target's address
119    };
120
121    struct GetValueForExpressionPathOptions
122    {
123        bool m_check_dot_vs_arrow_syntax;
124        bool m_no_fragile_ivar;
125        bool m_allow_bitfields_syntax;
126        bool m_no_synthetic_children;
127
128        GetValueForExpressionPathOptions(bool dot = false,
129                                         bool no_ivar = false,
130                                         bool bitfield = true,
131                                         bool no_synth = false) :
132            m_check_dot_vs_arrow_syntax(dot),
133            m_no_fragile_ivar(no_ivar),
134            m_allow_bitfields_syntax(bitfield),
135            m_no_synthetic_children(no_synth)
136        {
137        }
138
139        GetValueForExpressionPathOptions&
140        DoCheckDotVsArrowSyntax()
141        {
142            m_check_dot_vs_arrow_syntax = true;
143            return *this;
144        }
145
146        GetValueForExpressionPathOptions&
147        DontCheckDotVsArrowSyntax()
148        {
149            m_check_dot_vs_arrow_syntax = false;
150            return *this;
151        }
152
153        GetValueForExpressionPathOptions&
154        DoAllowFragileIVar()
155        {
156            m_no_fragile_ivar = false;
157            return *this;
158        }
159
160        GetValueForExpressionPathOptions&
161        DontAllowFragileIVar()
162        {
163            m_no_fragile_ivar = true;
164            return *this;
165        }
166
167        GetValueForExpressionPathOptions&
168        DoAllowBitfieldSyntax()
169        {
170            m_allow_bitfields_syntax = true;
171            return *this;
172        }
173
174        GetValueForExpressionPathOptions&
175        DontAllowBitfieldSyntax()
176        {
177            m_allow_bitfields_syntax = false;
178            return *this;
179        }
180
181        GetValueForExpressionPathOptions&
182        DoAllowSyntheticChildren()
183        {
184            m_no_synthetic_children = false;
185            return *this;
186        }
187
188        GetValueForExpressionPathOptions&
189        DontAllowSyntheticChildren()
190        {
191            m_no_synthetic_children = true;
192            return *this;
193        }
194
195        static const GetValueForExpressionPathOptions
196        DefaultOptions()
197        {
198            static GetValueForExpressionPathOptions g_default_options;
199
200            return g_default_options;
201        }
202
203    };
204
205    class EvaluationPoint
206    {
207    public:
208
209        EvaluationPoint ();
210
211        EvaluationPoint (ExecutionContextScope *exe_scope, bool use_selected = false);
212
213        EvaluationPoint (const EvaluationPoint &rhs);
214
215        ~EvaluationPoint ();
216
217        ExecutionContextScope *
218        GetExecutionContextScope ();
219
220        lldb::TargetSP
221        GetTargetSP () const
222        {
223            return m_target_sp;
224        }
225
226        lldb::ProcessSP
227        GetProcessSP () const
228        {
229            return m_process_sp;
230        }
231
232        // Set the EvaluationPoint to the values in exe_scope,
233        // Return true if the Evaluation Point changed.
234        // Since the ExecutionContextScope is always going to be valid currently,
235        // the Updated Context will also always be valid.
236
237        bool
238        SetContext (ExecutionContextScope *exe_scope);
239
240        void
241        SetIsConstant ()
242        {
243            SetUpdated();
244            m_mod_id.SetInvalid();
245        }
246
247        bool
248        IsConstant () const
249        {
250            return !m_mod_id.IsValid();
251        }
252
253        ProcessModID
254        GetModID () const
255        {
256            return m_mod_id;
257        }
258
259        void
260        SetUpdateID (ProcessModID new_id)
261        {
262            m_mod_id = new_id;
263        }
264
265        bool
266        IsFirstEvaluation () const
267        {
268            return m_first_update;
269        }
270
271        void
272        SetNeedsUpdate ()
273        {
274            m_needs_update = true;
275        }
276
277        void
278        SetUpdated ();
279
280        bool
281        NeedsUpdating()
282        {
283            SyncWithProcessState();
284            return m_needs_update;
285        }
286
287        bool
288        IsValid ()
289        {
290            if (!m_mod_id.IsValid())
291                return false;
292            else if (SyncWithProcessState ())
293            {
294                if (!m_mod_id.IsValid())
295                    return false;
296            }
297            return true;
298        }
299
300        void
301        SetInvalid ()
302        {
303            // Use the stop id to mark us as invalid, leave the thread id and the stack id around for logging and
304            // history purposes.
305            m_mod_id.SetInvalid();
306
307            // Can't update an invalid state.
308            m_needs_update = false;
309
310        }
311
312    private:
313        bool
314        SyncWithProcessState ();
315
316        ExecutionContextScope *m_exe_scope;   // This is not the way to store the evaluation point state, it is just
317                                            // a cache of the lookup, and gets thrown away when we update.
318        bool             m_needs_update;
319        bool             m_first_update;
320
321        lldb::TargetSP   m_target_sp;
322        lldb::ProcessSP  m_process_sp;
323        lldb::user_id_t  m_thread_id;
324        StackID          m_stack_id;
325        ProcessModID     m_mod_id; // This is the stop id when this ValueObject was last evaluated.
326    };
327
328    const EvaluationPoint &
329    GetUpdatePoint () const
330    {
331        return m_update_point;
332    }
333
334    EvaluationPoint &
335    GetUpdatePoint ()
336    {
337        return m_update_point;
338    }
339
340    ExecutionContextScope *
341    GetExecutionContextScope ()
342    {
343        return m_update_point.GetExecutionContextScope();
344    }
345
346    void
347    SetNeedsUpdate ();
348
349    virtual ~ValueObject();
350
351    //------------------------------------------------------------------
352    // Sublasses must implement the functions below.
353    //------------------------------------------------------------------
354    virtual size_t
355    GetByteSize() = 0;
356
357    virtual clang::ASTContext *
358    GetClangAST () = 0;
359
360    virtual lldb::clang_type_t
361    GetClangType () = 0;
362
363    virtual lldb::ValueType
364    GetValueType() const = 0;
365
366    virtual ConstString
367    GetTypeName() = 0;
368
369    virtual lldb::LanguageType
370    GetObjectRuntimeLanguage();
371
372    virtual bool
373    IsPointerType ();
374
375    virtual bool
376    IsArrayType ();
377
378    virtual bool
379    IsScalarType ();
380
381    virtual bool
382    IsPointerOrReferenceType ();
383
384    virtual bool
385    IsPossibleCPlusPlusDynamicType ();
386
387    virtual bool
388    IsPossibleDynamicType ();
389
390    virtual bool
391    IsBaseClass ()
392    {
393        return false;
394    }
395
396    virtual bool
397    IsDereferenceOfParent ()
398    {
399        return false;
400    }
401
402    bool
403    IsIntegerType (bool &is_signed);
404
405    virtual bool
406    GetBaseClassPath (Stream &s);
407
408    virtual void
409    GetExpressionPath (Stream &s, bool qualify_cxx_base_classes, GetExpressionPathFormat = eDereferencePointers);
410
411    lldb::ValueObjectSP
412    GetValueForExpressionPath(const char* expression,
413                              const char** first_unparsed = NULL,
414                              ExpressionPathScanEndReason* reason_to_stop = NULL,
415                              ExpressionPathEndResultType* final_value_type = NULL,
416                              const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(),
417                              ExpressionPathAftermath* final_task_on_target = NULL);
418
419    int
420    GetValuesForExpressionPath(const char* expression,
421                               lldb::ValueObjectListSP& list,
422                               const char** first_unparsed = NULL,
423                               ExpressionPathScanEndReason* reason_to_stop = NULL,
424                               ExpressionPathEndResultType* final_value_type = NULL,
425                               const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(),
426                               ExpressionPathAftermath* final_task_on_target = NULL);
427
428    virtual bool
429    IsInScope ()
430    {
431        return true;
432    }
433
434    virtual off_t
435    GetByteOffset()
436    {
437        return 0;
438    }
439
440    virtual uint32_t
441    GetBitfieldBitSize()
442    {
443        return 0;
444    }
445
446    virtual uint32_t
447    GetBitfieldBitOffset()
448    {
449        return 0;
450    }
451
452    virtual bool
453    IsArrayItemForPointer()
454    {
455        return m_is_array_item_for_pointer;
456    }
457
458    virtual bool
459    SetClangAST (clang::ASTContext *ast)
460    {
461        return false;
462    }
463
464    virtual const char *
465    GetValueAsCString ();
466
467    virtual unsigned long long
468    GetValueAsUnsigned();
469
470    virtual bool
471    SetValueFromCString (const char *value_str);
472
473    // Return the module associated with this value object in case the
474    // value is from an executable file and might have its data in
475    // sections of the file. This can be used for variables.
476    virtual Module *
477    GetModule()
478    {
479        if (m_parent)
480            return m_parent->GetModule();
481        return NULL;
482    }
483    //------------------------------------------------------------------
484    // The functions below should NOT be modified by sublasses
485    //------------------------------------------------------------------
486    const Error &
487    GetError();
488
489    const ConstString &
490    GetName() const;
491
492    virtual lldb::ValueObjectSP
493    GetChildAtIndex (uint32_t idx, bool can_create);
494
495    virtual lldb::ValueObjectSP
496    GetChildMemberWithName (const ConstString &name, bool can_create);
497
498    virtual uint32_t
499    GetIndexOfChildWithName (const ConstString &name);
500
501    uint32_t
502    GetNumChildren ();
503
504    const Value &
505    GetValue() const;
506
507    Value &
508    GetValue();
509
510    bool
511    ResolveValue (Scalar &scalar);
512
513    const char *
514    GetLocationAsCString ();
515
516    const char *
517    GetSummaryAsCString ();
518
519    const char *
520    GetObjectDescription ();
521
522    bool
523    GetPrintableRepresentation(Stream& s,
524                               ValueObjectRepresentationStyle val_obj_display = eDisplaySummary,
525                               lldb::Format custom_format = lldb::eFormatInvalid);
526
527    bool
528    DumpPrintableRepresentation(Stream& s,
529                                ValueObjectRepresentationStyle val_obj_display = eDisplaySummary,
530                                lldb::Format custom_format = lldb::eFormatInvalid);
531    bool
532    GetValueIsValid () const;
533
534    bool
535    GetValueDidChange ();
536
537    bool
538    UpdateValueIfNeeded (bool update_format = true);
539
540    bool
541    UpdateValueIfNeeded (lldb::DynamicValueType use_dynamic, bool update_format = true);
542
543    void
544    UpdateFormatsIfNeeded(lldb::DynamicValueType use_dynamic = lldb::eNoDynamicValues);
545
546    DataExtractor &
547    GetDataExtractor ();
548
549    lldb::ValueObjectSP
550    GetSP ()
551    {
552        return m_manager->GetSharedPointer(this);
553    }
554
555protected:
556    void
557    AddSyntheticChild (const ConstString &key,
558                       ValueObject *valobj);
559public:
560    lldb::ValueObjectSP
561    GetSyntheticChild (const ConstString &key) const;
562
563    lldb::ValueObjectSP
564    GetSyntheticArrayMemberFromPointer (int32_t index, bool can_create);
565
566    lldb::ValueObjectSP
567    GetSyntheticArrayMemberFromArray (int32_t index, bool can_create);
568
569    lldb::ValueObjectSP
570    GetSyntheticBitFieldChild (uint32_t from, uint32_t to, bool can_create);
571
572    lldb::ValueObjectSP
573    GetSyntheticExpressionPathChild(const char* expression, bool can_create);
574
575    virtual lldb::ValueObjectSP
576    GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create);
577
578    lldb::ValueObjectSP
579    GetDynamicValue (lldb::DynamicValueType valueType);
580
581    lldb::ValueObjectSP
582    GetSyntheticValue (lldb::SyntheticValueType use_synthetic);
583
584    virtual bool
585    HasSyntheticValue();
586
587    virtual lldb::ValueObjectSP
588    CreateConstantValue (const ConstString &name);
589
590    virtual lldb::ValueObjectSP
591    Dereference (Error &error);
592
593    virtual lldb::ValueObjectSP
594    AddressOf (Error &error);
595
596    virtual lldb::ValueObjectSP
597    CastPointerType (const char *name,
598                     ClangASTType &ast_type);
599
600    virtual lldb::ValueObjectSP
601    CastPointerType (const char *name,
602                     lldb::TypeSP &type_sp);
603
604    // The backing bits of this value object were updated, clear any value
605    // values, summaries or descriptions so we refetch them.
606    virtual void
607    ValueUpdated ()
608    {
609        m_value_str.clear();
610        m_summary_str.clear();
611        m_object_desc_str.clear();
612    }
613
614    virtual bool
615    IsDynamic ()
616    {
617        return false;
618    }
619
620    static void
621    DumpValueObject (Stream &s,
622                     ValueObject *valobj,
623                     const char *root_valobj_name,
624                     uint32_t ptr_depth,
625                     uint32_t curr_depth,
626                     uint32_t max_depth,
627                     bool show_types,
628                     bool show_location,
629                     bool use_objc,
630                     lldb::DynamicValueType use_dynamic,
631                     bool use_synthetic,
632                     bool scope_already_checked,
633                     bool flat_output,
634                     uint32_t omit_summary_depth,
635                     bool ignore_cap);
636
637    // returns true if this is a char* or a char[]
638    // if it is a char* and check_pointer is true,
639    // it also checks that the pointer is valid
640    bool
641    IsCStringContainer(bool check_pointer = false);
642
643    void
644    ReadPointedString(Stream& s,
645                      Error& error,
646                      uint32_t max_length = 0,
647                      bool honor_array = true,
648                      lldb::Format item_format = lldb::eFormatCharArray);
649
650    bool
651    GetIsConstant () const
652    {
653        return m_update_point.IsConstant();
654    }
655
656    void
657    SetIsConstant ()
658    {
659        m_update_point.SetIsConstant();
660    }
661
662    lldb::Format
663    GetFormat () const
664    {
665        if (m_parent && m_format == lldb::eFormatDefault)
666            return m_parent->GetFormat();
667        return m_format;
668    }
669
670    void
671    SetIsExpressionResult(bool expr)
672    {
673        m_is_expression_result = expr;
674    }
675
676    bool
677    GetIsExpressionResult()
678    {
679        return m_is_expression_result;
680    }
681
682    void
683    SetFormat (lldb::Format format)
684    {
685        if (format != m_format)
686            m_value_str.clear();
687        m_format = format;
688    }
689
690    void
691    SetCustomSummaryFormat(lldb::SummaryFormatSP format)
692    {
693        m_forced_summary_format = format;
694        m_user_id_of_forced_summary = m_update_point.GetModID();
695        m_summary_str.clear();
696    }
697
698    lldb::SummaryFormatSP
699    GetCustomSummaryFormat()
700    {
701        return m_forced_summary_format;
702    }
703
704    void
705    ClearCustomSummaryFormat()
706    {
707        m_forced_summary_format.reset();
708        m_summary_str.clear();
709    }
710
711    bool
712    HasCustomSummaryFormat()
713    {
714        return (m_forced_summary_format.get());
715    }
716
717    lldb::SummaryFormatSP
718    GetSummaryFormat()
719    {
720        UpdateFormatsIfNeeded(m_last_format_mgr_dynamic);
721        if (HasCustomSummaryFormat())
722            return m_forced_summary_format;
723        return m_last_summary_format;
724    }
725
726    // Use GetParent for display purposes, but if you want to tell the parent to update itself
727    // then use m_parent.  The ValueObjectDynamicValue's parent is not the correct parent for
728    // displaying, they are really siblings, so for display it needs to route through to its grandparent.
729    virtual ValueObject *
730    GetParent()
731    {
732        return m_parent;
733    }
734
735    virtual const ValueObject *
736    GetParent() const
737    {
738        return m_parent;
739    }
740
741    ValueObject *
742    GetNonBaseClassParent();
743
744    void
745    SetPointersPointToLoadAddrs (bool b)
746    {
747        m_pointers_point_to_load_addrs = b;
748    }
749
750protected:
751    typedef ClusterManager<ValueObject> ValueObjectManager;
752
753    //------------------------------------------------------------------
754    // Classes that inherit from ValueObject can see and modify these
755    //------------------------------------------------------------------
756    ValueObject  *      m_parent;       // The parent value object, or NULL if this has no parent
757    EvaluationPoint     m_update_point; // Stores both the stop id and the full context at which this value was last
758                                        // updated.  When we are asked to update the value object, we check whether
759                                        // the context & stop id are the same before updating.
760    ConstString         m_name;         // The name of this object
761    DataExtractor       m_data;         // A data extractor that can be used to extract the value.
762    Value               m_value;
763    Error               m_error;        // An error object that can describe any errors that occur when updating values.
764    std::string         m_value_str;    // Cached value string that will get cleared if/when the value is updated.
765    std::string         m_old_value_str;// Cached old value string from the last time the value was gotten
766    std::string         m_location_str; // Cached location string that will get cleared if/when the value is updated.
767    std::string         m_summary_str;  // Cached summary string that will get cleared if/when the value is updated.
768    std::string         m_object_desc_str; // Cached result of the "object printer".  This differs from the summary
769                                              // in that the summary is consed up by us, the object_desc_string is builtin.
770
771    ValueObjectManager *m_manager;      // This object is managed by the root object (any ValueObject that gets created
772                                        // without a parent.)  The manager gets passed through all the generations of
773                                        // dependent objects, and will keep the whole cluster of objects alive as long
774                                        // as a shared pointer to any of them has been handed out.  Shared pointers to
775                                        // value objects must always be made with the GetSP method.
776
777    std::vector<ValueObject *> m_children;
778    std::map<ConstString, ValueObject *> m_synthetic_children;
779    ValueObject *m_dynamic_value;
780    ValueObject *m_synthetic_value;
781    lldb::ValueObjectSP m_addr_of_valobj_sp; // We have to hold onto a shared pointer to this one because it is created
782                                             // as an independent ValueObjectConstResult, which isn't managed by us.
783    ValueObject *m_deref_valobj;
784
785    lldb::Format                m_format;
786    uint32_t                    m_last_format_mgr_revision;
787    lldb::DynamicValueType      m_last_format_mgr_dynamic;
788    lldb::SummaryFormatSP       m_last_summary_format;
789    lldb::SummaryFormatSP       m_forced_summary_format;
790    lldb::ValueFormatSP         m_last_value_format;
791    lldb::SyntheticChildrenSP   m_last_synthetic_filter;
792    ProcessModID                m_user_id_of_forced_summary;
793
794    bool                m_value_is_valid:1,
795                        m_value_did_change:1,
796                        m_children_count_valid:1,
797                        m_old_value_valid:1,
798                        m_pointers_point_to_load_addrs:1,
799                        m_is_deref_of_parent:1,
800                        m_is_array_item_for_pointer:1,
801                        m_is_bitfield_for_scalar:1,
802                        m_is_expression_path_child:1,
803                        m_is_child_at_offset:1,
804                        m_is_expression_result:1;
805
806    // used to prevent endless looping into GetpPrintableRepresentation()
807    uint32_t            m_dump_printable_counter;
808    friend class ClangExpressionDeclMap;  // For GetValue
809    friend class ClangExpressionVariable; // For SetName
810    friend class Target;                  // For SetName
811
812    //------------------------------------------------------------------
813    // Constructors and Destructors
814    //------------------------------------------------------------------
815
816    // Use the no-argument constructor to make a constant variable object (with no ExecutionContextScope.)
817
818    ValueObject();
819
820    // Use this constructor to create a "root variable object".  The ValueObject will be locked to this context
821    // through-out its lifespan.
822
823    ValueObject (ExecutionContextScope *exe_scope);
824
825    // Use this constructor to create a ValueObject owned by another ValueObject.  It will inherit the ExecutionContext
826    // of its parent.
827
828    ValueObject (ValueObject &parent);
829
830    ValueObjectManager *
831    GetManager()
832    {
833        return m_manager;
834    }
835
836    virtual bool
837    UpdateValue () = 0;
838
839    virtual void
840    CalculateDynamicValue (lldb::DynamicValueType use_dynamic);
841
842    virtual void
843    CalculateSyntheticValue (lldb::SyntheticValueType use_synthetic);
844
845    // Should only be called by ValueObject::GetChildAtIndex()
846    // Returns a ValueObject managed by this ValueObject's manager.
847    virtual ValueObject *
848    CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index);
849
850    // Should only be called by ValueObject::GetNumChildren()
851    virtual uint32_t
852    CalculateNumChildren() = 0;
853
854    void
855    SetNumChildren (uint32_t num_children);
856
857    void
858    SetValueDidChange (bool value_changed);
859
860    void
861    SetValueIsValid (bool valid);
862
863    void
864    ClearUserVisibleData();
865
866public:
867
868    void
869    SetName (const ConstString &name);
870
871    lldb::addr_t
872    GetPointerValue (AddressType &address_type,
873                     bool scalar_is_load_address);
874
875    lldb::addr_t
876    GetAddressOf (AddressType &address_type,
877                  bool scalar_is_load_address);
878private:
879    //------------------------------------------------------------------
880    // For ValueObject only
881    //------------------------------------------------------------------
882
883    lldb::ValueObjectSP
884    GetValueForExpressionPath_Impl(const char* expression_cstr,
885                                   const char** first_unparsed,
886                                   ExpressionPathScanEndReason* reason_to_stop,
887                                   ExpressionPathEndResultType* final_value_type,
888                                   const GetValueForExpressionPathOptions& options,
889                                   ExpressionPathAftermath* final_task_on_target);
890
891    // this method will ONLY expand [] expressions into a VOList and return
892    // the number of elements it added to the VOList
893    // it will NOT loop through expanding the follow-up of the expression_cstr
894    // for all objects in the list
895    int
896    ExpandArraySliceExpression(const char* expression_cstr,
897                               const char** first_unparsed,
898                               lldb::ValueObjectSP root,
899                               lldb::ValueObjectListSP& list,
900                               ExpressionPathScanEndReason* reason_to_stop,
901                               ExpressionPathEndResultType* final_value_type,
902                               const GetValueForExpressionPathOptions& options,
903                               ExpressionPathAftermath* final_task_on_target);
904
905
906    DISALLOW_COPY_AND_ASSIGN (ValueObject);
907
908};
909
910} // namespace lldb_private
911
912#endif  // liblldb_ValueObject_h_
913