]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / LanguageRuntime / ObjC / AppleObjCRuntime / AppleObjCRuntimeV1.h
1 //===-- AppleObjCRuntimeV1.h ------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_AppleObjCRuntimeV1_h_
11 #define liblldb_AppleObjCRuntimeV1_h_
12
13 #include "AppleObjCRuntime.h"
14 #include "lldb/Target/ObjCLanguageRuntime.h"
15 #include "lldb/lldb-private.h"
16
17 namespace lldb_private {
18
19 class AppleObjCRuntimeV1 : public AppleObjCRuntime {
20 public:
21   ~AppleObjCRuntimeV1() override = default;
22
23   //------------------------------------------------------------------
24   // Static Functions
25   //------------------------------------------------------------------
26   static void Initialize();
27
28   static void Terminate();
29
30   static lldb_private::LanguageRuntime *
31   CreateInstance(Process *process, lldb::LanguageType language);
32
33   static lldb_private::ConstString GetPluginNameStatic();
34
35   static bool classof(const ObjCLanguageRuntime *runtime) {
36     switch (runtime->GetRuntimeVersion()) {
37     case ObjCRuntimeVersions::eAppleObjC_V1:
38       return true;
39     default:
40       return false;
41     }
42   }
43
44   lldb::addr_t GetTaggedPointerObfuscator();
45
46   class ClassDescriptorV1 : public ObjCLanguageRuntime::ClassDescriptor {
47   public:
48     ClassDescriptorV1(ValueObject &isa_pointer);
49     ClassDescriptorV1(ObjCISA isa, lldb::ProcessSP process_sp);
50
51     ~ClassDescriptorV1() override = default;
52
53     ConstString GetClassName() override { return m_name; }
54
55     ClassDescriptorSP GetSuperclass() override;
56
57     ClassDescriptorSP GetMetaclass() const override;
58
59     bool IsValid() override { return m_valid; }
60
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 {
65       return false;
66     }
67
68     uint64_t GetInstanceSize() override { return m_instance_size; }
69
70     ObjCISA GetISA() override { return m_isa; }
71
72     bool
73     Describe(std::function<void(ObjCLanguageRuntime::ObjCISA)> const
74                  &superclass_func,
75              std::function<bool(const char *, const char *)> const
76                  &instance_method_func,
77              std::function<bool(const char *, const char *)> const
78                  &class_method_func,
79              std::function<bool(const char *, const char *, lldb::addr_t,
80                                 uint64_t)> const &ivar_func) const override;
81
82   protected:
83     void Initialize(ObjCISA isa, lldb::ProcessSP process_sp);
84
85   private:
86     ConstString m_name;
87     ObjCISA m_isa;
88     ObjCISA m_parent_isa;
89     bool m_valid;
90     lldb::ProcessWP m_process_wp;
91     uint64_t m_instance_size;
92   };
93
94   // These are generic runtime functions:
95   bool GetDynamicTypeAndAddress(ValueObject &in_value,
96                                 lldb::DynamicValueType use_dynamic,
97                                 TypeAndOrName &class_type_or_name,
98                                 Address &address,
99                                 Value::ValueType &value_type) override;
100
101   UtilityFunction *CreateObjectChecker(const char *) override;
102
103   //------------------------------------------------------------------
104   // PluginInterface protocol
105   //------------------------------------------------------------------
106   ConstString GetPluginName() override;
107
108   uint32_t GetPluginVersion() override;
109
110   ObjCRuntimeVersions GetRuntimeVersion() const override {
111     return ObjCRuntimeVersions::eAppleObjC_V1;
112   }
113
114   void UpdateISAToDescriptorMapIfNeeded() override;
115
116   DeclVendor *GetDeclVendor() override;
117
118 protected:
119   lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt,
120                                                      bool catch_bp,
121                                                      bool throw_bp) override;
122
123   class HashTableSignature {
124   public:
125     HashTableSignature()
126         : m_count(0), m_num_buckets(0), m_buckets_ptr(LLDB_INVALID_ADDRESS) {}
127
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;
132     }
133
134     void UpdateSignature(uint32_t count, uint32_t num_buckets,
135                          lldb::addr_t buckets_ptr) {
136       m_count = count;
137       m_num_buckets = num_buckets;
138       m_buckets_ptr = buckets_ptr;
139     }
140
141   protected:
142     uint32_t m_count;
143     uint32_t m_num_buckets;
144     lldb::addr_t m_buckets_ptr;
145   };
146
147   lldb::addr_t GetISAHashTablePointer();
148
149   HashTableSignature m_hash_signature;
150   lldb::addr_t m_isa_hash_table_ptr;
151   std::unique_ptr<DeclVendor> m_decl_vendor_ap;
152
153 private:
154   AppleObjCRuntimeV1(Process *process);
155 };
156
157 } // namespace lldb_private
158
159 #endif // liblldb_AppleObjCRuntimeV1_h_