LLDB  mainline
AppleObjCRuntimeV1.h
Go to the documentation of this file.
1 //===-- AppleObjCRuntimeV1.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_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIMEV1_H
10 #define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIMEV1_H
11 
12 #include "AppleObjCRuntime.h"
13 #include "lldb/lldb-private.h"
14 
16 
17 namespace lldb_private {
18 
20 public:
21  ~AppleObjCRuntimeV1() override = default;
22 
23  // Static Functions
24  static void Initialize();
25 
26  static void Terminate();
27 
29  CreateInstance(Process *process, lldb::LanguageType language);
30 
31  static llvm::StringRef GetPluginNameStatic() { return "apple-objc-v1"; }
32 
33  static char ID;
34 
35  bool isA(const void *ClassID) const override {
36  return ClassID == &ID || AppleObjCRuntime::isA(ClassID);
37  }
38 
39  static bool classof(const LanguageRuntime *runtime) {
40  return runtime->isA(&ID);
41  }
42 
44 
46  public:
47  ClassDescriptorV1(ValueObject &isa_pointer);
48  ClassDescriptorV1(ObjCISA isa, lldb::ProcessSP process_sp);
49 
50  ~ClassDescriptorV1() override = default;
51 
52  ConstString GetClassName() override { return m_name; }
53 
55 
56  ClassDescriptorSP GetMetaclass() const override;
57 
58  bool IsValid() override { return m_valid; }
59 
60  // v1 does not support tagged pointers
61  bool GetTaggedPointerInfo(uint64_t *info_bits = nullptr,
62  uint64_t *value_bits = nullptr,
63  uint64_t *payload = nullptr) override {
64  return false;
65  }
66 
67  bool GetTaggedPointerInfoSigned(uint64_t *info_bits = nullptr,
68  int64_t *value_bits = nullptr,
69  uint64_t *payload = nullptr) override {
70  return false;
71  }
72 
73  uint64_t GetInstanceSize() override { return m_instance_size; }
74 
75  ObjCISA GetISA() override { return m_isa; }
76 
77  bool
78  Describe(std::function<void(ObjCLanguageRuntime::ObjCISA)> const
79  &superclass_func,
80  std::function<bool(const char *, const char *)> const
81  &instance_method_func,
82  std::function<bool(const char *, const char *)> const
83  &class_method_func,
84  std::function<bool(const char *, const char *, lldb::addr_t,
85  uint64_t)> const &ivar_func) const override;
86 
87  protected:
88  void Initialize(ObjCISA isa, lldb::ProcessSP process_sp);
89 
90  private:
94  bool m_valid;
95  lldb::ProcessWP m_process_wp;
96  uint64_t m_instance_size;
97  };
98 
99  // These are generic runtime functions:
100  bool GetDynamicTypeAndAddress(ValueObject &in_value,
101  lldb::DynamicValueType use_dynamic,
102  TypeAndOrName &class_type_or_name,
103  Address &address,
104  Value::ValueType &value_type) override;
105 
106  llvm::Expected<std::unique_ptr<UtilityFunction>>
108 
109  // PluginInterface protocol
110  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
111 
114  }
115 
116  void UpdateISAToDescriptorMapIfNeeded() override;
117 
118  DeclVendor *GetDeclVendor() override;
119 
120 protected:
121  lldb::BreakpointResolverSP
122  CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
123  bool catch_bp, bool throw_bp) override;
124 
126  public:
127  HashTableSignature() = default;
128 
129  bool NeedsUpdate(uint32_t count, uint32_t num_buckets,
130  lldb::addr_t buckets_ptr) {
131  return m_count != count || m_num_buckets != num_buckets ||
132  m_buckets_ptr != buckets_ptr;
133  }
134 
135  void UpdateSignature(uint32_t count, uint32_t num_buckets,
136  lldb::addr_t buckets_ptr) {
137  m_count = count;
138  m_num_buckets = num_buckets;
139  m_buckets_ptr = buckets_ptr;
140  }
141 
142  protected:
146  };
147 
149 
152  std::unique_ptr<DeclVendor> m_decl_vendor_up;
153 
154 private:
155  AppleObjCRuntimeV1(Process *process);
156 };
157 
158 } // namespace lldb_private
159 
160 #endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIMEV1_H
lldb_private::AppleObjCRuntime::isA
bool isA(const void *ClassID) const override
Definition: AppleObjCRuntime.h:38
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::m_instance_size
uint64_t m_instance_size
Definition: AppleObjCRuntimeV1.h:96
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::GetTaggedPointerInfo
bool GetTaggedPointerInfo(uint64_t *info_bits=nullptr, uint64_t *value_bits=nullptr, uint64_t *payload=nullptr) override
There are two routines in the ObjC runtime that tagged pointer clients can call to get the value from...
Definition: AppleObjCRuntimeV1.h:61
lldb_private::AppleObjCRuntimeV1::Terminate
static void Terminate()
Definition: AppleObjCRuntimeV1.cpp:91
lldb_private::AppleObjCRuntimeV1::GetRuntimeVersion
ObjCRuntimeVersions GetRuntimeVersion() const override
Definition: AppleObjCRuntimeV1.h:112
lldb_private::AppleObjCRuntimeV1::HashTableSignature::m_buckets_ptr
lldb::addr_t m_buckets_ptr
Definition: AppleObjCRuntimeV1.h:145
lldb_private::AppleObjCRuntimeV1::~AppleObjCRuntimeV1
~AppleObjCRuntimeV1() override=default
lldb_private::AppleObjCRuntimeV1::isA
bool isA(const void *ClassID) const override
Definition: AppleObjCRuntimeV1.h:35
lldb_private::ObjCLanguageRuntime::ClassDescriptorSP
std::shared_ptr< ClassDescriptor > ClassDescriptorSP
Definition: ObjCLanguageRuntime.h:44
lldb_private::AppleObjCRuntimeV1::HashTableSignature::HashTableSignature
HashTableSignature()=default
lldb_private::Process
Definition: Process.h:341
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::GetInstanceSize
uint64_t GetInstanceSize() override
Definition: AppleObjCRuntimeV1.h:73
lldb_private::AppleObjCRuntimeV1::UpdateISAToDescriptorMapIfNeeded
void UpdateISAToDescriptorMapIfNeeded() override
Definition: AppleObjCRuntimeV1.cpp:312
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::GetTaggedPointerInfoSigned
bool GetTaggedPointerInfoSigned(uint64_t *info_bits=nullptr, int64_t *value_bits=nullptr, uint64_t *payload=nullptr) override
Definition: AppleObjCRuntimeV1.h:67
lldb_private::AppleObjCRuntimeV1::HashTableSignature
Definition: AppleObjCRuntimeV1.h:125
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::m_valid
bool m_valid
Definition: AppleObjCRuntimeV1.h:94
lldb_private::AppleObjCRuntimeV1::AppleObjCRuntimeV1
AppleObjCRuntimeV1(Process *process)
Definition: AppleObjCRuntimeV1.cpp:41
lldb_private::AppleObjCRuntimeV1::m_decl_vendor_up
std::unique_ptr< DeclVendor > m_decl_vendor_up
Definition: AppleObjCRuntimeV1.h:152
lldb_private::LanguageRuntime::isA
virtual bool isA(const void *ClassID) const
Definition: LanguageRuntime.h:173
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::m_name
ConstString m_name
Definition: AppleObjCRuntimeV1.h:91
lldb_private::AppleObjCRuntimeV1::CreateExceptionResolver
lldb::BreakpointResolverSP CreateExceptionResolver(const lldb::BreakpointSP &bkpt, bool catch_bp, bool throw_bp) override
Definition: AppleObjCRuntimeV1.cpp:96
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::IsValid
bool IsValid() override
Definition: AppleObjCRuntimeV1.h:58
lldb_private::AppleObjCRuntimeV1::HashTableSignature::UpdateSignature
void UpdateSignature(uint32_t count, uint32_t num_buckets, lldb::addr_t buckets_ptr)
Definition: AppleObjCRuntimeV1.h:135
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::GetClassName
ConstString GetClassName() override
Definition: AppleObjCRuntimeV1.h:52
lldb_private::AppleObjCRuntimeV1::m_isa_hash_table_ptr
lldb::addr_t m_isa_hash_table_ptr
Definition: AppleObjCRuntimeV1.h:151
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::AppleObjCRuntimeV1::GetDynamicTypeAndAddress
bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, Address &address, Value::ValueType &value_type) override
Definition: AppleObjCRuntimeV1.cpp:47
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::ClassDescriptorV1
ClassDescriptorV1(ValueObject &isa_pointer)
Definition: AppleObjCRuntimeV1.cpp:169
lldb_private::Value::ValueType
ValueType
Type that describes Value::m_value.
Definition: Value.h:41
lldb_private::ObjCLanguageRuntime::ObjCRuntimeVersions
ObjCRuntimeVersions
Definition: ObjCLanguageRuntime.h:36
lldb_private::AppleObjCRuntime
Definition: AppleObjCRuntime.h:23
lldb_private::AppleObjCRuntimeV1::GetTaggedPointerObfuscator
lldb::addr_t GetTaggedPointerObfuscator()
Definition: AppleObjCRuntimeV1.cpp:275
lldb::DynamicValueType
DynamicValueType
Definition: lldb-enumerations.h:494
lldb_private::LanguageRuntime
Definition: LanguageRuntime.h:60
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::ObjCLanguageRuntime::ObjCRuntimeVersions::eAppleObjC_V1
@ eAppleObjC_V1
lldb_private::AppleObjCRuntimeV1::GetDeclVendor
DeclVendor * GetDeclVendor() override
Definition: AppleObjCRuntimeV1.cpp:428
lldb-private.h
lldb_private::AppleObjCRuntimeV1::GetISAHashTablePointer
lldb::addr_t GetISAHashTablePointer()
Definition: AppleObjCRuntimeV1.cpp:279
lldb_private::AppleObjCRuntimeV1::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition: AppleObjCRuntimeV1.h:31
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::GetMetaclass
ClassDescriptorSP GetMetaclass() const override
Definition: AppleObjCRuntimeV1.cpp:262
lldb_private::ObjCLanguageRuntime::ClassDescriptor
Definition: ObjCLanguageRuntime.h:50
lldb_private::ValueObject
ValueObject:
Definition: ValueObject.h:105
lldb_private::AppleObjCRuntimeV1::ID
static char ID
Definition: AppleObjCRuntimeV1.h:33
uint32_t
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::Describe
bool Describe(std::function< void(ObjCLanguageRuntime::ObjCISA)> const &superclass_func, std::function< bool(const char *, const char *)> const &instance_method_func, std::function< bool(const char *, const char *)> const &class_method_func, std::function< bool(const char *, const char *, lldb::addr_t, uint64_t)> const &ivar_func) const override
Definition: AppleObjCRuntimeV1.cpp:266
lldb_private::DeclVendor
Definition: DeclVendor.h:20
lldb_private::Address
Definition: Address.h:59
lldb_private::AppleObjCRuntimeV1::HashTableSignature::m_num_buckets
uint32_t m_num_buckets
Definition: AppleObjCRuntimeV1.h:144
lldb_private::ObjCLanguageRuntime::ObjCISA
lldb::addr_t ObjCISA
Definition: ObjCLanguageRuntime.h:42
lldb_private::AppleObjCRuntimeV1::CreateInstance
static lldb_private::LanguageRuntime * CreateInstance(Process *process, lldb::LanguageType language)
Definition: AppleObjCRuntimeV1.cpp:67
lldb_private::AppleObjCRuntimeV1::classof
static bool classof(const LanguageRuntime *runtime)
Definition: AppleObjCRuntimeV1.h:39
ObjCLanguageRuntime.h
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
lldb_private::AppleObjCRuntimeV1::HashTableSignature::NeedsUpdate
bool NeedsUpdate(uint32_t count, uint32_t num_buckets, lldb::addr_t buckets_ptr)
Definition: AppleObjCRuntimeV1.h:129
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::m_parent_isa
ObjCISA m_parent_isa
Definition: AppleObjCRuntimeV1.h:93
lldb_private::AppleObjCRuntimeV1::HashTableSignature::m_count
uint32_t m_count
Definition: AppleObjCRuntimeV1.h:143
lldb_private::AppleObjCRuntimeV1::CreateObjectChecker
llvm::Expected< std::unique_ptr< UtilityFunction > > CreateObjectChecker(std::string, ExecutionContext &exe_ctx) override
Definition: AppleObjCRuntimeV1.cpp:114
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::m_isa
ObjCISA m_isa
Definition: AppleObjCRuntimeV1.h:92
lldb_private::AppleObjCRuntimeV1::m_hash_signature
HashTableSignature m_hash_signature
Definition: AppleObjCRuntimeV1.h:150
lldb_private::TypeAndOrName
Sometimes you can find the name of the type corresponding to an object, but we don't have debug infor...
Definition: Type.h:394
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::~ClassDescriptorV1
~ClassDescriptorV1() override=default
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::GetSuperclass
ClassDescriptorSP GetSuperclass() override
Definition: AppleObjCRuntimeV1.cpp:251
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::Initialize
void Initialize(ObjCISA isa, lldb::ProcessSP process_sp)
Definition: AppleObjCRuntimeV1.cpp:179
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::m_process_wp
lldb::ProcessWP m_process_wp
Definition: AppleObjCRuntimeV1.h:95
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1::GetISA
ObjCISA GetISA() override
Definition: AppleObjCRuntimeV1.h:75
lldb_private::AppleObjCRuntimeV1::GetPluginName
llvm::StringRef GetPluginName() override
Definition: AppleObjCRuntimeV1.h:110
AppleObjCRuntime.h
lldb_private::AppleObjCRuntimeV1::ClassDescriptorV1
Definition: AppleObjCRuntimeV1.h:45
lldb_private::AppleObjCRuntimeV1
Definition: AppleObjCRuntimeV1.h:19
lldb_private::AppleObjCRuntimeV1::Initialize
static void Initialize()
Definition: AppleObjCRuntimeV1.cpp:84