LLDB mainline
ValueObject.h
Go to the documentation of this file.
1//===-- ValueObject.h -------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_CORE_VALUEOBJECT_H
10#define LLDB_CORE_VALUEOBJECT_H
11
12#include "lldb/Core/Value.h"
14#include "lldb/Symbol/Type.h"
16#include "lldb/Target/Process.h"
20#include "lldb/Utility/Status.h"
21#include "lldb/Utility/UserID.h"
22#include "lldb/lldb-defines.h"
24#include "lldb/lldb-forward.h"
26#include "lldb/lldb-types.h"
27
28#include "llvm/ADT/ArrayRef.h"
29#include "llvm/ADT/SmallVector.h"
30#include "llvm/ADT/StringRef.h"
31
32#include <functional>
33#include <initializer_list>
34#include <map>
35#include <mutex>
36#include <optional>
37#include <string>
38#include <utility>
39
40#include <cstddef>
41#include <cstdint>
42
43namespace lldb_private {
44class Declaration;
45class DumpValueObjectOptions;
46class EvaluateExpressionOptions;
47class ExecutionContextScope;
48class Log;
49class Scalar;
50class Stream;
51class SymbolContextScope;
52class TypeFormatImpl;
53class TypeSummaryImpl;
54class TypeSummaryOptions;
55
56/// ValueObject:
57///
58/// This abstract class provides an interface to a particular value, be it a
59/// register, a local or global variable,
60/// that is evaluated in some particular scope. The ValueObject also has the
61/// capability of being the "child" of
62/// some other variable object, and in turn of having children.
63/// If a ValueObject is a root variable object - having no parent - then it must
64/// be constructed with respect to some
65/// particular ExecutionContextScope. If it is a child, it inherits the
66/// ExecutionContextScope from its parent.
67/// The ValueObject will update itself if necessary before fetching its value,
68/// summary, object description, etc.
69/// But it will always update itself in the ExecutionContextScope with which it
70/// was originally created.
71
72/// A brief note on life cycle management for ValueObjects. This is a little
73/// tricky because a ValueObject can contain
74/// various other ValueObjects - the Dynamic Value, its children, the
75/// dereference value, etc. Any one of these can be
76/// handed out as a shared pointer, but for that contained value object to be
77/// valid, the root object and potentially other
78/// of the value objects need to stay around.
79/// We solve this problem by handing out shared pointers to the Value Object and
80/// any of its dependents using a shared
81/// ClusterManager. This treats each shared pointer handed out for the entire
82/// cluster as a reference to the whole
83/// cluster. The whole cluster will stay around until the last reference is
84/// released.
85///
86/// The ValueObject mostly handle this automatically, if a value object is made
87/// with a Parent ValueObject, then it adds
88/// itself to the ClusterManager of the parent.
89
90/// It does mean that external to the ValueObjects we should only ever make
91/// available ValueObjectSP's, never ValueObjects
92/// or pointers to them. So all the "Root level" ValueObject derived
93/// constructors should be private, and
94/// should implement a Create function that new's up object and returns a Shared
95/// Pointer that it gets from the GetSP() method.
96///
97/// However, if you are making an derived ValueObject that will be contained in
98/// a parent value object, you should just
99/// hold onto a pointer to it internally, and by virtue of passing the parent
100/// ValueObject into its constructor, it will
101/// be added to the ClusterManager for the parent. Then if you ever hand out a
102/// Shared Pointer to the contained ValueObject,
103/// just do so by calling GetSP() on the contained object.
104
106public:
110 };
111
121 };
122
124 /// Out of data to parse.
126 /// Child element not found.
128 /// (Synthetic) child element not found.
130 /// [] only allowed for arrays.
132 /// . used when -> should be used.
134 /// -> used when . should be used.
136 /// ObjC ivar expansion not allowed.
138 /// [] not allowed by options.
140 /// [] not valid on objects other than scalars, pointers or arrays.
142 /// [] is good for arrays, but I cannot parse it.
144 /// [] is good for bitfields, but I cannot parse after it.
146 /// Something is malformed in he expression.
148 /// Impossible to apply & operator.
150 /// Impossible to apply * operator.
152 /// [] was expanded into a VOList.
154 /// getting the synthetic children failed.
157 };
158
160 /// Anything but...
162 /// A bitfield.
164 /// A range [low-high].
166 /// A range [].
168 /// Several items in a VOList.
171 };
172
174 /// Just return it.
176 /// Dereference the target.
178 /// Take target's address.
180 };
181
194 };
195
198 None,
201 Both
202 };
203
208
210 bool dot = false, bool no_ivar = false, bool bitfield = true,
211 SyntheticChildrenTraversal synth_traverse =
214 m_allow_bitfields_syntax(bitfield),
215 m_synthetic_children_traversal(synth_traverse) {}
216
219 return *this;
220 }
221
224 return *this;
225 }
226
228 m_no_fragile_ivar = false;
229 return *this;
230 }
231
233 m_no_fragile_ivar = true;
234 return *this;
235 }
236
239 return *this;
240 }
241
244 return *this;
245 }
246
250 return *this;
251 }
252
254 static GetValueForExpressionPathOptions g_default_options;
255
256 return g_default_options;
257 }
258 };
259
261 public:
263
265 bool use_selected = false);
266
268
270
272 return m_exe_ctx_ref;
273 }
274
276 SetUpdated();
278 }
279
280 bool IsConstant() const { return !m_mod_id.IsValid(); }
281
282 ProcessModID GetModID() const { return m_mod_id; }
283
284 void SetUpdateID(ProcessModID new_id) { m_mod_id = new_id; }
285
287
288 void SetUpdated();
289
290 bool NeedsUpdating(bool accept_invalid_exe_ctx) {
291 SyncWithProcessState(accept_invalid_exe_ctx);
292 return m_needs_update;
293 }
294
295 bool IsValid() {
296 const bool accept_invalid_exe_ctx = false;
297 if (!m_mod_id.IsValid())
298 return false;
299 else if (SyncWithProcessState(accept_invalid_exe_ctx)) {
300 if (!m_mod_id.IsValid())
301 return false;
302 }
303 return true;
304 }
305
306 void SetInvalid() {
307 // Use the stop id to mark us as invalid, leave the thread id and the
308 // stack id around for logging and history purposes.
310
311 // Can't update an invalid state.
312 m_needs_update = false;
313 }
314
315 private:
316 bool SyncWithProcessState(bool accept_invalid_exe_ctx);
317
318 ProcessModID m_mod_id; // This is the stop id when this ValueObject was last
319 // evaluated.
321 bool m_needs_update = true;
322 };
323
324 virtual ~ValueObject();
325
327
329
332 }
333
336 }
337
340 }
341
344 }
345
348 }
349
350 void SetNeedsUpdate();
351
353
354 // this vends a TypeImpl that is useful at the SB API layer
356
357 virtual bool CanProvideValue();
358
359 // Subclasses must implement the functions below.
360 virtual std::optional<uint64_t> GetByteSize() = 0;
361
362 virtual lldb::ValueType GetValueType() const = 0;
363
364 // Subclasses can implement the functions below.
366
368
370 return GetCompilerType().GetTypeName();
371 }
372
375 }
376
377 uint32_t
378 GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr) {
379 return GetCompilerType().GetTypeInfo(pointee_or_element_compiler_type);
380 }
381
383
385
387
390 }
391
393
394 bool IsNilReference();
395
397
398 virtual bool IsBaseClass() { return false; }
399
400 bool IsBaseClass(uint32_t &depth);
401
402 virtual bool IsDereferenceOfParent() { return false; }
403
404 bool IsIntegerType(bool &is_signed) {
405 return GetCompilerType().IsIntegerType(is_signed);
406 }
407
408 virtual void GetExpressionPath(
409 Stream &s,
411
413 llvm::StringRef expression,
414 ExpressionPathScanEndReason *reason_to_stop = nullptr,
415 ExpressionPathEndResultType *final_value_type = nullptr,
416 const GetValueForExpressionPathOptions &options =
418 ExpressionPathAftermath *final_task_on_target = nullptr);
419
420 virtual bool IsInScope() { return true; }
421
422 virtual lldb::offset_t GetByteOffset() { return 0; }
423
424 virtual uint32_t GetBitfieldBitSize() { return 0; }
425
426 virtual uint32_t GetBitfieldBitOffset() { return 0; }
427
428 bool IsBitfield() {
429 return (GetBitfieldBitSize() != 0) || (GetBitfieldBitOffset() != 0);
430 }
431
432 virtual const char *GetValueAsCString();
433
434 virtual bool GetValueAsCString(const lldb_private::TypeFormatImpl &format,
435 std::string &destination);
436
437 bool GetValueAsCString(lldb::Format format, std::string &destination);
438
439 virtual uint64_t GetValueAsUnsigned(uint64_t fail_value,
440 bool *success = nullptr);
441
442 virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success = nullptr);
443
444 virtual bool SetValueFromCString(const char *value_str, Status &error);
445
446 /// Return the module associated with this value object in case the value is
447 /// from an executable file and might have its data in sections of the file.
448 /// This can be used for variables.
449 virtual lldb::ModuleSP GetModule();
450
452
453 /// Given a ValueObject, loop over itself and its parent, and its parent's
454 /// parent, .. until either the given callback returns false, or you end up at
455 /// a null pointer
456 ValueObject *FollowParentChain(std::function<bool(ValueObject *)>);
457
458 virtual bool GetDeclaration(Declaration &decl);
459
460 // The functions below should NOT be modified by subclasses
461 const Status &GetError();
462
463 ConstString GetName() const { return m_name; }
464
465 /// Returns a unique id for this ValueObject.
466 lldb::user_id_t GetID() const { return m_id.GetID(); }
467
468 virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx,
469 bool can_create = true);
470
471 // The method always creates missing children in the path, if necessary.
472 lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef<llvm::StringRef> names);
473
474 virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
475 bool can_create = true);
476
477 virtual size_t GetIndexOfChildWithName(llvm::StringRef name);
478
479 llvm::Expected<uint32_t> GetNumChildren(uint32_t max = UINT32_MAX);
480 /// Like \c GetNumChildren but returns 0 on error. You probably
481 /// shouldn't be using this function. It exists primarily to ease the
482 /// transition to more pervasive error handling while not all APIs
483 /// have been updated.
484 uint32_t GetNumChildrenIgnoringErrors(uint32_t max = UINT32_MAX);
486
487 const Value &GetValue() const { return m_value; }
488
489 Value &GetValue() { return m_value; }
490
491 virtual bool ResolveValue(Scalar &scalar);
492
493 // return 'false' whenever you set the error, otherwise callers may assume
494 // true means everything is OK - this will break breakpoint conditions among
495 // potentially a few others
496 virtual bool IsLogicalTrue(Status &error);
497
498 virtual const char *GetLocationAsCString() {
500 }
501
502 const char *
504
505 bool
506 GetSummaryAsCString(TypeSummaryImpl *summary_ptr, std::string &destination,
508
509 bool GetSummaryAsCString(std::string &destination,
510 const TypeSummaryOptions &options);
511
512 bool GetSummaryAsCString(TypeSummaryImpl *summary_ptr,
513 std::string &destination,
514 const TypeSummaryOptions &options);
515
516 const char *GetObjectDescription();
517
519 ValueObjectRepresentationStyle val_obj_display,
520 lldb::Format custom_format);
521
523 eDisable = false,
524 eAllow = true
525 };
526
527 bool
529 ValueObjectRepresentationStyle val_obj_display =
531 lldb::Format custom_format = lldb::eFormatInvalid,
534 bool do_dump_error = true);
535 bool GetValueIsValid() const { return m_flags.m_value_is_valid; }
536
537 // If you call this on a newly created ValueObject, it will always return
538 // false.
540
541 bool UpdateValueIfNeeded(bool update_format = true);
542
544
546
547 /// Change the name of the current ValueObject. Should *not* be used from a
548 /// synthetic child provider as it would change the name of the non synthetic
549 /// child as well.
550 void SetName(ConstString name) { m_name = name; }
551
552 virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
553 AddressType *address_type = nullptr);
554
555 lldb::addr_t GetPointerValue(AddressType *address_type = nullptr);
556
558
559 lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create);
560
561 lldb::ValueObjectSP GetSyntheticBitFieldChild(uint32_t from, uint32_t to,
562 bool can_create);
563
565 bool can_create);
566
567 virtual lldb::ValueObjectSP
568 GetSyntheticChildAtOffset(uint32_t offset, const CompilerType &type,
569 bool can_create,
570 ConstString name_const_str = ConstString());
571
572 virtual lldb::ValueObjectSP
573 GetSyntheticBase(uint32_t offset, const CompilerType &type, bool can_create,
574 ConstString name_const_str = ConstString());
575
577
579
581
583
585
586 virtual bool HasSyntheticValue();
587
588 virtual bool IsSynthetic() { return false; }
589
592 bool synthValue);
593
595
597
598 /// Creates a copy of the ValueObject with a new name and setting the current
599 /// ValueObject as its parent. It should be used when we want to change the
600 /// name of a ValueObject without modifying the actual ValueObject itself
601 /// (e.g. sythetic child provider).
602 virtual lldb::ValueObjectSP Clone(ConstString new_name);
603
605
607
609 AddressType address_type = eAddressTypeLoad) {}
610
611 lldb::ValueObjectSP Cast(const CompilerType &compiler_type);
612
613 virtual lldb::ValueObjectSP DoCast(const CompilerType &compiler_type);
614
615 virtual lldb::ValueObjectSP CastPointerType(const char *name,
616 CompilerType &ast_type);
617
618 virtual lldb::ValueObjectSP CastPointerType(const char *name,
619 lldb::TypeSP &type_sp);
620
621 /// If this object represents a C++ class with a vtable, return an object
622 /// that represents the virtual function table. If the object isn't a class
623 /// with a vtable, return a valid ValueObject with the error set correctly.
625 // The backing bits of this value object were updated, clear any descriptive
626 // string, so we know we have to refetch them.
631 }
632
633 virtual bool IsDynamic() { return false; }
634
635 virtual bool DoesProvideSyntheticValue() { return false; }
636
639 }
640
641 virtual void SetSyntheticChildrenGenerated(bool b) {
643 }
644
646
647 void Dump(Stream &s);
648
649 void Dump(Stream &s, const DumpValueObjectOptions &options);
650
652 CreateValueObjectFromExpression(llvm::StringRef name,
653 llvm::StringRef expression,
654 const ExecutionContext &exe_ctx);
655
657 CreateValueObjectFromExpression(llvm::StringRef name,
658 llvm::StringRef expression,
659 const ExecutionContext &exe_ctx,
660 const EvaluateExpressionOptions &options);
661
663 CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address,
664 const ExecutionContext &exe_ctx,
665 CompilerType type);
666
668 CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data,
669 const ExecutionContext &exe_ctx, CompilerType type);
670
672
673 /// Returns true if this is a char* or a char[] if it is a char* and
674 /// check_pointer is true, it also checks that the pointer is valid.
675 bool IsCStringContainer(bool check_pointer = false);
676
677 std::pair<size_t, bool>
679 bool honor_array);
680
681 virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
682 uint32_t item_count = 1);
683
684 virtual uint64_t GetData(DataExtractor &data, Status &error);
685
686 virtual bool SetData(DataExtractor &data, Status &error);
687
688 virtual bool GetIsConstant() const { return m_update_point.IsConstant(); }
689
691 const bool accept_invalid_exe_ctx =
693 return m_update_point.NeedsUpdating(accept_invalid_exe_ctx);
694 }
695
697
698 lldb::Format GetFormat() const;
699
700 virtual void SetFormat(lldb::Format format) {
701 if (format != m_format)
703 m_format = format;
704 }
705
707
710 }
711
714 return m_type_summary_sp;
715 }
716
718 m_type_summary_sp = std::move(format);
720 }
721
723 m_type_format_sp = std::move(format);
725 }
726
729 return m_type_format_sp;
730 }
731
733 if (synth_sp.get() == m_synthetic_children_sp.get())
734 return;
736 m_synthetic_children_sp = synth_sp;
737 }
738
742 }
743
744 // Use GetParent for display purposes, but if you want to tell the parent to
745 // update itself then use m_parent. The ValueObjectDynamicValue's parent is
746 // not the correct parent for displaying, they are really siblings, so for
747 // display it needs to route through to its grandparent.
748 virtual ValueObject *GetParent() { return m_parent; }
749
750 virtual const ValueObject *GetParent() const { return m_parent; }
751
753
756 }
757
759
762 }
763
764 /// Find out if a ValueObject might have children.
765 ///
766 /// This call is much more efficient than CalculateNumChildren() as
767 /// it doesn't need to complete the underlying type. This is designed
768 /// to be used in a UI environment in order to detect if the
769 /// disclosure triangle should be displayed or not.
770 ///
771 /// This function returns true for class, union, structure,
772 /// pointers, references, arrays and more. Again, it does so without
773 /// doing any expensive type completion.
774 ///
775 /// \return
776 /// Returns \b true if the ValueObject might have children, or \b
777 /// false otherwise.
778 virtual bool MightHaveChildren();
779
780 virtual lldb::VariableSP GetVariable() { return nullptr; }
781
782 virtual bool IsRuntimeSupportValue();
783
784 virtual uint64_t GetLanguageFlags() { return m_language_flags; }
785
786 virtual void SetLanguageFlags(uint64_t flags) { m_language_flags = flags; }
787
788protected:
790
792 public:
793 ChildrenManager() = default;
794
795 bool HasChildAtIndex(size_t idx) {
796 std::lock_guard<std::recursive_mutex> guard(m_mutex);
797 return (m_children.find(idx) != m_children.end());
798 }
799
801 std::lock_guard<std::recursive_mutex> guard(m_mutex);
802 const auto iter = m_children.find(idx);
803 return ((iter == m_children.end()) ? nullptr : iter->second);
804 }
805
806 void SetChildAtIndex(size_t idx, ValueObject *valobj) {
807 // we do not need to be mutex-protected to make a pair
808 ChildrenPair pair(idx, valobj);
809 std::lock_guard<std::recursive_mutex> guard(m_mutex);
810 m_children.insert(pair);
811 }
812
813 void SetChildrenCount(size_t count) { Clear(count); }
814
816
817 void Clear(size_t new_count = 0) {
818 std::lock_guard<std::recursive_mutex> guard(m_mutex);
819 m_children_count = new_count;
820 m_children.clear();
821 }
822
823 private:
824 typedef std::map<size_t, ValueObject *> ChildrenMap;
825 typedef ChildrenMap::iterator ChildrenIterator;
826 typedef ChildrenMap::value_type ChildrenPair;
827 std::recursive_mutex m_mutex;
830 };
831
832 // Classes that inherit from ValueObject can see and modify these
833
834 /// The parent value object, or nullptr if this has no parent.
836 /// The root of the hierarchy for this ValueObject (or nullptr if never
837 /// calculated).
838 ValueObject *m_root = nullptr;
839 /// Stores both the stop id and the full context at which this value was last
840 /// updated. When we are asked to update the value object, we check whether
841 /// the context & stop id are the same before updating.
843 /// The name of this object.
845 /// A data extractor that can be used to extract the value.
848 /// An error object that can describe any errors that occur when updating
849 /// values.
851 /// Cached value string that will get cleared if/when the value is updated.
852 std::string m_value_str;
853 /// Cached old value string from the last time the value was gotten
854 std::string m_old_value_str;
855 /// Cached location string that will get cleared if/when the value is updated.
856 std::string m_location_str;
857 /// Cached summary string that will get cleared if/when the value is updated.
858 std::string m_summary_str;
859 /// Cached result of the "object printer". This differs from the summary
860 /// in that the summary is consed up by us, the object_desc_string is builtin.
861 std::string m_object_desc_str;
862 /// If the type of the value object should be overridden, the type to impose.
864
865 /// This object is managed by the root object (any ValueObject that gets
866 /// created without a parent.) The manager gets passed through all the
867 /// generations of dependent objects, and will keep the whole cluster of
868 /// objects alive as long as a shared pointer to any of them has been handed
869 /// out. Shared pointers to value objects must always be made with the GetSP
870 /// method.
872
874 std::map<ConstString, ValueObject *> m_synthetic_children;
875
879
880 /// We have to hold onto a shared pointer to this one because it is created
881 /// as an independent ValueObjectConstResult, which isn't managed by us.
883
892
893 llvm::SmallVector<uint8_t, 16> m_value_checksum;
894
896
897 uint64_t m_language_flags = 0;
898
899 /// Unique identifier for every value object.
901
902 // Utility class for initializing all bitfields in ValueObject's constructors.
903 // FIXME: This could be done via default initializers once we have C++20.
904 struct Bitflags {
912 m_value_is_valid = false;
913 m_value_did_change = false;
915 m_old_value_valid = false;
916 m_is_deref_of_parent = false;
919 m_is_child_at_offset = false;
920 m_is_getting_summary = false;
923 }
925
926 friend class ValueObjectChild;
927 friend class ExpressionVariable; // For SetName
928 friend class Target; // For SetName
930 friend class ValueObjectSynthetic; // For ClearUserVisibleData
931
932 /// Use this constructor to create a "root variable object". The ValueObject
933 /// will be locked to this context through-out its lifespan.
935 AddressType child_ptr_or_ref_addr_type = eAddressTypeLoad);
936
937 /// Use this constructor to create a ValueObject owned by another ValueObject.
938 /// It will inherit the ExecutionContext of its parent.
939 ValueObject(ValueObject &parent);
940
942
943 virtual bool UpdateValue() = 0;
944
946 return eLazyBoolCalculate;
947 }
948
949 virtual void CalculateDynamicValue(lldb::DynamicValueType use_dynamic);
950
953 }
954
955 virtual bool HasDynamicValueTypeInfo() { return false; }
956
957 virtual void CalculateSyntheticValue();
958
959 /// Should only be called by ValueObject::GetChildAtIndex().
960 ///
961 /// \return A ValueObject managed by this ValueObject's manager.
962 virtual ValueObject *CreateChildAtIndex(size_t idx,
963 bool synthetic_array_member,
964 int32_t synthetic_index);
965
966 /// Should only be called by ValueObject::GetNumChildren().
967 virtual llvm::Expected<uint32_t>
968 CalculateNumChildren(uint32_t max = UINT32_MAX) = 0;
969
970 void SetNumChildren(uint32_t num_children);
971
972 void SetValueDidChange(bool value_changed) {
973 m_flags.m_value_did_change = value_changed;
974 }
975
976 void SetValueIsValid(bool valid) { m_flags.m_value_is_valid = valid; }
977
980
981 void AddSyntheticChild(ConstString key, ValueObject *valobj);
982
984
986
987 // Subclasses must implement the functions below.
988
990
991 const char *GetLocationAsCStringImpl(const Value &value,
992 const DataExtractor &data);
993
994 bool IsChecksumEmpty() { return m_value_checksum.empty(); }
995
997
998protected:
1000
1001private:
1005 }
1006
1008 llvm::StringRef expression_cstr,
1009 ExpressionPathScanEndReason *reason_to_stop,
1010 ExpressionPathEndResultType *final_value_type,
1011 const GetValueForExpressionPathOptions &options,
1012 ExpressionPathAftermath *final_task_on_target);
1013
1014 ValueObject(const ValueObject &) = delete;
1015 const ValueObject &operator=(const ValueObject &) = delete;
1016};
1017
1018} // namespace lldb_private
1019
1020#endif // LLDB_CORE_VALUEOBJECT_H
static llvm::raw_ostream & error(Stream &strm)
std::shared_ptr< T > GetSharedPointer(T *desired_object)
Definition: SharedCluster.h:40
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
lldb::LanguageType GetMinimumLanguage()
bool IsArrayType(CompilerType *element_type=nullptr, uint64_t *size=nullptr, bool *is_incomplete=nullptr) const
ConstString GetTypeName(bool BaseOnly=false) const
bool IsIntegerType(bool &is_signed) const
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
bool IsPointerOrReferenceType(CompilerType *pointee_type=nullptr) const
bool IsPointerType(CompilerType *pointee_type=nullptr) const
A uniqued constant string class.
Definition: ConstString.h:40
An data extractor class.
Definition: DataExtractor.h:48
A class that describes the declaration location of a lldb object.
Definition: Declaration.h:24
Execution context objects refer to objects in the execution of the program that is being debugged.
lldb::StackFrameSP GetFrameSP() const
Get accessor that creates a strong reference from the weak frame reference contained in this object.
lldb::ThreadSP GetThreadSP() const
Get accessor that creates a strong reference from the weak thread reference contained in this object.
lldb::TargetSP GetTargetSP() const
Get accessor that creates a strong reference from the weak target reference contained in this object.
lldb::ProcessSP GetProcessSP() const
Get accessor that creates a strong reference from the weak process reference contained in this object...
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
bool IsValid() const
Definition: Process.h:267
An error handling class.
Definition: Status.h:44
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
A child of another ValueObject.
A class wrapping common implementation details for operations in ValueObjectConstResult ( & Child ) t...
A ValueObject that obtains its children from some source other than real information.
ValueObject * GetChildAtIndex(uint32_t idx)
Definition: ValueObject.h:800
void SetChildAtIndex(size_t idx, ValueObject *valobj)
Definition: ValueObject.h:806
std::map< size_t, ValueObject * > ChildrenMap
Definition: ValueObject.h:824
bool SyncWithProcessState(bool accept_invalid_exe_ctx)
void SetUpdateID(ProcessModID new_id)
Definition: ValueObject.h:284
const ExecutionContextRef & GetExecutionContextRef() const
Definition: ValueObject.h:271
bool NeedsUpdating(bool accept_invalid_exe_ctx)
Definition: ValueObject.h:290
AddressType m_address_type_of_ptr_or_ref_children
Definition: ValueObject.h:891
void SetValueIsValid(bool valid)
Definition: ValueObject.h:976
lldb::TypeFormatImplSP GetValueFormat()
Definition: ValueObject.h:727
EvaluationPoint m_update_point
Stores both the stop id and the full context at which this value was last updated.
Definition: ValueObject.h:842
lldb::TypeSummaryImplSP GetSummaryFormat()
Definition: ValueObject.h:712
llvm::SmallVector< uint8_t, 16 > m_value_checksum
Definition: ValueObject.h:893
virtual uint32_t GetBitfieldBitSize()
Definition: ValueObject.h:424
void ClearUserVisibleData(uint32_t items=ValueObject::eClearUserVisibleDataItemsAllStrings)
ValueObject * FollowParentChain(std::function< bool(ValueObject *)>)
Given a ValueObject, loop over itself and its parent, and its parent's parent, .
CompilerType m_override_type
If the type of the value object should be overridden, the type to impose.
Definition: ValueObject.h:863
virtual bool IsInScope()
Definition: ValueObject.h:420
lldb::ValueObjectSP Cast(const CompilerType &compiler_type)
const EvaluationPoint & GetUpdatePoint() const
Definition: ValueObject.h:326
void AddSyntheticChild(ConstString key, ValueObject *valobj)
virtual uint64_t GetData(DataExtractor &data, Status &error)
uint32_t m_last_format_mgr_revision
Definition: ValueObject.h:886
EvaluationPoint & GetUpdatePoint()
Definition: ValueObject.h:328
bool DumpPrintableRepresentation(Stream &s, ValueObjectRepresentationStyle val_obj_display=eValueObjectRepresentationStyleSummary, lldb::Format custom_format=lldb::eFormatInvalid, PrintableRepresentationSpecialCases special=PrintableRepresentationSpecialCases::eAllow, bool do_dump_error=true)
ValueObject * m_deref_valobj
Definition: ValueObject.h:878
virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx, bool can_create=true)
virtual lldb::DynamicValueType GetDynamicValueTypeImpl()
Definition: ValueObject.h:951
const ValueObject & operator=(const ValueObject &)=delete
lldb::addr_t GetPointerValue(AddressType *address_type=nullptr)
virtual bool GetIsConstant() const
Definition: ValueObject.h:688
virtual bool MightHaveChildren()
Find out if a ValueObject might have children.
static lldb::ValueObjectSP CreateValueObjectFromExpression(llvm::StringRef name, llvm::StringRef expression, const ExecutionContext &exe_ctx)
virtual bool IsDereferenceOfParent()
Definition: ValueObject.h:402
CompilerType GetCompilerType()
Definition: ValueObject.h:352
virtual const ValueObject * GetParent() const
Definition: ValueObject.h:750
void SetValueFormat(lldb::TypeFormatImplSP format)
Definition: ValueObject.h:722
virtual lldb::addr_t GetLiveAddress()
Definition: ValueObject.h:606
virtual void CalculateSyntheticValue()
void SetPreferredDisplayLanguage(lldb::LanguageType lt)
Definition: ValueObject.h:708
struct lldb_private::ValueObject::Bitflags m_flags
ClusterManager< ValueObject > ValueObjectManager
Definition: ValueObject.h:789
std::string m_summary_str
Cached summary string that will get cleared if/when the value is updated.
Definition: ValueObject.h:858
virtual lldb::ValueObjectSP DoCast(const CompilerType &compiler_type)
lldb::TypeSummaryImplSP m_type_summary_sp
Definition: ValueObject.h:887
lldb::ValueObjectSP GetSP()
Definition: ValueObject.h:545
ChildrenManager m_children
Definition: ValueObject.h:873
virtual void SetLanguageFlags(uint64_t flags)
Definition: ValueObject.h:786
virtual lldb::ValueObjectSP CastPointerType(const char *name, CompilerType &ast_type)
Status m_error
An error object that can describe any errors that occur when updating values.
Definition: ValueObject.h:850
virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx=0, uint32_t item_count=1)
lldb::ValueObjectSP GetSyntheticValue()
ValueObjectManager * m_manager
This object is managed by the root object (any ValueObject that gets created without a parent....
Definition: ValueObject.h:871
lldb::ValueObjectSP GetSyntheticBitFieldChild(uint32_t from, uint32_t to, bool can_create)
lldb::ProcessSP GetProcessSP() const
Definition: ValueObject.h:338
lldb::ValueObjectSP GetSyntheticChild(ConstString key) const
@ eExpressionPathScanEndReasonArrowInsteadOfDot
-> used when . should be used.
Definition: ValueObject.h:135
@ eExpressionPathScanEndReasonDereferencingFailed
Impossible to apply * operator.
Definition: ValueObject.h:151
@ eExpressionPathScanEndReasonNoSuchSyntheticChild
(Synthetic) child element not found.
Definition: ValueObject.h:129
@ eExpressionPathScanEndReasonNoSuchChild
Child element not found.
Definition: ValueObject.h:127
@ eExpressionPathScanEndReasonDotInsteadOfArrow
. used when -> should be used.
Definition: ValueObject.h:133
@ eExpressionPathScanEndReasonEndOfString
Out of data to parse.
Definition: ValueObject.h:125
@ eExpressionPathScanEndReasonBitfieldRangeOperatorMet
[] is good for bitfields, but I cannot parse after it.
Definition: ValueObject.h:145
@ eExpressionPathScanEndReasonRangeOperatorNotAllowed
[] not allowed by options.
Definition: ValueObject.h:139
@ eExpressionPathScanEndReasonEmptyRangeNotAllowed
[] only allowed for arrays.
Definition: ValueObject.h:131
@ eExpressionPathScanEndReasonRangeOperatorExpanded
[] was expanded into a VOList.
Definition: ValueObject.h:153
@ eExpressionPathScanEndReasonRangeOperatorInvalid
[] not valid on objects other than scalars, pointers or arrays.
Definition: ValueObject.h:141
@ eExpressionPathScanEndReasonUnexpectedSymbol
Something is malformed in he expression.
Definition: ValueObject.h:147
@ eExpressionPathScanEndReasonArrayRangeOperatorMet
[] is good for arrays, but I cannot parse it.
Definition: ValueObject.h:143
@ eExpressionPathScanEndReasonSyntheticValueMissing
getting the synthetic children failed.
Definition: ValueObject.h:155
@ eExpressionPathScanEndReasonTakingAddressFailed
Impossible to apply & operator.
Definition: ValueObject.h:149
@ eExpressionPathScanEndReasonFragileIVarNotAllowed
ObjC ivar expansion not allowed.
Definition: ValueObject.h:137
virtual bool UpdateValue()=0
lldb::Format GetFormat() const
virtual uint64_t GetLanguageFlags()
Definition: ValueObject.h:784
virtual lldb::VariableSP GetVariable()
Definition: ValueObject.h:780
@ eExpressionPathAftermathNothing
Just return it.
Definition: ValueObject.h:175
@ eExpressionPathAftermathDereference
Dereference the target.
Definition: ValueObject.h:177
@ eExpressionPathAftermathTakeAddress
Take target's address.
Definition: ValueObject.h:179
virtual void SetSyntheticChildrenGenerated(bool b)
Definition: ValueObject.h:641
virtual std::optional< uint64_t > GetByteSize()=0
virtual size_t GetIndexOfChildWithName(llvm::StringRef name)
lldb::user_id_t GetID() const
Returns a unique id for this ValueObject.
Definition: ValueObject.h:466
virtual void DoUpdateChildrenAddressType(ValueObject &valobj)
Definition: ValueObject.h:999
ValueObject * GetNonBaseClassParent()
lldb::ValueObjectSP GetValueForExpressionPath(llvm::StringRef expression, ExpressionPathScanEndReason *reason_to_stop=nullptr, ExpressionPathEndResultType *final_value_type=nullptr, const GetValueForExpressionPathOptions &options=GetValueForExpressionPathOptions::DefaultOptions(), ExpressionPathAftermath *final_task_on_target=nullptr)
virtual lldb::ValueObjectSP GetSyntheticChildAtOffset(uint32_t offset, const CompilerType &type, bool can_create, ConstString name_const_str=ConstString())
virtual void CalculateDynamicValue(lldb::DynamicValueType use_dynamic)
DataExtractor m_data
A data extractor that can be used to extract the value.
Definition: ValueObject.h:846
virtual CompilerType GetCompilerTypeImpl()=0
virtual lldb::ValueObjectSP GetSyntheticBase(uint32_t offset, const CompilerType &type, bool can_create, ConstString name_const_str=ConstString())
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
virtual bool IsDynamic()
Definition: ValueObject.h:633
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create=true)
llvm::Expected< uint32_t > GetNumChildren(uint32_t max=UINT32_MAX)
virtual lldb::ValueType GetValueType() const =0
virtual void GetExpressionPath(Stream &s, GetExpressionPathFormat=eGetExpressionPathFormatDereferencePointers)
virtual bool HasSyntheticValue()
lldb::StackFrameSP GetFrameSP() const
Definition: ValueObject.h:346
lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef< llvm::StringRef > names)
void SetSummaryFormat(lldb::TypeSummaryImplSP format)
Definition: ValueObject.h:717
virtual bool IsRuntimeSupportValue()
virtual ConstString GetTypeName()
Definition: ValueObject.h:365
DataExtractor & GetDataExtractor()
virtual LazyBool CanUpdateWithInvalidExecutionContext()
Definition: ValueObject.h:945
static lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type)
void SetValueDidChange(bool value_changed)
Definition: ValueObject.h:972
lldb::ThreadSP GetThreadSP() const
Definition: ValueObject.h:342
ValueObjectManager * GetManager()
Definition: ValueObject.h:941
ValueObject * m_root
The root of the hierarchy for this ValueObject (or nullptr if never calculated).
Definition: ValueObject.h:838
bool GetValueIsValid() const
Definition: ValueObject.h:535
virtual lldb::ModuleSP GetModule()
Return the module associated with this value object in case the value is from an executable file and ...
virtual lldb::ValueObjectSP GetDynamicValue(lldb::DynamicValueType valueType)
virtual ConstString GetDisplayTypeName()
Definition: ValueObject.h:367
virtual lldb::ValueObjectSP AddressOf(Status &error)
lldb::DynamicValueType GetDynamicValueType()
lldb::SyntheticChildrenSP GetSyntheticChildren()
Definition: ValueObject.h:739
lldb::LanguageType m_preferred_display_language
Definition: ValueObject.h:895
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr)
Definition: ValueObject.h:378
virtual llvm::Expected< uint32_t > CalculateNumChildren(uint32_t max=UINT32_MAX)=0
Should only be called by ValueObject::GetNumChildren().
lldb::LanguageType GetObjectRuntimeLanguage()
Definition: ValueObject.h:373
virtual lldb::ValueObjectSP CreateConstantValue(ConstString name)
virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address=true, AddressType *address_type=nullptr)
virtual bool IsLogicalTrue(Status &error)
lldb::Format m_last_format
Definition: ValueObject.h:885
virtual SymbolContextScope * GetSymbolContextScope()
virtual bool HasDynamicValueTypeInfo()
Definition: ValueObject.h:955
ValueObject * m_synthetic_value
Definition: ValueObject.h:877
void SetNumChildren(uint32_t num_children)
ValueObject * m_parent
The parent value object, or nullptr if this has no parent.
Definition: ValueObject.h:835
virtual bool IsBaseClass()
Definition: ValueObject.h:398
virtual bool GetDeclaration(Declaration &decl)
virtual lldb::ValueObjectSP Clone(ConstString new_name)
Creates a copy of the ValueObject with a new name and setting the current ValueObject as its parent.
lldb::ValueObjectSP GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue, bool synthValue)
virtual bool IsSyntheticChildrenGenerated()
Definition: ValueObject.h:637
virtual ValueObject * CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index)
Should only be called by ValueObject::GetChildAtIndex().
lldb::ValueObjectSP m_addr_of_valobj_sp
We have to hold onto a shared pointer to this one because it is created as an independent ValueObject...
Definition: ValueObject.h:882
std::pair< size_t, bool > ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, Status &error, bool honor_array)
ValueObject(const ValueObject &)=delete
bool UpdateValueIfNeeded(bool update_format=true)
void SetName(ConstString name)
Change the name of the current ValueObject.
Definition: ValueObject.h:550
AddressType GetAddressTypeOfChildren()
const Status & GetError()
lldb::TypeFormatImplSP m_type_format_sp
Definition: ValueObject.h:888
lldb::TargetSP GetTargetSP() const
Definition: ValueObject.h:334
@ eExpressionPathEndResultTypePlain
Anything but...
Definition: ValueObject.h:161
@ eExpressionPathEndResultTypeBoundedRange
A range [low-high].
Definition: ValueObject.h:165
@ eExpressionPathEndResultTypeBitfield
A bitfield.
Definition: ValueObject.h:163
@ eExpressionPathEndResultTypeValueObjectList
Several items in a VOList.
Definition: ValueObject.h:169
@ eExpressionPathEndResultTypeUnboundedRange
A range [].
Definition: ValueObject.h:167
virtual lldb::ValueObjectSP Dereference(Status &error)
static lldb::ValueObjectSP CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type)
void SetPreferredDisplayLanguageIfNeeded(lldb::LanguageType)
virtual const char * GetValueAsCString()
bool HasSpecialPrintableRepresentation(ValueObjectRepresentationStyle val_obj_display, lldb::Format custom_format)
virtual const char * GetLocationAsCString()
Definition: ValueObject.h:498
ConstString GetName() const
Definition: ValueObject.h:463
std::string m_location_str
Cached location string that will get cleared if/when the value is updated.
Definition: ValueObject.h:856
lldb::ValueObjectSP GetVTable()
If this object represents a C++ class with a vtable, return an object that represents the virtual fun...
virtual bool SetValueFromCString(const char *value_str, Status &error)
virtual lldb::ValueObjectSP GetStaticValue()
Definition: ValueObject.h:580
lldb::ValueObjectSP Persist()
std::string m_object_desc_str
Cached result of the "object printer".
Definition: ValueObject.h:861
virtual ValueObject * GetParent()
Definition: ValueObject.h:748
virtual ConstString GetQualifiedTypeName()
Definition: ValueObject.h:369
virtual bool DoesProvideSyntheticValue()
Definition: ValueObject.h:635
virtual CompilerType MaybeCalculateCompleteType()
lldb::SyntheticChildrenSP m_synthetic_children_sp
Definition: ValueObject.h:889
const char * GetObjectDescription()
virtual uint32_t GetBitfieldBitOffset()
Definition: ValueObject.h:426
std::string m_old_value_str
Cached old value string from the last time the value was gotten.
Definition: ValueObject.h:854
virtual lldb::ValueObjectSP GetNonSyntheticValue()
Definition: ValueObject.h:582
lldb::ValueObjectSP GetSyntheticExpressionPathChild(const char *expression, bool can_create)
virtual bool SetData(DataExtractor &data, Status &error)
virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success=nullptr)
const char * GetSummaryAsCString(lldb::LanguageType lang=lldb::eLanguageTypeUnknown)
@ eValueObjectRepresentationStyleLanguageSpecific
Definition: ValueObject.h:115
std::string m_value_str
Cached value string that will get cleared if/when the value is updated.
Definition: ValueObject.h:852
bool IsIntegerType(bool &is_signed)
Definition: ValueObject.h:404
lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create)
virtual bool ResolveValue(Scalar &scalar)
void SetSyntheticChildren(const lldb::SyntheticChildrenSP &synth_sp)
Definition: ValueObject.h:732
ConstString m_name
The name of this object.
Definition: ValueObject.h:844
const char * GetLocationAsCStringImpl(const Value &value, const DataExtractor &data)
virtual void SetFormat(lldb::Format format)
Definition: ValueObject.h:700
ValueObject * m_dynamic_value
Definition: ValueObject.h:876
ProcessModID m_user_id_of_forced_summary
Definition: ValueObject.h:890
virtual TypeImpl GetTypeImpl()
Definition: ValueObject.h:355
bool IsCStringContainer(bool check_pointer=false)
Returns true if this is a char* or a char[] if it is a char* and check_pointer is true,...
virtual bool IsSynthetic()
Definition: ValueObject.h:588
std::map< ConstString, ValueObject * > m_synthetic_children
Definition: ValueObject.h:874
const ExecutionContextRef & GetExecutionContextRef() const
Definition: ValueObject.h:330
uint32_t GetNumChildrenIgnoringErrors(uint32_t max=UINT32_MAX)
Like GetNumChildren but returns 0 on error.
virtual bool CanProvideValue()
UserID m_id
Unique identifier for every value object.
Definition: ValueObject.h:900
const Value & GetValue() const
Definition: ValueObject.h:487
virtual lldb::LanguageType GetPreferredDisplayLanguage()
virtual void SetLiveAddress(lldb::addr_t addr=LLDB_INVALID_ADDRESS, AddressType address_type=eAddressTypeLoad)
Definition: ValueObject.h:608
void SetAddressTypeOfChildren(AddressType at)
Definition: ValueObject.h:754
virtual lldb::offset_t GetByteOffset()
Definition: ValueObject.h:422
lldb::ValueObjectSP GetValueForExpressionPath_Impl(llvm::StringRef expression_cstr, ExpressionPathScanEndReason *reason_to_stop, ExpressionPathEndResultType *final_value_type, const GetValueForExpressionPathOptions &options, ExpressionPathAftermath *final_task_on_target)
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:82
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
Definition: lldb-forward.h:412
std::shared_ptr< lldb_private::TypeSummaryImpl > TypeSummaryImplSP
Definition: lldb-forward.h:463
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:438
std::shared_ptr< lldb_private::TypeFormatImpl > TypeFormatImplSP
Definition: lldb-forward.h:460
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:472
Format
Display format definitions.
uint64_t offset_t
Definition: lldb-types.h:83
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Type > TypeSP
Definition: lldb-forward.h:449
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:381
std::shared_ptr< lldb_private::Variable > VariableSP
Definition: lldb-forward.h:474
std::shared_ptr< lldb_private::SyntheticChildren > SyntheticChildrenSP
Definition: lldb-forward.h:433
uint64_t user_id_t
Definition: lldb-types.h:80
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
Definition: lldb-forward.h:329
uint64_t addr_t
Definition: lldb-types.h:79
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:436
@ eNoDynamicValues
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:365
A mix in class that contains a generic user ID.
Definition: UserID.h:31
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
GetValueForExpressionPathOptions & DontAllowFragileIVar()
Definition: ValueObject.h:232
GetValueForExpressionPathOptions & SetSyntheticChildrenTraversal(SyntheticChildrenTraversal traverse)
Definition: ValueObject.h:248
GetValueForExpressionPathOptions & DoAllowFragileIVar()
Definition: ValueObject.h:227
GetValueForExpressionPathOptions(bool dot=false, bool no_ivar=false, bool bitfield=true, SyntheticChildrenTraversal synth_traverse=SyntheticChildrenTraversal::ToSynthetic)
Definition: ValueObject.h:209
static const GetValueForExpressionPathOptions DefaultOptions()
Definition: ValueObject.h:253
GetValueForExpressionPathOptions & DontCheckDotVsArrowSyntax()
Definition: ValueObject.h:222
GetValueForExpressionPathOptions & DontAllowBitfieldSyntax()
Definition: ValueObject.h:242
GetValueForExpressionPathOptions & DoCheckDotVsArrowSyntax()
Definition: ValueObject.h:217
GetValueForExpressionPathOptions & DoAllowBitfieldSyntax()
Definition: ValueObject.h:237