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_VALUEOBJECT_VALUEOBJECT_H
10#define LLDB_VALUEOBJECT_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;
48class Log;
49class Scalar;
50class Stream;
52class TypeFormatImpl;
53class TypeSummaryImpl;
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:
111
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
172
174 /// Just return it.
176 /// Dereference the target.
178 /// Take target's address.
180 };
181
195
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
221
226
231
236
241
246
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();
277 m_mod_id.SetInvalid();
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.
309 m_mod_id.SetInvalid();
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
331 return m_update_point.GetExecutionContextRef();
332 }
333
335 return m_update_point.GetExecutionContextRef().GetTargetSP();
336 }
337
339 return m_update_point.GetExecutionContextRef().GetProcessSP();
340 }
341
343 return m_update_point.GetExecutionContextRef().GetThreadSP();
344 }
345
347 return m_update_point.GetExecutionContextRef().GetFrameSP();
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 llvm::Expected<uint64_t> GetByteSize() = 0;
361
362 virtual lldb::ValueType GetValueType() const = 0;
363
364 // Subclasses can implement the functions below.
366
368
372
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
391
393
394 bool IsNilReference();
395
397
398 virtual bool IsBaseClass() { return false; }
399
400 virtual bool IsDereferenceOfParent() { return false; }
401
402 bool IsIntegerType(bool &is_signed) {
403 return GetCompilerType().IsIntegerType(is_signed);
404 }
405
406 virtual void GetExpressionPath(
407 Stream &s,
409
411 llvm::StringRef expression,
412 ExpressionPathScanEndReason *reason_to_stop = nullptr,
413 ExpressionPathEndResultType *final_value_type = nullptr,
414 const GetValueForExpressionPathOptions &options =
416 ExpressionPathAftermath *final_task_on_target = nullptr);
417
418 virtual bool IsInScope() { return true; }
419
420 virtual lldb::offset_t GetByteOffset() { return 0; }
421
422 virtual uint32_t GetBitfieldBitSize() { return 0; }
423
424 virtual uint32_t GetBitfieldBitOffset() { return 0; }
425
426 bool IsBitfield() {
427 return (GetBitfieldBitSize() != 0) || (GetBitfieldBitOffset() != 0);
428 }
429
430 virtual const char *GetValueAsCString();
431
432 virtual bool GetValueAsCString(const lldb_private::TypeFormatImpl &format,
433 std::string &destination);
434
435 bool GetValueAsCString(lldb::Format format, std::string &destination);
436
437 virtual uint64_t GetValueAsUnsigned(uint64_t fail_value,
438 bool *success = nullptr);
439
440 virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success = nullptr);
441
442 /// If the current ValueObject is of an appropriate type, convert the
443 /// value to an APSInt and return that. Otherwise return an error.
444 llvm::Expected<llvm::APSInt> GetValueAsAPSInt();
445
446 /// If the current ValueObject is of an appropriate type, convert the
447 /// value to an APFloat and return that. Otherwise return an error.
448 llvm::Expected<llvm::APFloat> GetValueAsAPFloat();
449
450 /// If the current ValueObject is of an appropriate type, convert the
451 /// value to a boolean and return that. Otherwise return an error.
452 llvm::Expected<bool> GetValueAsBool();
453
454 /// Update an existing integer ValueObject with a new integer value. If
455 /// can_update_var is true, will allow updating objects associated with
456 /// program variables; otherwise not.
457 llvm::Error SetValueFromInteger(const llvm::APInt &value,
458 bool can_update_var = true);
459
460 /// Update an existing integer ValueObject with an integer value created
461 /// frome 'new_val_sp'. If can_update_var is true, will allow updating objects
462 /// associated with program variables; otherwise not.
463 llvm::Error SetValueFromInteger(lldb::ValueObjectSP new_val_sp,
464 bool can_update_var = true);
465
466 virtual bool SetValueFromCString(const char *value_str, Status &error);
467
468 /// Return the module associated with this value object in case the value is
469 /// from an executable file and might have its data in sections of the file.
470 /// This can be used for variables.
471 virtual lldb::ModuleSP GetModule();
472
474
475 /// Given a ValueObject, loop over itself and its parent, and its parent's
476 /// parent, .. until either the given callback returns false, or you end up at
477 /// a null pointer
478 ValueObject *FollowParentChain(std::function<bool(ValueObject *)>);
479
480 virtual bool GetDeclaration(Declaration &decl);
481
482 // The functions below should NOT be modified by subclasses
483 const Status &GetError();
484
485 ConstString GetName() const { return m_name; }
486
487 /// Returns a unique id for this ValueObject.
488 lldb::user_id_t GetID() const { return m_id.GetID(); }
489
490 virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx,
491 bool can_create = true);
492
493 // The method always creates missing children in the path, if necessary.
494 lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef<llvm::StringRef> names);
495
496 virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
497 bool can_create = true);
498
499 /// Return the index of the child named \c name.
500 ///
501 /// The error is for LLDB developers, not for the user: a missing child is the
502 /// ordinary negative answer to a lookup. Callers that cannot propagate it
503 /// should log it rather than call \c llvm::consumeError.
504 virtual llvm::Expected<size_t> GetIndexOfChildWithName(llvm::StringRef name);
505
506 llvm::Expected<uint32_t> GetNumChildren(uint32_t max = UINT32_MAX);
507 /// Like \c GetNumChildren but returns 0 on error. You probably
508 /// shouldn't be using this function. It exists primarily to ease the
509 /// transition to more pervasive error handling while not all APIs
510 /// have been updated.
511 uint32_t GetNumChildrenIgnoringErrors(uint32_t max = UINT32_MAX);
513
514 const Value &GetValue() const { return m_value; }
515
516 Value &GetValue() { return m_value; }
517
518 virtual bool ResolveValue(Scalar &scalar);
519
520 // return 'false' whenever you set the error, otherwise callers may assume
521 // true means everything is OK - this will break breakpoint conditions among
522 // potentially a few others
523 virtual bool IsLogicalTrue(Status &error);
524
525 virtual const char *GetLocationAsCString() {
527 }
528
529 const char *
531
532 bool
533 GetSummaryAsCString(TypeSummaryImpl *summary_ptr, std::string &destination,
535
536 bool GetSummaryAsCString(std::string &destination,
537 const TypeSummaryOptions &options);
538
539 bool GetSummaryAsCString(TypeSummaryImpl *summary_ptr,
540 std::string &destination,
541 const TypeSummaryOptions &options);
542
543 llvm::Expected<std::string> GetObjectDescription();
544
546 ValueObjectRepresentationStyle val_obj_display,
547 lldb::Format custom_format);
548
550 eDisable = false,
551 eAllow = true
552 };
553
554 bool
556 ValueObjectRepresentationStyle val_obj_display =
558 lldb::Format custom_format = lldb::eFormatInvalid,
561 bool do_dump_error = true);
562 bool GetValueIsValid() const { return m_flags.m_value_is_valid; }
563
564 // If you call this on a newly created ValueObject, it will always return
565 // false.
566 bool GetValueDidChange() { return m_flags.m_value_did_change; }
567
568 bool UpdateValueIfNeeded(bool update_format = true);
569
571
572 lldb::ValueObjectSP GetSP() { return m_manager->GetSharedPointer(this); }
573
574 /// Change the name of the current ValueObject. Should *not* be used from a
575 /// synthetic child provider as it would change the name of the non synthetic
576 /// child as well.
577 void SetName(llvm::StringRef name) { m_name = ConstString(name); }
578
583
584 virtual AddrAndType GetAddressOf(bool scalar_is_load_address = true);
585
586 /// Remove ptrauth bits from address if the type has a ptrauth qualifier.
587 std::optional<lldb::addr_t> GetStrippedPointerValue(lldb::addr_t address);
588
590
592
593 lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create);
594
595 lldb::ValueObjectSP GetSyntheticBitFieldChild(uint32_t from, uint32_t to,
596 bool can_create);
597
599 bool can_create);
600
601 virtual lldb::ValueObjectSP
602 GetSyntheticChildAtOffset(uint32_t offset, const CompilerType &type,
603 bool can_create,
604 ConstString name_const_str = ConstString());
605
606 virtual lldb::ValueObjectSP
607 GetSyntheticBase(uint32_t offset, const CompilerType &type, bool can_create,
608 ConstString name_const_str = ConstString());
609
611
613
615
617
619
620 virtual bool HasSyntheticValue();
621
622 virtual bool IsSynthetic() { return false; }
623
626 bool synthValue);
627
629
631
632 /// Creates a copy of the ValueObject with a new name and setting the current
633 /// ValueObject as its parent. It should be used when we want to change the
634 /// name of a ValueObject without modifying the actual ValueObject itself
635 /// (e.g. sythetic child provider).
636 virtual lldb::ValueObjectSP Clone(llvm::StringRef new_name);
637
639
641
644
645 lldb::ValueObjectSP Cast(const CompilerType &compiler_type);
646
647 virtual lldb::ValueObjectSP DoCast(const CompilerType &compiler_type);
648
649 virtual lldb::ValueObjectSP CastPointerType(const char *name,
650 CompilerType &ast_type);
651
652 virtual lldb::ValueObjectSP CastPointerType(const char *name,
653 lldb::TypeSP &type_sp);
654
655 /// Return the target load address associated with this value object.
657
658 /// Take a ValueObject whose type is an inherited class, and cast it to
659 /// 'type', which should be one of its base classes. 'base_type_indices'
660 /// contains the indices of direct base classes on the path from the
661 /// ValueObject's current type to 'type'
662 llvm::Expected<lldb::ValueObjectSP>
664 const llvm::ArrayRef<uint32_t> &base_type_indices);
665
666 /// Take a ValueObject whose type is a base class, and cast it to 'type',
667 /// which should be one of its derived classes. 'base_type_indices'
668 /// contains the indices of direct base classes on the path from the
669 /// ValueObject's current type to 'type'
670 llvm::Expected<lldb::ValueObjectSP> CastBaseToDerivedType(CompilerType type,
671 uint64_t offset);
672
673 // Take a ValueObject that contains a scalar, enum or pointer type, and
674 // cast it to a "basic" type (integer, float or boolean).
676
677 // Take a ValueObject that contain an integer, float or enum, and cast it
678 // to an enum.
680
681 /// If this object represents a C++ class with a vtable, return an object
682 /// that represents the virtual function table. If the object isn't a class
683 /// with a vtable, return a valid ValueObject with the error set correctly.
685 // The backing bits of this value object were updated, clear any descriptive
686 // string, so we know we have to refetch them.
692
693 virtual bool IsDynamic() { return false; }
694
695 virtual bool DoesProvideSyntheticValue() { return false; }
696
698 return m_flags.m_is_synthetic_children_generated;
699 }
700
701 virtual void SetSyntheticChildrenGenerated(bool b) {
702 m_flags.m_is_synthetic_children_generated = b;
703 }
704
706
707 llvm::Error Dump(Stream &s);
708
709 llvm::Error Dump(Stream &s, const DumpValueObjectOptions &options);
710
711 /// The following static routines create "Root" ValueObjects if parent is
712 /// null. If it is a valid ValueObject, the new ValueObject is managed by the
713 /// ValueObjectManager of the parent object.
714 /// The only code that should explicitly pass in a parent is that
715 /// implementing the CreateChildValueObjectFrom and the ValueObjectSynthetic.
716 /// If you are creating a ValueObject in a Synthetic Child Provider, you
717 /// should instead use the method CreateChildValueObjectFrom***.
718 /// That is more straightforward and will ensure the right parent is used.
719
721 llvm::StringRef name, llvm::StringRef expression,
722 const ExecutionContext &exe_ctx, ValueObject *parent = nullptr);
723
725 llvm::StringRef name, llvm::StringRef expression,
726 const ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,
727 ValueObject *parent = nullptr);
728
729 /// Given an address either create a value object containing the value at
730 /// that address, or create a value object containing the address itself
731 /// (pointer value), depending on whether the parameter 'do_deref' is true or
732 /// false.
734 llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx,
735 CompilerType type, bool do_deref = true, ValueObject *parent = nullptr);
736
738 CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data,
739 const ExecutionContext &exe_ctx, CompilerType type,
740 ValueObject *parent = nullptr);
741
742 /// Create a value object containing the given APInt value.
744 const ExecutionContext &exe_ctx, const llvm::APInt &v, CompilerType type,
745 llvm::StringRef name, ValueObject *parent = nullptr);
746
747 /// Create a value object containing the given APFloat value.
749 const ExecutionContext &exe_ctx, const llvm::APFloat &v,
750 CompilerType type, llvm::StringRef name, ValueObject *parent = nullptr);
751
752 /// Create a value object containing the given Scalar value.
755 CompilerType type, llvm::StringRef name,
756 ValueObject *parent = nullptr);
757
758 /// Create a value object containing the given boolean value.
760 const ExecutionContext &exe_ctx, lldb::TypeSystemSP typesystem,
761 bool value, llvm::StringRef name, ValueObject *parent = nullptr);
762
763 /// Create a nullptr value object with the specified type (must be a
764 /// nullptr type).
767 CompilerType type, llvm::StringRef name,
768 ValueObject *parent = nullptr);
769
770 /// These are the appropriate routines to make a ValueObject that get managed
771 /// by this ValueObject (and all the other members of its Cluster).
773 llvm::StringRef name, llvm::StringRef expression,
774 const ExecutionContext &exe_ctx,
775 const EvaluateExpressionOptions &options) {
776 return CreateValueObjectFromExpression(name, expression, exe_ctx, options,
777 /*parent=*/this);
778 }
779
780 /// Given an address either create a value object containing the value at
781 /// that address, or create a value object containing the address itself
782 /// (pointer value), depending on whether the parameter 'do_deref' is true or
783 /// false.
785 CreateChildValueObjectFromAddress(llvm::StringRef name, uint64_t address,
786 const ExecutionContext &exe_ctx,
787 CompilerType type, bool do_deref = true) {
788 return CreateValueObjectFromAddress(name, address, exe_ctx, type, do_deref,
789 /*parent=*/this);
790 }
791
793 llvm::StringRef name, const DataExtractor &data,
794 const ExecutionContext &exe_ctx, CompilerType type) {
795 return CreateValueObjectFromData(name, data, exe_ctx, type,
796 /*parent=*/this);
797 }
798
799 /// Create a value object containing the given APInt value.
802 const llvm::APInt &v, CompilerType type,
803 llvm::StringRef name) {
804 return CreateValueObjectFromAPInt(exe_ctx, v, type, name, /*parent=*/this);
805 }
806
807 /// Create a value object containing the given APFloat value.
810 const llvm::APFloat &v, CompilerType type,
811 llvm::StringRef name) {
812 return CreateValueObjectFromAPFloat(exe_ctx, v, type, name,
813 /*parent=*/this);
814 }
815
816 /// Create a value object containing the given Scalar value.
819 CompilerType type, llvm::StringRef name) {
820 return CreateValueObjectFromScalar(exe_ctx, s, type, name, /*parent=*/this);
821 }
822
823 /// Create a value object containing the given boolean value.
826 lldb::TypeSystemSP typesystem, bool value,
827 llvm::StringRef name) {
828 return CreateValueObjectFromBool(exe_ctx, typesystem, value, name,
829 /*parent=*/this);
830 }
831
832 /// Create a nullptr value object with the specified type (must be a
833 /// nullptr type).
836 CompilerType type, llvm::StringRef name) {
837 return CreateValueObjectFromNullptr(exe_ctx, type, name, /*parent=*/this);
838 }
839
841
842 /// Returns true if this is a char* or a char[] if it is a char* and
843 /// check_pointer is true, it also checks that the pointer is valid.
844 bool IsCStringContainer(bool check_pointer = false);
845
846 std::pair<size_t, bool>
848 bool honor_array);
849
850 virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
851 uint32_t item_count = 1);
852
853 virtual uint64_t GetData(DataExtractor &data, Status &error);
854
855 virtual bool SetData(DataExtractor &data, Status &error);
856
857 virtual bool GetIsConstant() const { return m_update_point.IsConstant(); }
858
859 /// Check if the value may be writable. Returns an error describing
860 /// why this value cannot be modified. Success does not guarantee a
861 /// write will succeed; other runtime conditions can still cause
862 /// SetValue* to fail.
863 virtual llvm::Error CanSetValue() {
864 if (GetIsConstant())
865 return llvm::createStringError("value is not in a writable location");
866 return llvm::Error::success();
867 }
868
870 const bool accept_invalid_exe_ctx =
872 return m_update_point.NeedsUpdating(accept_invalid_exe_ctx);
873 }
874
875 void SetIsConstant() { m_update_point.SetIsConstant(); }
876
877 lldb::Format GetFormat() const;
878
879 virtual void SetFormat(lldb::Format format) {
880 if (format != m_format)
882 m_format = format;
883 }
884
886
890
895
900
901 void SetDerefValobj(ValueObject *deref) { m_deref_valobj = deref; }
902
904
909
914
921
928
935
937 return nullptr;
938 }
939
940 // Use GetParent for display purposes, but if you want to tell the parent to
941 // update itself then use m_parent. The ValueObjectDynamicValue's parent is
942 // not the correct parent for displaying, they are really siblings, so for
943 // display it needs to route through to its grandparent.
947
948 virtual const ValueObject *GetParent() const {
950 }
951
953
955
959
961
963 m_flags.m_did_calculate_complete_objc_class_type = true;
964 }
965
966 /// Find out if a ValueObject might have children.
967 ///
968 /// This call is much more efficient than CalculateNumChildren() as
969 /// it doesn't need to complete the underlying type. This is designed
970 /// to be used in a UI environment in order to detect if the
971 /// disclosure triangle should be displayed or not.
972 ///
973 /// This function returns true for class, union, structure,
974 /// pointers, references, arrays and more. Again, it does so without
975 /// doing any expensive type completion.
976 ///
977 /// \return
978 /// Returns \b true if the ValueObject might have children, or \b
979 /// false otherwise.
980 virtual bool MightHaveChildren();
981
982 virtual lldb::VariableSP GetVariable() { return nullptr; }
983
984 virtual bool IsRuntimeSupportValue();
985
986 virtual uint64_t GetLanguageFlags() { return m_language_flags; }
987
988 virtual void SetLanguageFlags(uint64_t flags) { m_language_flags = flags; }
989
990 /// Returns the local buffer that this ValueObject points to if it's
991 /// available.
992 /// \return
993 /// The local buffer if this value object's value points to a
994 /// host address, and if that buffer can be determined. Otherwise, returns
995 /// an empty ArrayRef.
996 ///
997 /// TODO: Because a ValueObject's Value can point to any arbitrary memory
998 /// location, it is possible that we can't find what what buffer we're
999 /// pointing to, and thus also can't know its size. See the comment in
1000 /// Value::m_value for a more thorough explanation of why that is.
1001 llvm::ArrayRef<uint8_t> GetLocalBuffer() const;
1002
1004
1005 virtual void *GetImplementation() { return nullptr; }
1006
1007protected:
1009
1011 public:
1012 ChildrenManager() = default;
1013
1014 bool HasChildAtIndex(size_t idx) {
1015 std::lock_guard<std::recursive_mutex> guard(m_mutex);
1016 return (m_children.find(idx) != m_children.end());
1017 }
1018
1020 std::lock_guard<std::recursive_mutex> guard(m_mutex);
1021 const auto iter = m_children.find(idx);
1022 return ((iter == m_children.end()) ? nullptr : iter->second);
1023 }
1024
1025 void SetChildAtIndex(size_t idx, ValueObject *valobj) {
1026 // we do not need to be mutex-protected to make a pair
1027 ChildrenPair pair(idx, valobj);
1028 std::lock_guard<std::recursive_mutex> guard(m_mutex);
1029 m_children.insert(pair);
1030 }
1031
1032 void SetChildrenCount(size_t count) { Clear(count); }
1033
1035
1036 void Clear(size_t new_count = 0) {
1037 std::lock_guard<std::recursive_mutex> guard(m_mutex);
1038 m_children_count = new_count;
1039 m_children.clear();
1040 }
1041
1042 private:
1043 typedef std::map<size_t, ValueObject *> ChildrenMap;
1044 typedef ChildrenMap::iterator ChildrenIterator;
1045 typedef ChildrenMap::value_type ChildrenPair;
1046 std::recursive_mutex m_mutex;
1049 };
1050
1051 using ValueObjectManagerSP = std::shared_ptr<ValueObjectManager>;
1052
1053 /// The following two functions are helpers for Create methods
1054 /// for ValueObject subclasses that need to optionally receive
1055 /// a parent or external manager.
1056 /// This returns a ValueObjectManagerSP that is either the SP of the
1057 /// parent - if it is non-null, or a new manager if null.
1059 ValueObjectManagerSP manager_sp;
1060 if (parent)
1061 manager_sp = parent->GetManager()->shared_from_this();
1062 else
1063 manager_sp = ValueObjectManager::Create();
1064 return manager_sp;
1065 }
1066
1067 /// If manager is null, makes a new ValueObjectManager and sets
1068 /// manager to the new ValueObjectManager. It also returns the
1069 /// shared pointer which is necessary to keep the new manager alive.
1072 ValueObjectManagerSP manager_sp;
1073 if (!manager) {
1074 manager_sp = ValueObjectManager::Create();
1075 manager = manager_sp.get();
1076 }
1077 return manager_sp;
1078 }
1079
1080 // Classes that inherit from ValueObject can see and modify these
1081
1082 /// The parent value object, or nullptr if this has no parent.
1084 /// The parent to report from GetParent() when m_parent does not reflect the
1085 /// "display" (i.e logical) parent. Used for synthetic children whose logical
1086 /// parent is the synthetic ValueObject. See also GetParent().
1088 /// The root of the hierarchy for this ValueObject (or nullptr if never
1089 /// calculated).
1091 /// Stores both the stop id and the full context at which this value was last
1092 /// updated. When we are asked to update the value object, we check whether
1093 /// the context & stop id are the same before updating.
1095 /// The name of this object.
1097 /// A data extractor that can be used to extract the value.
1100 /// An error object that can describe any errors that occur when updating
1101 /// values.
1103 /// Cached value string that will get cleared if/when the value is updated.
1104 std::string m_value_str;
1105 /// Cached old value string from the last time the value was gotten
1106 std::string m_old_value_str;
1107 /// Cached location string that will get cleared if/when the value is updated.
1108 std::string m_location_str;
1109 /// Cached summary string that will get cleared if/when the value is updated.
1110 std::string m_summary_str;
1111 /// Cached result of the "object printer". This differs from the summary
1112 /// in that the summary is consed up by us, the object_desc_string is builtin.
1114 /// If the type of the value object should be overridden, the type to impose.
1116
1117 /// This object is managed by the root object (any ValueObject that gets
1118 /// created without a parent.) The manager gets passed through all the
1119 /// generations of dependent objects, and will keep the whole cluster of
1120 /// objects alive as long as a shared pointer to any of them has been handed
1121 /// out. Shared pointers to value objects must always be made with the GetSP
1122 /// method.
1124
1126 std::map<ConstString, ValueObject *> m_synthetic_children;
1127
1131
1132 /// We have to hold onto a shared pointer to this one because it is created
1133 /// as an independent ValueObjectConstResult, which isn't managed by us.
1135
1141
1142 /// As determined by `DataVisualization` - may be overridden
1144
1145 /// Sticky override of `m_synthetic_children_sp`
1147
1150
1151 llvm::SmallVector<uint8_t, 16> m_value_checksum;
1152
1154
1155 uint64_t m_language_flags = 0;
1156
1157 /// Unique identifier for every value object.
1159
1160 // Utility class for initializing all bitfields in ValueObject's constructors.
1161 // FIXME: This could be done via default initializers once we have C++20.
1183
1184 friend class ValueObjectChild;
1185 friend class ExpressionVariable; // For SetName
1186 friend class Target; // For SetName
1188 friend class ValueObjectSynthetic; // For ClearUserVisibleData
1189
1190 /// Use this constructor to create a "root variable object". The ValueObject
1191 /// will be locked to this context through-out its lifespan.
1193 AddressType child_ptr_or_ref_addr_type = eAddressTypeLoad);
1194
1195 /// Use this constructor to create a ValueObject owned by another ValueObject.
1196 /// It will inherit the ExecutionContext of its parent.
1197 ValueObject(ValueObject &parent);
1198
1200
1201 virtual bool UpdateValue() = 0;
1202
1206
1207 virtual void CalculateDynamicValue(lldb::DynamicValueType use_dynamic);
1208
1212
1213 virtual bool HasDynamicValueTypeInfo() { return false; }
1214
1215 virtual void CalculateSyntheticValue();
1216
1217 /// Should only be called by ValueObject::GetChildAtIndex().
1218 ///
1219 /// \return A ValueObject managed by this ValueObject's manager.
1220 virtual ValueObject *CreateChildAtIndex(size_t idx);
1221
1222 /// Should only be called by ValueObject::GetSyntheticArrayMember().
1223 ///
1224 /// \return A ValueObject managed by this ValueObject's manager.
1225 virtual ValueObject *CreateSyntheticArrayMember(size_t idx);
1226
1227 /// Should only be called by ValueObject::GetNumChildren().
1228 virtual llvm::Expected<uint32_t>
1230
1231 void SetNumChildren(uint32_t num_children);
1232
1233 void SetValueDidChange(bool value_changed) {
1234 m_flags.m_value_did_change = value_changed;
1235 }
1236
1237 void SetValueIsValid(bool valid) { m_flags.m_value_is_valid = valid; }
1238
1241
1242 void AddSyntheticChild(ConstString key, ValueObject *valobj);
1243
1245
1247
1248 // Subclasses must implement the functions below.
1249
1251
1252 const char *GetLocationAsCStringImpl(const Value &value,
1253 const DataExtractor &data);
1254
1255 bool IsChecksumEmpty() { return m_value_checksum.empty(); }
1256
1258
1259protected:
1261
1262private:
1266
1268 llvm::StringRef expression_cstr,
1269 ExpressionPathScanEndReason *reason_to_stop,
1270 ExpressionPathEndResultType *final_value_type,
1271 const GetValueForExpressionPathOptions &options,
1272 ExpressionPathAftermath *final_task_on_target);
1273
1274 ValueObject(const ValueObject &) = delete;
1275 const ValueObject &operator=(const ValueObject &) = delete;
1276};
1277
1278// The two classes below are used by the public SBValue API implementation. This
1279// is useful here because we need them in order to access the underlying
1280// ValueObject from SBValue without introducing a back-dependency from the API
1281// library to the more core libs.
1282
1284public:
1285 ValueImpl() = default;
1286
1287 ValueImpl(lldb::ValueObjectSP in_valobj_sp,
1288 lldb::DynamicValueType use_dynamic, bool use_synthetic,
1289 const char *name = nullptr);
1290
1291 ValueImpl(const ValueImpl &rhs) = default;
1292
1293 ValueImpl &operator=(const ValueImpl &rhs);
1294
1295 bool IsValid();
1296
1298
1300 TargetAPIMutex &api_mutex,
1301 std::unique_lock<TargetAPIMutex> &lock,
1302 Status &error);
1303
1305 m_use_dynamic = use_dynamic;
1306 }
1307
1308 void SetUseSynthetic(bool use_synthetic) { m_use_synthetic = use_synthetic; }
1309
1311
1313
1314 // All the derived values that we would make from the m_valobj_sp will share
1315 // the ExecutionContext with m_valobj_sp, so we don't need to do the
1316 // calculations in GetSP to return the Target, Process, Thread or Frame. It
1317 // is convenient to provide simple accessors for these, which I do here.
1319 return m_valobj_sp ? m_valobj_sp->GetTargetSP() : lldb::TargetSP{};
1320 }
1321
1323 return m_valobj_sp ? m_valobj_sp->GetProcessSP() : lldb::ProcessSP{};
1324 }
1325
1327 return m_valobj_sp ? m_valobj_sp->GetThreadSP() : lldb::ThreadSP{};
1328 }
1329
1331 return m_valobj_sp ? m_valobj_sp->GetFrameSP() : lldb::StackFrameSP{};
1332 }
1333
1334private:
1339};
1340
1342public:
1343 ValueLocker() = default;
1344
1348
1350
1351private:
1354 std::unique_lock<TargetAPIMutex> m_lock;
1356};
1357
1358} // namespace lldb_private
1359
1360#endif // LLDB_VALUEOBJECT_VALUEOBJECT_H
static llvm::raw_ostream & error(Stream &strm)
static std::shared_ptr< ClusterManager > Create()
Generic representation of a type in a programming language.
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.
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/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ProcessRunLock::ProcessRunLocker StopLocker
Definition Process.h:407
An error handling class.
Definition Status.h:118
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 Lockable handle over a Target's API mutex, returned by Target::GetAPIMutex() and backing the public...
lldb::ValueObjectSP GetSP(Process::StopLocker &stop_locker, TargetAPIMutex &api_mutex, std::unique_lock< TargetAPIMutex > &lock, Status &error)
lldb::ProcessSP GetProcessSP()
lldb::ValueObjectSP m_valobj_sp
lldb::DynamicValueType m_use_dynamic
lldb::DynamicValueType GetUseDynamic()
lldb::StackFrameSP GetFrameSP()
lldb::ThreadSP GetThreadSP()
ValueImpl & operator=(const ValueImpl &rhs)
void SetUseSynthetic(bool use_synthetic)
ValueImpl(const ValueImpl &rhs)=default
void SetUseDynamic(lldb::DynamicValueType use_dynamic)
lldb::TargetSP GetTargetSP()
lldb::ValueObjectSP GetRootSP()
Process::StopLocker m_stop_locker
std::unique_lock< TargetAPIMutex > m_lock
lldb::ValueObjectSP GetLockedSP(ValueImpl &in_value)
ValueObject * GetChildAtIndex(uint32_t idx)
void SetChildAtIndex(size_t idx, ValueObject *valobj)
std::map< size_t, ValueObject * > ChildrenMap
bool SyncWithProcessState(bool accept_invalid_exe_ctx)
void SetUpdateID(ProcessModID new_id)
const ExecutionContextRef & GetExecutionContextRef() const
bool NeedsUpdating(bool accept_invalid_exe_ctx)
AddressType m_address_type_of_ptr_or_ref_children
void SetValueIsValid(bool valid)
lldb::TypeFormatImplSP GetValueFormat()
EvaluationPoint m_update_point
Stores both the stop id and the full context at which this value was last updated.
lldb::TypeSummaryImplSP GetSummaryFormat()
lldb::ValueObjectSP CheckValueObjectOwnership(ValueObject *child)
llvm::SmallVector< uint8_t, 16 > m_value_checksum
static lldb::ValueObjectSP CreateValueObjectFromNullptr(const ExecutionContext &exe_ctx, CompilerType type, llvm::StringRef name, ValueObject *parent=nullptr)
Create a nullptr value object with the specified type (must be a nullptr type).
llvm::Expected< llvm::APFloat > GetValueAsAPFloat()
If the current ValueObject is of an appropriate type, convert the value to an APFloat and return that...
virtual uint32_t GetBitfieldBitSize()
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.
lldb::ValueObjectSP Cast(const CompilerType &compiler_type)
const EvaluationPoint & GetUpdatePoint() const
void AddSyntheticChild(ConstString key, ValueObject *valobj)
virtual uint64_t GetData(DataExtractor &data, Status &error)
EvaluationPoint & GetUpdatePoint()
friend class ValueObjectSynthetic
bool DumpPrintableRepresentation(Stream &s, ValueObjectRepresentationStyle val_obj_display=eValueObjectRepresentationStyleSummary, lldb::Format custom_format=lldb::eFormatInvalid, PrintableRepresentationSpecialCases special=PrintableRepresentationSpecialCases::eAllow, bool do_dump_error=true)
virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx, bool can_create=true)
lldb::ValueObjectSP CreateChildValueObjectFromAPFloat(const ExecutionContext &exe_ctx, const llvm::APFloat &v, CompilerType type, llvm::StringRef name)
Create a value object containing the given APFloat value.
virtual lldb::DynamicValueType GetDynamicValueTypeImpl()
const ValueObject & operator=(const ValueObject &)=delete
virtual bool GetIsConstant() const
virtual bool MightHaveChildren()
Find out if a ValueObject might have children.
virtual bool IsDereferenceOfParent()
void SetLogicalParent(ValueObject *parent)
lldb::SyntheticChildrenSP m_synthetic_children_override_sp
Sticky override of m_synthetic_children_sp
virtual llvm::Expected< size_t > GetIndexOfChildWithName(llvm::StringRef name)
Return the index of the child named name.
static lldb::ValueObjectSP CreateValueObjectFromScalar(const ExecutionContext &exe_ctx, Scalar &s, CompilerType type, llvm::StringRef name, ValueObject *parent=nullptr)
Create a value object containing the given Scalar value.
virtual ValueObject * CreateSyntheticArrayMember(size_t idx)
Should only be called by ValueObject::GetSyntheticArrayMember().
virtual const ValueObject * GetParent() const
void SetValueFormat(lldb::TypeFormatImplSP format)
virtual lldb::addr_t GetLiveAddress()
virtual void CalculateSyntheticValue()
void SetPreferredDisplayLanguage(lldb::LanguageType lt)
struct lldb_private::ValueObject::Bitflags m_flags
ClusterManager< ValueObject > ValueObjectManager
ValueObject(ExecutionContextScope *exe_scope, ValueObjectManager &manager, AddressType child_ptr_or_ref_addr_type=eAddressTypeLoad)
Use this constructor to create a "root variable object".
std::string m_summary_str
Cached summary string that will get cleared if/when the value is updated.
virtual lldb::ValueObjectSP DoCast(const CompilerType &compiler_type)
lldb::TypeSummaryImplSP m_type_summary_sp
lldb::ValueObjectSP GetSP()
virtual llvm::Error CanSetValue()
Check if the value may be writable.
ValueObject * m_logical_parent
The parent to report from GetParent() when m_parent does not reflect the "display" (i....
ChildrenManager m_children
void SetSyntheticChildrenOverride(const lldb::SyntheticChildrenSP &synth_sp)
virtual void SetLanguageFlags(uint64_t flags)
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.
virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx=0, uint32_t item_count=1)
lldb::ValueObjectSP GetSyntheticValue()
lldb::ValueObjectSP CreateChildValueObjectFromNullptr(const ExecutionContext &exe_ctx, CompilerType type, llvm::StringRef name)
Create a nullptr value object with the specified type (must be a nullptr type).
ValueObjectManager * m_manager
This object is managed by the root object (any ValueObject that gets created without a parent....
lldb::ValueObjectSP GetSyntheticBitFieldChild(uint32_t from, uint32_t to, bool can_create)
lldb::ProcessSP GetProcessSP() const
lldb::ValueObjectSP GetSyntheticChild(ConstString key) const
@ eExpressionPathScanEndReasonArrowInsteadOfDot
-> used when . should be used.
@ eExpressionPathScanEndReasonDereferencingFailed
Impossible to apply * operator.
@ eExpressionPathScanEndReasonNoSuchSyntheticChild
(Synthetic) child element not found.
@ eExpressionPathScanEndReasonNoSuchChild
Child element not found.
@ eExpressionPathScanEndReasonDotInsteadOfArrow
. used when -> should be used.
@ eExpressionPathScanEndReasonEndOfString
Out of data to parse.
@ eExpressionPathScanEndReasonBitfieldRangeOperatorMet
[] is good for bitfields, but I cannot parse after it.
@ eExpressionPathScanEndReasonRangeOperatorNotAllowed
[] not allowed by options.
@ eExpressionPathScanEndReasonEmptyRangeNotAllowed
[] only allowed for arrays.
@ eExpressionPathScanEndReasonRangeOperatorExpanded
[] was expanded into a VOList.
@ eExpressionPathScanEndReasonRangeOperatorInvalid
[] not valid on objects other than scalars, pointers or arrays.
@ eExpressionPathScanEndReasonUnexpectedSymbol
Something is malformed in he expression.
@ eExpressionPathScanEndReasonArrayRangeOperatorMet
[] is good for arrays, but I cannot parse it.
@ eExpressionPathScanEndReasonSyntheticValueMissing
getting the synthetic children failed.
@ eExpressionPathScanEndReasonTakingAddressFailed
Impossible to apply & operator.
@ eExpressionPathScanEndReasonFragileIVarNotAllowed
ObjC ivar expansion not allowed.
virtual bool UpdateValue()=0
lldb::Format GetFormat() const
virtual uint64_t GetLanguageFlags()
virtual lldb::VariableSP GetVariable()
friend class ExpressionVariable
@ eExpressionPathAftermathNothing
Just return it.
@ eExpressionPathAftermathDereference
Dereference the target.
@ eExpressionPathAftermathTakeAddress
Take target's address.
lldb::ValueObjectSP CastToBasicType(CompilerType type)
virtual void SetSyntheticChildrenGenerated(bool b)
lldb::user_id_t GetID() const
Returns a unique id for this ValueObject.
virtual void DoUpdateChildrenAddressType(ValueObject &valobj)
ValueObject * GetNonBaseClassParent()
virtual void * GetImplementation()
virtual ValueObject * CreateChildAtIndex(size_t idx)
Should only be called by ValueObject::GetChildAtIndex().
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)
lldb::ValueObjectSP CreateChildValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type, bool do_deref=true)
Given an address either create a value object containing the value at that address,...
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.
virtual llvm::Expected< uint64_t > GetByteSize()=0
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 lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create=true)
lldb::ValueObjectSP CastToEnumType(CompilerType type)
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
lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef< llvm::StringRef > names)
void SetSummaryFormat(lldb::TypeSummaryImplSP format)
virtual bool IsRuntimeSupportValue()
virtual ConstString GetTypeName()
DataExtractor & GetDataExtractor()
virtual LazyBool CanUpdateWithInvalidExecutionContext()
void SetValueDidChange(bool value_changed)
lldb::ThreadSP GetThreadSP() const
static lldb::ValueObjectSP CreateValueObjectFromBool(const ExecutionContext &exe_ctx, lldb::TypeSystemSP typesystem, bool value, llvm::StringRef name, ValueObject *parent=nullptr)
Create a value object containing the given boolean value.
ValueObjectManager * GetManager()
ValueObject * m_root
The root of the hierarchy for this ValueObject (or nullptr if never calculated).
lldb::addr_t GetLoadAddress()
Return the target load address associated with this value object.
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)
ValueObject * GetDerefValobj()
virtual ConstString GetDisplayTypeName()
llvm::Expected< lldb::ValueObjectSP > CastDerivedToBaseType(CompilerType type, const llvm::ArrayRef< uint32_t > &base_type_indices)
Take a ValueObject whose type is an inherited class, and cast it to 'type', which should be one of it...
virtual lldb::ValueObjectSP AddressOf(Status &error)
lldb::DynamicValueType GetDynamicValueType()
llvm::Expected< lldb::ValueObjectSP > CastBaseToDerivedType(CompilerType type, uint64_t offset)
Take a ValueObject whose type is a base class, and cast it to 'type', which should be one of its deri...
lldb::SyntheticChildrenSP GetSyntheticChildren()
lldb::LanguageType m_preferred_display_language
void SetDerefValobj(ValueObject *deref)
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr)
virtual llvm::Expected< uint32_t > CalculateNumChildren(uint32_t max=UINT32_MAX)=0
Should only be called by ValueObject::GetNumChildren().
lldb::LanguageType GetObjectRuntimeLanguage()
static ValueObjectManagerSP CreateManagerIfEmpty(ValueObjectManager *&manager)
If manager is null, makes a new ValueObjectManager and sets manager to the new ValueObjectManager.
virtual lldb::ValueObjectSP CreateConstantValue(ConstString name)
virtual bool IsLogicalTrue(Status &error)
virtual SymbolContextScope * GetSymbolContextScope()
virtual bool HasDynamicValueTypeInfo()
ValueObject * m_synthetic_value
virtual lldb::ValueObjectSP Clone(llvm::StringRef new_name)
Creates a copy of the ValueObject with a new name and setting the current ValueObject as its parent.
void SetNumChildren(uint32_t num_children)
ValueObject * m_parent
The parent value object, or nullptr if this has no parent.
static lldb::ValueObjectSP CreateValueObjectFromAPInt(const ExecutionContext &exe_ctx, const llvm::APInt &v, CompilerType type, llvm::StringRef name, ValueObject *parent=nullptr)
Create a value object containing the given APInt value.
virtual bool IsBaseClass()
llvm::Expected< bool > GetValueAsBool()
If the current ValueObject is of an appropriate type, convert the value to a boolean and return that.
virtual bool GetDeclaration(Declaration &decl)
llvm::Error SetValueFromInteger(const llvm::APInt &value, bool can_update_var=true)
Update an existing integer ValueObject with a new integer value.
static lldb::ValueObjectSP CreateValueObjectFromExpression(llvm::StringRef name, llvm::StringRef expression, const ExecutionContext &exe_ctx, ValueObject *parent=nullptr)
The following static routines create "Root" ValueObjects if parent is null.
lldb::ValueObjectSP GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue, bool synthValue)
virtual bool IsSyntheticChildrenGenerated()
virtual SyntheticChildrenFrontEnd * GetSyntheticChildrenFrontEnd()
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...
std::pair< size_t, bool > ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, Status &error, bool honor_array)
lldb::ValueObjectSP CreateChildValueObjectFromBool(const ExecutionContext &exe_ctx, lldb::TypeSystemSP typesystem, bool value, llvm::StringRef name)
Create a value object containing the given boolean value.
void SetName(llvm::StringRef name)
Change the name of the current ValueObject.
ValueObject(const ValueObject &)=delete
llvm::Error Dump(Stream &s)
bool UpdateValueIfNeeded(bool update_format=true)
AddressType GetAddressTypeOfChildren()
const Status & GetError()
lldb::TypeFormatImplSP m_type_format_sp
lldb::TargetSP GetTargetSP() const
@ eExpressionPathEndResultTypePlain
Anything but...
@ eExpressionPathEndResultTypeBoundedRange
A range [low-high].
@ eExpressionPathEndResultTypeBitfield
A bitfield.
@ eExpressionPathEndResultTypeValueObjectList
Several items in a VOList.
@ eExpressionPathEndResultTypeUnboundedRange
A range [].
virtual lldb::ValueObjectSP Dereference(Status &error)
CompilerType GetCompilerType()
lldb::ValueObjectSP CreateChildValueObjectFromScalar(const ExecutionContext &exe_ctx, Scalar &s, CompilerType type, llvm::StringRef name)
Create a value object containing the given Scalar value.
void SetPreferredDisplayLanguageIfNeeded(lldb::LanguageType)
virtual const char * GetValueAsCString()
bool HasSpecialPrintableRepresentation(ValueObjectRepresentationStyle val_obj_display, lldb::Format custom_format)
virtual const char * GetLocationAsCString()
ConstString GetName() const
std::string m_location_str
Cached location string that will get cleared if/when the value is updated.
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()
lldb::ValueObjectSP Persist()
std::string m_object_desc_str
Cached result of the "object printer".
friend class ValueObjectConstResultImpl
virtual ValueObject * GetParent()
virtual ConstString GetQualifiedTypeName()
virtual bool DoesProvideSyntheticValue()
static lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type, ValueObject *parent=nullptr)
lldb::SyntheticChildrenSP m_synthetic_children_sp
As determined by DataVisualization - may be overridden.
static lldb::ValueObjectSP CreateValueObjectFromAPFloat(const ExecutionContext &exe_ctx, const llvm::APFloat &v, CompilerType type, llvm::StringRef name, ValueObject *parent=nullptr)
Create a value object containing the given APFloat value.
virtual uint32_t GetBitfieldBitOffset()
llvm::Expected< std::string > GetObjectDescription()
std::string m_old_value_str
Cached old value string from the last time the value was gotten.
virtual lldb::ValueObjectSP GetNonSyntheticValue()
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)
std::string m_value_str
Cached value string that will get cleared if/when the value is updated.
bool IsIntegerType(bool &is_signed)
lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create)
std::shared_ptr< ValueObjectManager > ValueObjectManagerSP
virtual bool ResolveValue(Scalar &scalar)
lldb::ValueObjectSP CreateChildValueObjectFromExpression(llvm::StringRef name, llvm::StringRef expression, const ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options)
These are the appropriate routines to make a ValueObject that get managed by this ValueObject (and al...
llvm::Expected< llvm::APSInt > GetValueAsAPSInt()
If the current ValueObject is of an appropriate type, convert the value to an APSInt and return that.
void SetSyntheticChildren(const lldb::SyntheticChildrenSP &synth_sp)
ConstString m_name
The name of this object.
const char * GetLocationAsCStringImpl(const Value &value, const DataExtractor &data)
static ValueObjectManagerSP ReuseManagerIfParent(ValueObject *parent)
The following two functions are helpers for Create methods for ValueObject subclasses that need to op...
virtual void SetFormat(lldb::Format format)
ValueObject * m_dynamic_value
ProcessModID m_user_id_of_forced_summary
virtual TypeImpl GetTypeImpl()
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()
std::map< ConstString, ValueObject * > m_synthetic_children
llvm::ArrayRef< uint8_t > GetLocalBuffer() const
Returns the local buffer that this ValueObject points to if it's available.
std::optional< lldb::addr_t > GetStrippedPointerValue(lldb::addr_t address)
Remove ptrauth bits from address if the type has a ptrauth qualifier.
const ExecutionContextRef & GetExecutionContextRef() const
virtual AddrAndType GetAddressOf(bool scalar_is_load_address=true)
uint32_t GetNumChildrenIgnoringErrors(uint32_t max=UINT32_MAX)
Like GetNumChildren but returns 0 on error.
UserID m_id
Unique identifier for every value object.
lldb::ValueObjectSP CreateChildValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type)
const Value & GetValue() const
lldb::ValueObjectSP CreateChildValueObjectFromAPInt(const ExecutionContext &exe_ctx, const llvm::APInt &v, CompilerType type, llvm::StringRef name)
Create a value object containing the given APInt value.
virtual lldb::LanguageType GetPreferredDisplayLanguage()
virtual void SetLiveAddress(lldb::addr_t addr=LLDB_INVALID_ADDRESS, AddressType address_type=eAddressTypeLoad)
void SetAddressTypeOfChildren(AddressType at)
virtual lldb::offset_t GetByteOffset()
lldb::ValueObjectSP GetValueForExpressionPath_Impl(llvm::StringRef expression_cstr, ExpressionPathScanEndReason *reason_to_stop, ExpressionPathEndResultType *final_value_type, const GetValueForExpressionPathOptions &options, ExpressionPathAftermath *final_task_on_target)
static lldb::ValueObjectSP CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type, bool do_deref=true, ValueObject *parent=nullptr)
Given an address either create a value object containing the value at that address,...
#define LLDB_INVALID_ADDRESS
#define UINT32_MAX
A class that represents a running process on the host machine.
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::TypeSummaryImpl > TypeSummaryImplSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::TypeFormatImpl > TypeFormatImplSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Format
Display format definitions.
uint64_t offset_t
Definition lldb-types.h:86
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Type > TypeSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Variable > VariableSP
std::shared_ptr< lldb_private::SyntheticChildren > SyntheticChildrenSP
uint64_t user_id_t
Definition lldb-types.h:83
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
A mix in class that contains a generic user ID.
Definition UserID.h:31
GetValueForExpressionPathOptions & DontAllowFragileIVar()
GetValueForExpressionPathOptions & SetSyntheticChildrenTraversal(SyntheticChildrenTraversal traverse)
GetValueForExpressionPathOptions & DoAllowFragileIVar()
GetValueForExpressionPathOptions(bool dot=false, bool no_ivar=false, bool bitfield=true, SyntheticChildrenTraversal synth_traverse=SyntheticChildrenTraversal::ToSynthetic)
static const GetValueForExpressionPathOptions DefaultOptions()
GetValueForExpressionPathOptions & DontCheckDotVsArrowSyntax()
GetValueForExpressionPathOptions & DontAllowBitfieldSyntax()
GetValueForExpressionPathOptions & DoCheckDotVsArrowSyntax()
GetValueForExpressionPathOptions & DoAllowBitfieldSyntax()