1 //===-- ValueObjectRegister.h -----------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_CORE_VALUEOBJECTREGISTER_H 10 #define LLDB_CORE_VALUEOBJECTREGISTER_H 11 12 #include "lldb/Core/ValueObject.h" 13 #include "lldb/Symbol/CompilerType.h" 14 #include "lldb/Utility/ConstString.h" 15 #include "lldb/Utility/RegisterValue.h" 16 #include "lldb/lldb-defines.h" 17 #include "lldb/lldb-enumerations.h" 18 #include "lldb/lldb-forward.h" 19 #include "lldb/lldb-private-types.h" 20 21 #include <stddef.h> 22 #include <stdint.h> 23 24 namespace lldb_private { 25 class DataExtractor; 26 class Status; 27 class ExecutionContextScope; 28 class Scalar; 29 class Stream; 30 31 class ValueObjectRegisterSet : public ValueObject { 32 public: 33 ~ValueObjectRegisterSet() override; 34 35 static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, 36 lldb::RegisterContextSP ®_ctx_sp, 37 uint32_t set_idx); 38 39 llvm::Optional<uint64_t> GetByteSize() override; 40 GetValueType()41 lldb::ValueType GetValueType() const override { 42 return lldb::eValueTypeRegisterSet; 43 } 44 45 ConstString GetTypeName() override; 46 47 ConstString GetQualifiedTypeName() override; 48 49 size_t CalculateNumChildren(uint32_t max) override; 50 51 ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member, 52 int32_t synthetic_index) override; 53 54 lldb::ValueObjectSP GetChildMemberWithName(ConstString name, 55 bool can_create) override; 56 57 size_t GetIndexOfChildWithName(ConstString name) override; 58 59 protected: 60 bool UpdateValue() override; 61 62 CompilerType GetCompilerTypeImpl() override; 63 64 lldb::RegisterContextSP m_reg_ctx_sp; 65 const RegisterSet *m_reg_set; 66 uint32_t m_reg_set_idx; 67 68 private: 69 friend class ValueObjectRegisterContext; 70 71 ValueObjectRegisterSet(ExecutionContextScope *exe_scope, 72 ValueObjectManager &manager, 73 lldb::RegisterContextSP ®_ctx_sp, uint32_t set_idx); 74 75 // For ValueObject only 76 ValueObjectRegisterSet(const ValueObjectRegisterSet &) = delete; 77 const ValueObjectRegisterSet & 78 operator=(const ValueObjectRegisterSet &) = delete; 79 }; 80 81 class ValueObjectRegister : public ValueObject { 82 public: 83 ~ValueObjectRegister() override; 84 85 static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, 86 lldb::RegisterContextSP ®_ctx_sp, 87 uint32_t reg_num); 88 89 llvm::Optional<uint64_t> GetByteSize() override; 90 GetValueType()91 lldb::ValueType GetValueType() const override { 92 return lldb::eValueTypeRegister; 93 } 94 95 ConstString GetTypeName() override; 96 97 size_t CalculateNumChildren(uint32_t max) override; 98 99 bool SetValueFromCString(const char *value_str, Status &error) override; 100 101 bool SetData(DataExtractor &data, Status &error) override; 102 103 bool ResolveValue(Scalar &scalar) override; 104 105 void 106 GetExpressionPath(Stream &s, 107 GetExpressionPathFormat epformat = 108 eGetExpressionPathFormatDereferencePointers) override; 109 110 protected: 111 bool UpdateValue() override; 112 113 CompilerType GetCompilerTypeImpl() override; 114 115 lldb::RegisterContextSP m_reg_ctx_sp; 116 RegisterInfo m_reg_info; 117 RegisterValue m_reg_value; 118 ConstString m_type_name; 119 CompilerType m_compiler_type; 120 121 private: 122 void ConstructObject(uint32_t reg_num); 123 124 friend class ValueObjectRegisterSet; 125 126 ValueObjectRegister(ValueObject &parent, lldb::RegisterContextSP ®_ctx_sp, 127 uint32_t reg_num); 128 ValueObjectRegister(ExecutionContextScope *exe_scope, 129 ValueObjectManager &manager, 130 lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num); 131 132 // For ValueObject only 133 ValueObjectRegister(const ValueObjectRegister &) = delete; 134 const ValueObjectRegister &operator=(const ValueObjectRegister &) = delete; 135 }; 136 137 } // namespace lldb_private 138 139 #endif // LLDB_CORE_VALUEOBJECTREGISTER_H 140