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 void SetValueFromInteger(const llvm::APInt &value, Status &error,
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.
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 virtual llvm::Expected<size_t> GetIndexOfChildWithName(llvm::StringRef name);
500
501 llvm::Expected<uint32_t> GetNumChildren(uint32_t max = UINT32_MAX);
502 /// Like \c GetNumChildren but returns 0 on error. You probably
503 /// shouldn't be using this function. It exists primarily to ease the
504 /// transition to more pervasive error handling while not all APIs
505 /// have been updated.
506 uint32_t GetNumChildrenIgnoringErrors(uint32_t max = UINT32_MAX);
508
509 const Value &GetValue() const { return m_value; }
510
511 Value &GetValue() { return m_value; }
512
513 virtual bool ResolveValue(Scalar &scalar);
514
515 // return 'false' whenever you set the error, otherwise callers may assume
516 // true means everything is OK - this will break breakpoint conditions among
517 // potentially a few others
518 virtual bool IsLogicalTrue(Status &error);
519
520 virtual const char *GetLocationAsCString() {
522 }
523
524 const char *
526
527 bool
528 GetSummaryAsCString(TypeSummaryImpl *summary_ptr, std::string &destination,
530
531 bool GetSummaryAsCString(std::string &destination,
532 const TypeSummaryOptions &options);
533
534 bool GetSummaryAsCString(TypeSummaryImpl *summary_ptr,
535 std::string &destination,
536 const TypeSummaryOptions &options);
537
538 llvm::Expected<std::string> GetObjectDescription();
539
541 ValueObjectRepresentationStyle val_obj_display,
542 lldb::Format custom_format);
543
545 eDisable = false,
546 eAllow = true
547 };
548
549 bool
551 ValueObjectRepresentationStyle val_obj_display =
553 lldb::Format custom_format = lldb::eFormatInvalid,
556 bool do_dump_error = true);
557 bool GetValueIsValid() const { return m_flags.m_value_is_valid; }
558
559 // If you call this on a newly created ValueObject, it will always return
560 // false.
561 bool GetValueDidChange() { return m_flags.m_value_did_change; }
562
563 bool UpdateValueIfNeeded(bool update_format = true);
564
566
567 lldb::ValueObjectSP GetSP() { return m_manager->GetSharedPointer(this); }
568
569 /// Change the name of the current ValueObject. Should *not* be used from a
570 /// synthetic child provider as it would change the name of the non synthetic
571 /// child as well.
572 void SetName(ConstString name) { m_name = name; }
573
578
579 virtual AddrAndType GetAddressOf(bool scalar_is_load_address = true);
580
581 /// Remove ptrauth bits from address if the type has a ptrauth qualifier.
582 std::optional<lldb::addr_t> GetStrippedPointerValue(lldb::addr_t address);
583
585
587
588 lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create);
589
590 lldb::ValueObjectSP GetSyntheticBitFieldChild(uint32_t from, uint32_t to,
591 bool can_create);
592
594 bool can_create);
595
596 virtual lldb::ValueObjectSP
597 GetSyntheticChildAtOffset(uint32_t offset, const CompilerType &type,
598 bool can_create,
599 ConstString name_const_str = ConstString());
600
601 virtual lldb::ValueObjectSP
602 GetSyntheticBase(uint32_t offset, const CompilerType &type, bool can_create,
603 ConstString name_const_str = ConstString());
604
606
608
610
612
614
615 virtual bool HasSyntheticValue();
616
617 virtual bool IsSynthetic() { return false; }
618
621 bool synthValue);
622
624
626
627 /// Creates a copy of the ValueObject with a new name and setting the current
628 /// ValueObject as its parent. It should be used when we want to change the
629 /// name of a ValueObject without modifying the actual ValueObject itself
630 /// (e.g. sythetic child provider).
631 virtual lldb::ValueObjectSP Clone(ConstString new_name);
632
634
636
639
640 lldb::ValueObjectSP Cast(const CompilerType &compiler_type);
641
642 virtual lldb::ValueObjectSP DoCast(const CompilerType &compiler_type);
643
644 virtual lldb::ValueObjectSP CastPointerType(const char *name,
645 CompilerType &ast_type);
646
647 virtual lldb::ValueObjectSP CastPointerType(const char *name,
648 lldb::TypeSP &type_sp);
649
650 /// Return the target load address associated with this value object.
652
653 /// Take a ValueObject whose type is an inherited class, and cast it to
654 /// 'type', which should be one of its base classes. 'base_type_indices'
655 /// contains the indices of direct base classes on the path from the
656 /// ValueObject's current type to 'type'
657 llvm::Expected<lldb::ValueObjectSP>
659 const llvm::ArrayRef<uint32_t> &base_type_indices);
660
661 /// Take a ValueObject whose type is a base class, and cast it to 'type',
662 /// which should be one of its derived classes. 'base_type_indices'
663 /// contains the indices of direct base classes on the path from the
664 /// ValueObject's current type to 'type'
665 llvm::Expected<lldb::ValueObjectSP> CastBaseToDerivedType(CompilerType type,
666 uint64_t offset);
667
668 // Take a ValueObject that contains a scalar, enum or pointer type, and
669 // cast it to a "basic" type (integer, float or boolean).
671
672 // Take a ValueObject that contain an integer, float or enum, and cast it
673 // to an enum.
675
676 /// If this object represents a C++ class with a vtable, return an object
677 /// that represents the virtual function table. If the object isn't a class
678 /// with a vtable, return a valid ValueObject with the error set correctly.
680 // The backing bits of this value object were updated, clear any descriptive
681 // string, so we know we have to refetch them.
687
688 virtual bool IsDynamic() { return false; }
689
690 virtual bool DoesProvideSyntheticValue() { return false; }
691
693 return m_flags.m_is_synthetic_children_generated;
694 }
695
696 virtual void SetSyntheticChildrenGenerated(bool b) {
697 m_flags.m_is_synthetic_children_generated = b;
698 }
699
701
702 llvm::Error Dump(Stream &s);
703
704 llvm::Error Dump(Stream &s, const DumpValueObjectOptions &options);
705
706 /// The following static routines create "Root" ValueObjects if parent is
707 /// null. If it is a valid ValueObject, the new ValueObject is managed by the
708 /// ValueObjectManager of the parent object.
709 /// The only code that should explicitly pass in a parent is that
710 /// implementing the CreateChildValueObjectFrom and the ValueObjectSynthetic.
711 /// If you are creating a ValueObject in a Synthetic Child Provider, you
712 /// should instead use the method CreateChildValueObjectFrom***.
713 /// That is more straightforward and will ensure the right parent is used.
714
716 llvm::StringRef name, llvm::StringRef expression,
717 const ExecutionContext &exe_ctx, ValueObject *parent = nullptr);
718
720 llvm::StringRef name, llvm::StringRef expression,
721 const ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,
722 ValueObject *parent = nullptr);
723
724 /// Given an address either create a value object containing the value at
725 /// that address, or create a value object containing the address itself
726 /// (pointer value), depending on whether the parameter 'do_deref' is true or
727 /// false.
729 llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx,
730 CompilerType type, bool do_deref = true, ValueObject *parent = nullptr);
731
733 CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data,
734 const ExecutionContext &exe_ctx, CompilerType type,
735 ValueObject *parent = nullptr);
736
737 /// Create a value object containing the given APInt value.
739 const ExecutionContext &exe_ctx, const llvm::APInt &v, CompilerType type,
740 llvm::StringRef name, ValueObject *parent = nullptr);
741
742 /// Create a value object containing the given APFloat value.
744 const ExecutionContext &exe_ctx, const llvm::APFloat &v,
745 CompilerType type, llvm::StringRef name, ValueObject *parent = nullptr);
746
747 /// Create a value object containing the given Scalar value.
750 CompilerType type, llvm::StringRef name,
751 ValueObject *parent = nullptr);
752
753 /// Create a value object containing the given boolean value.
755 const ExecutionContext &exe_ctx, lldb::TypeSystemSP typesystem,
756 bool value, llvm::StringRef name, ValueObject *parent = nullptr);
757
758 /// Create a nullptr value object with the specified type (must be a
759 /// nullptr type).
762 CompilerType type, llvm::StringRef name,
763 ValueObject *parent = nullptr);
764
765 /// These are the appropriate routines to make a ValueObject that get managed
766 /// by this ValueObject (and all the other members of its Cluster).
768 llvm::StringRef name, llvm::StringRef expression,
769 const ExecutionContext &exe_ctx,
770 const EvaluateExpressionOptions &options) {
771 return CreateValueObjectFromExpression(name, expression, exe_ctx, options,
772 /*parent=*/this);
773 }
774
775 /// Given an address either create a value object containing the value at
776 /// that address, or create a value object containing the address itself
777 /// (pointer value), depending on whether the parameter 'do_deref' is true or
778 /// false.
780 CreateChildValueObjectFromAddress(llvm::StringRef name, uint64_t address,
781 const ExecutionContext &exe_ctx,
782 CompilerType type, bool do_deref = true) {
783 return CreateValueObjectFromAddress(name, address, exe_ctx, type, do_deref,
784 /*parent=*/this);
785 }
786
788 llvm::StringRef name, const DataExtractor &data,
789 const ExecutionContext &exe_ctx, CompilerType type) {
790 return CreateValueObjectFromData(name, data, exe_ctx, type,
791 /*parent=*/this);
792 }
793
794 /// Create a value object containing the given APInt value.
797 const llvm::APInt &v, CompilerType type,
798 llvm::StringRef name) {
799 return CreateValueObjectFromAPInt(exe_ctx, v, type, name, /*parent=*/this);
800 }
801
802 /// Create a value object containing the given APFloat value.
805 const llvm::APFloat &v, CompilerType type,
806 llvm::StringRef name) {
807 return CreateValueObjectFromAPFloat(exe_ctx, v, type, name,
808 /*parent=*/this);
809 }
810
811 /// Create a value object containing the given Scalar value.
814 CompilerType type, llvm::StringRef name) {
815 return CreateValueObjectFromScalar(exe_ctx, s, type, name, /*parent=*/this);
816 }
817
818 /// Create a value object containing the given boolean value.
821 lldb::TypeSystemSP typesystem, bool value,
822 llvm::StringRef name) {
823 return CreateValueObjectFromBool(exe_ctx, typesystem, value, name,
824 /*parent=*/this);
825 }
826
827 /// Create a nullptr value object with the specified type (must be a
828 /// nullptr type).
831 CompilerType type, llvm::StringRef name) {
832 return CreateValueObjectFromNullptr(exe_ctx, type, name, /*parent=*/this);
833 }
834
836
837 /// Returns true if this is a char* or a char[] if it is a char* and
838 /// check_pointer is true, it also checks that the pointer is valid.
839 bool IsCStringContainer(bool check_pointer = false);
840
841 std::pair<size_t, bool>
843 bool honor_array);
844
845 virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
846 uint32_t item_count = 1);
847
848 virtual uint64_t GetData(DataExtractor &data, Status &error);
849
850 virtual bool SetData(DataExtractor &data, Status &error);
851
852 virtual bool GetIsConstant() const { return m_update_point.IsConstant(); }
853
855 const bool accept_invalid_exe_ctx =
857 return m_update_point.NeedsUpdating(accept_invalid_exe_ctx);
858 }
859
860 void SetIsConstant() { m_update_point.SetIsConstant(); }
861
862 lldb::Format GetFormat() const;
863
864 virtual void SetFormat(lldb::Format format) {
865 if (format != m_format)
867 m_format = format;
868 }
869
871
875
880
885
886 void SetDerefValobj(ValueObject *deref) { m_deref_valobj = deref; }
887
889
894
899
906
911
912 // Use GetParent for display purposes, but if you want to tell the parent to
913 // update itself then use m_parent. The ValueObjectDynamicValue's parent is
914 // not the correct parent for displaying, they are really siblings, so for
915 // display it needs to route through to its grandparent.
916 virtual ValueObject *GetParent() { return m_parent; }
917
918 virtual const ValueObject *GetParent() const { return m_parent; }
919
921
925
927
929 m_flags.m_did_calculate_complete_objc_class_type = true;
930 }
931
932 /// Find out if a ValueObject might have children.
933 ///
934 /// This call is much more efficient than CalculateNumChildren() as
935 /// it doesn't need to complete the underlying type. This is designed
936 /// to be used in a UI environment in order to detect if the
937 /// disclosure triangle should be displayed or not.
938 ///
939 /// This function returns true for class, union, structure,
940 /// pointers, references, arrays and more. Again, it does so without
941 /// doing any expensive type completion.
942 ///
943 /// \return
944 /// Returns \b true if the ValueObject might have children, or \b
945 /// false otherwise.
946 virtual bool MightHaveChildren();
947
948 virtual lldb::VariableSP GetVariable() { return nullptr; }
949
950 virtual bool IsRuntimeSupportValue();
951
952 virtual uint64_t GetLanguageFlags() { return m_language_flags; }
953
954 virtual void SetLanguageFlags(uint64_t flags) { m_language_flags = flags; }
955
956 /// Returns the local buffer that this ValueObject points to if it's
957 /// available.
958 /// \return
959 /// The local buffer if this value object's value points to a
960 /// host address, and if that buffer can be determined. Otherwise, returns
961 /// an empty ArrayRef.
962 ///
963 /// TODO: Because a ValueObject's Value can point to any arbitrary memory
964 /// location, it is possible that we can't find what what buffer we're
965 /// pointing to, and thus also can't know its size. See the comment in
966 /// Value::m_value for a more thorough explanation of why that is.
967 llvm::ArrayRef<uint8_t> GetLocalBuffer() const;
968
970
971protected:
973
975 public:
976 ChildrenManager() = default;
977
978 bool HasChildAtIndex(size_t idx) {
979 std::lock_guard<std::recursive_mutex> guard(m_mutex);
980 return (m_children.find(idx) != m_children.end());
981 }
982
984 std::lock_guard<std::recursive_mutex> guard(m_mutex);
985 const auto iter = m_children.find(idx);
986 return ((iter == m_children.end()) ? nullptr : iter->second);
987 }
988
989 void SetChildAtIndex(size_t idx, ValueObject *valobj) {
990 // we do not need to be mutex-protected to make a pair
991 ChildrenPair pair(idx, valobj);
992 std::lock_guard<std::recursive_mutex> guard(m_mutex);
993 m_children.insert(pair);
994 }
995
996 void SetChildrenCount(size_t count) { Clear(count); }
997
999
1000 void Clear(size_t new_count = 0) {
1001 std::lock_guard<std::recursive_mutex> guard(m_mutex);
1002 m_children_count = new_count;
1003 m_children.clear();
1004 }
1005
1006 private:
1007 typedef std::map<size_t, ValueObject *> ChildrenMap;
1008 typedef ChildrenMap::iterator ChildrenIterator;
1009 typedef ChildrenMap::value_type ChildrenPair;
1010 std::recursive_mutex m_mutex;
1013 };
1014
1015 using ValueObjectManagerSP = std::shared_ptr<ValueObjectManager>;
1016
1017 /// The following two functions are helpers for Create methods
1018 /// for ValueObject subclasses that need to optionally receive
1019 /// a parent or external manager.
1020 /// This returns a ValueObjectManagerSP that is either the SP of the
1021 /// parent - if it is non-null, or a new manager if null.
1023 ValueObjectManagerSP manager_sp;
1024 if (parent)
1025 manager_sp = parent->GetManager()->shared_from_this();
1026 else
1027 manager_sp = ValueObjectManager::Create();
1028 return manager_sp;
1029 }
1030
1031 /// If manager is null, makes a new ValueObjectManager and sets
1032 /// manager to the new ValueObjectManager. It also returns the
1033 /// shared pointer which is necessary to keep the new manager alive.
1036 ValueObjectManagerSP manager_sp;
1037 if (!manager) {
1038 manager_sp = ValueObjectManager::Create();
1039 manager = manager_sp.get();
1040 }
1041 return manager_sp;
1042 }
1043
1044 // Classes that inherit from ValueObject can see and modify these
1045
1046 /// The parent value object, or nullptr if this has no parent.
1048 /// The root of the hierarchy for this ValueObject (or nullptr if never
1049 /// calculated).
1051 /// Stores both the stop id and the full context at which this value was last
1052 /// updated. When we are asked to update the value object, we check whether
1053 /// the context & stop id are the same before updating.
1055 /// The name of this object.
1057 /// A data extractor that can be used to extract the value.
1060 /// An error object that can describe any errors that occur when updating
1061 /// values.
1063 /// Cached value string that will get cleared if/when the value is updated.
1064 std::string m_value_str;
1065 /// Cached old value string from the last time the value was gotten
1066 std::string m_old_value_str;
1067 /// Cached location string that will get cleared if/when the value is updated.
1068 std::string m_location_str;
1069 /// Cached summary string that will get cleared if/when the value is updated.
1070 std::string m_summary_str;
1071 /// Cached result of the "object printer". This differs from the summary
1072 /// in that the summary is consed up by us, the object_desc_string is builtin.
1074 /// If the type of the value object should be overridden, the type to impose.
1076
1077 /// This object is managed by the root object (any ValueObject that gets
1078 /// created without a parent.) The manager gets passed through all the
1079 /// generations of dependent objects, and will keep the whole cluster of
1080 /// objects alive as long as a shared pointer to any of them has been handed
1081 /// out. Shared pointers to value objects must always be made with the GetSP
1082 /// method.
1084
1086 std::map<ConstString, ValueObject *> m_synthetic_children;
1087
1091
1092 /// We have to hold onto a shared pointer to this one because it is created
1093 /// as an independent ValueObjectConstResult, which isn't managed by us.
1095
1104
1105 llvm::SmallVector<uint8_t, 16> m_value_checksum;
1106
1108
1109 uint64_t m_language_flags = 0;
1110
1111 /// Unique identifier for every value object.
1113
1114 // Utility class for initializing all bitfields in ValueObject's constructors.
1115 // FIXME: This could be done via default initializers once we have C++20.
1137
1138 friend class ValueObjectChild;
1139 friend class ExpressionVariable; // For SetName
1140 friend class Target; // For SetName
1142 friend class ValueObjectSynthetic; // For ClearUserVisibleData
1143
1144 /// Use this constructor to create a "root variable object". The ValueObject
1145 /// will be locked to this context through-out its lifespan.
1147 AddressType child_ptr_or_ref_addr_type = eAddressTypeLoad);
1148
1149 /// Use this constructor to create a ValueObject owned by another ValueObject.
1150 /// It will inherit the ExecutionContext of its parent.
1151 ValueObject(ValueObject &parent);
1152
1154
1155 virtual bool UpdateValue() = 0;
1156
1160
1161 virtual void CalculateDynamicValue(lldb::DynamicValueType use_dynamic);
1162
1166
1167 virtual bool HasDynamicValueTypeInfo() { return false; }
1168
1169 virtual void CalculateSyntheticValue();
1170
1171 /// Should only be called by ValueObject::GetChildAtIndex().
1172 ///
1173 /// \return A ValueObject managed by this ValueObject's manager.
1174 virtual ValueObject *CreateChildAtIndex(size_t idx);
1175
1176 /// Should only be called by ValueObject::GetSyntheticArrayMember().
1177 ///
1178 /// \return A ValueObject managed by this ValueObject's manager.
1179 virtual ValueObject *CreateSyntheticArrayMember(size_t idx);
1180
1181 /// Should only be called by ValueObject::GetNumChildren().
1182 virtual llvm::Expected<uint32_t>
1184
1185 void SetNumChildren(uint32_t num_children);
1186
1187 void SetValueDidChange(bool value_changed) {
1188 m_flags.m_value_did_change = value_changed;
1189 }
1190
1191 void SetValueIsValid(bool valid) { m_flags.m_value_is_valid = valid; }
1192
1195
1196 void AddSyntheticChild(ConstString key, ValueObject *valobj);
1197
1199
1201
1202 // Subclasses must implement the functions below.
1203
1205
1206 const char *GetLocationAsCStringImpl(const Value &value,
1207 const DataExtractor &data);
1208
1209 bool IsChecksumEmpty() { return m_value_checksum.empty(); }
1210
1212
1213protected:
1215
1216private:
1220
1222 llvm::StringRef expression_cstr,
1223 ExpressionPathScanEndReason *reason_to_stop,
1224 ExpressionPathEndResultType *final_value_type,
1225 const GetValueForExpressionPathOptions &options,
1226 ExpressionPathAftermath *final_task_on_target);
1227
1228 ValueObject(const ValueObject &) = delete;
1229 const ValueObject &operator=(const ValueObject &) = delete;
1230};
1231
1232// The two classes below are used by the public SBValue API implementation. This
1233// is useful here because we need them in order to access the underlying
1234// ValueObject from SBValue without introducing a back-dependency from the API
1235// library to the more core libs.
1236
1238public:
1239 ValueImpl() = default;
1240
1241 ValueImpl(lldb::ValueObjectSP in_valobj_sp,
1242 lldb::DynamicValueType use_dynamic, bool use_synthetic,
1243 const char *name = nullptr);
1244
1245 ValueImpl(const ValueImpl &rhs) = default;
1246
1247 ValueImpl &operator=(const ValueImpl &rhs);
1248
1249 bool IsValid();
1250
1252
1254 std::unique_lock<std::recursive_mutex> &lock,
1255 Status &error);
1256
1258 m_use_dynamic = use_dynamic;
1259 }
1260
1261 void SetUseSynthetic(bool use_synthetic) { m_use_synthetic = use_synthetic; }
1262
1264
1266
1267 // All the derived values that we would make from the m_valobj_sp will share
1268 // the ExecutionContext with m_valobj_sp, so we don't need to do the
1269 // calculations in GetSP to return the Target, Process, Thread or Frame. It
1270 // is convenient to provide simple accessors for these, which I do here.
1272 return m_valobj_sp ? m_valobj_sp->GetTargetSP() : lldb::TargetSP{};
1273 }
1274
1276 return m_valobj_sp ? m_valobj_sp->GetProcessSP() : lldb::ProcessSP{};
1277 }
1278
1280 return m_valobj_sp ? m_valobj_sp->GetThreadSP() : lldb::ThreadSP{};
1281 }
1282
1284 return m_valobj_sp ? m_valobj_sp->GetFrameSP() : lldb::StackFrameSP{};
1285 }
1286
1287private:
1292};
1293
1295public:
1296 ValueLocker() = default;
1297
1301
1303
1304private:
1306 std::unique_lock<std::recursive_mutex> m_lock;
1308};
1309
1310} // namespace lldb_private
1311
1312#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:395
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...
lldb::ProcessSP GetProcessSP()
lldb::ValueObjectSP m_valobj_sp
lldb::DynamicValueType m_use_dynamic
lldb::DynamicValueType GetUseDynamic()
lldb::StackFrameSP GetFrameSP()
lldb::ThreadSP GetThreadSP()
lldb::ValueObjectSP GetSP(Process::StopLocker &stop_locker, std::unique_lock< std::recursive_mutex > &lock, Status &error)
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()
std::unique_lock< std::recursive_mutex > m_lock
Process::StopLocker m_stop_locker
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()
virtual llvm::Expected< size_t > GetIndexOfChildWithName(llvm::StringRef 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()
ChildrenManager m_children
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 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
void SetValueFromInteger(const llvm::APInt &value, Status &error, bool can_update_var=true)
Update an existing integer ValueObject with a new integer value.
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
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)
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.
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()
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.
ValueObject(const ValueObject &)=delete
llvm::Error Dump(Stream &s)
bool UpdateValueIfNeeded(bool update_format=true)
void SetName(ConstString name)
Change the name of the current ValueObject.
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
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:85
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:82
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()