1 //===-- AppleObjCRuntimeV1.h ------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_AppleObjCRuntimeV1_h_
11 #define liblldb_AppleObjCRuntimeV1_h_
13 #include "AppleObjCRuntime.h"
14 #include "lldb/Target/ObjCLanguageRuntime.h"
15 #include "lldb/lldb-private.h"
17 namespace lldb_private {
19 class AppleObjCRuntimeV1 : public AppleObjCRuntime {
21 ~AppleObjCRuntimeV1() override = default;
23 //------------------------------------------------------------------
25 //------------------------------------------------------------------
26 static void Initialize();
28 static void Terminate();
30 static lldb_private::LanguageRuntime *
31 CreateInstance(Process *process, lldb::LanguageType language);
33 static lldb_private::ConstString GetPluginNameStatic();
35 static bool classof(const ObjCLanguageRuntime *runtime) {
36 switch (runtime->GetRuntimeVersion()) {
37 case ObjCRuntimeVersions::eAppleObjC_V1:
44 lldb::addr_t GetTaggedPointerObfuscator();
46 class ClassDescriptorV1 : public ObjCLanguageRuntime::ClassDescriptor {
48 ClassDescriptorV1(ValueObject &isa_pointer);
49 ClassDescriptorV1(ObjCISA isa, lldb::ProcessSP process_sp);
51 ~ClassDescriptorV1() override = default;
53 ConstString GetClassName() override { return m_name; }
55 ClassDescriptorSP GetSuperclass() override;
57 ClassDescriptorSP GetMetaclass() const override;
59 bool IsValid() override { return m_valid; }
61 // v1 does not support tagged pointers
62 bool GetTaggedPointerInfo(uint64_t *info_bits = nullptr,
63 uint64_t *value_bits = nullptr,
64 uint64_t *payload = nullptr) override {
68 uint64_t GetInstanceSize() override { return m_instance_size; }
70 ObjCISA GetISA() override { return m_isa; }
73 Describe(std::function<void(ObjCLanguageRuntime::ObjCISA)> const
75 std::function<bool(const char *, const char *)> const
76 &instance_method_func,
77 std::function<bool(const char *, const char *)> const
79 std::function<bool(const char *, const char *, lldb::addr_t,
80 uint64_t)> const &ivar_func) const override;
83 void Initialize(ObjCISA isa, lldb::ProcessSP process_sp);
90 lldb::ProcessWP m_process_wp;
91 uint64_t m_instance_size;
94 // These are generic runtime functions:
95 bool GetDynamicTypeAndAddress(ValueObject &in_value,
96 lldb::DynamicValueType use_dynamic,
97 TypeAndOrName &class_type_or_name,
99 Value::ValueType &value_type) override;
101 UtilityFunction *CreateObjectChecker(const char *) override;
103 //------------------------------------------------------------------
104 // PluginInterface protocol
105 //------------------------------------------------------------------
106 ConstString GetPluginName() override;
108 uint32_t GetPluginVersion() override;
110 ObjCRuntimeVersions GetRuntimeVersion() const override {
111 return ObjCRuntimeVersions::eAppleObjC_V1;
114 void UpdateISAToDescriptorMapIfNeeded() override;
116 DeclVendor *GetDeclVendor() override;
119 lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt,
121 bool throw_bp) override;
123 class HashTableSignature {
126 : m_count(0), m_num_buckets(0), m_buckets_ptr(LLDB_INVALID_ADDRESS) {}
128 bool NeedsUpdate(uint32_t count, uint32_t num_buckets,
129 lldb::addr_t buckets_ptr) {
130 return m_count != count || m_num_buckets != num_buckets ||
131 m_buckets_ptr != buckets_ptr;
134 void UpdateSignature(uint32_t count, uint32_t num_buckets,
135 lldb::addr_t buckets_ptr) {
137 m_num_buckets = num_buckets;
138 m_buckets_ptr = buckets_ptr;
143 uint32_t m_num_buckets;
144 lldb::addr_t m_buckets_ptr;
147 lldb::addr_t GetISAHashTablePointer();
149 HashTableSignature m_hash_signature;
150 lldb::addr_t m_isa_hash_table_ptr;
151 std::unique_ptr<DeclVendor> m_decl_vendor_ap;
154 AppleObjCRuntimeV1(Process *process);
157 } // namespace lldb_private
159 #endif // liblldb_AppleObjCRuntimeV1_h_