Home | History | Annotate | Download | only in AppleObjCRuntime
      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 // C Includes
     14 // C++ Includes
     15 // Other libraries and framework includes
     16 // Project includes
     17 #include "lldb/lldb-private.h"
     18 #include "lldb/Target/ObjCLanguageRuntime.h"
     19 #include "AppleObjCRuntime.h"
     20 
     21 namespace lldb_private {
     22 
     23 class AppleObjCRuntimeV1 :
     24         public AppleObjCRuntime
     25 {
     26 public:
     27 
     28     class ClassDescriptorV1 : public ObjCLanguageRuntime::ClassDescriptor
     29     {
     30     public:
     31         ClassDescriptorV1 (ValueObject &isa_pointer);
     32         ClassDescriptorV1 (ObjCISA isa, lldb::ProcessSP process_sp);
     33 
     34         virtual ConstString
     35         GetClassName ()
     36         {
     37             return m_name;
     38         }
     39 
     40         virtual ClassDescriptorSP
     41         GetSuperclass ();
     42 
     43         virtual bool
     44         IsValid ()
     45         {
     46             return m_valid;
     47         }
     48 
     49         // v1 does not support tagged pointers
     50         virtual bool
     51         GetTaggedPointerInfo (uint64_t* info_bits = NULL,
     52                               uint64_t* value_bits = NULL,
     53                               uint64_t* payload = NULL)
     54         {
     55             return false;
     56         }
     57 
     58         virtual uint64_t
     59         GetInstanceSize ()
     60         {
     61             return m_instance_size;
     62         }
     63 
     64         virtual ObjCISA
     65         GetISA ()
     66         {
     67             return m_isa;
     68         }
     69 
     70         virtual bool
     71         Describe (std::function <void (ObjCLanguageRuntime::ObjCISA)> const &superclass_func,
     72                   std::function <bool (const char *, const char *)> const &instance_method_func,
     73                   std::function <bool (const char *, const char *)> const &class_method_func,
     74                   std::function <bool (const char *, const char *, lldb::addr_t, uint64_t)> const &ivar_func);
     75 
     76         virtual
     77         ~ClassDescriptorV1 ()
     78         {}
     79 
     80     protected:
     81         void
     82         Initialize (ObjCISA isa, lldb::ProcessSP process_sp);
     83 
     84     private:
     85         ConstString m_name;
     86         ObjCISA m_isa;
     87         ObjCISA m_parent_isa;
     88         bool m_valid;
     89         lldb::ProcessWP m_process_wp;
     90         uint64_t m_instance_size;
     91     };
     92 
     93     virtual ~AppleObjCRuntimeV1() { }
     94 
     95     // These are generic runtime functions:
     96     virtual bool
     97     GetDynamicTypeAndAddress (ValueObject &in_value,
     98                               lldb::DynamicValueType use_dynamic,
     99                               TypeAndOrName &class_type_or_name,
    100                               Address &address);
    101 
    102     virtual ClangUtilityFunction *
    103     CreateObjectChecker (const char *);
    104 
    105     //------------------------------------------------------------------
    106     // Static Functions
    107     //------------------------------------------------------------------
    108     static void
    109     Initialize();
    110 
    111     static void
    112     Terminate();
    113 
    114     static lldb_private::LanguageRuntime *
    115     CreateInstance (Process *process, lldb::LanguageType language);
    116 
    117     static lldb_private::ConstString
    118     GetPluginNameStatic();
    119 
    120     //------------------------------------------------------------------
    121     // PluginInterface protocol
    122     //------------------------------------------------------------------
    123     virtual ConstString
    124     GetPluginName();
    125 
    126     virtual uint32_t
    127     GetPluginVersion();
    128 
    129     virtual ObjCRuntimeVersions
    130     GetRuntimeVersion ()
    131     {
    132         return eAppleObjC_V1;
    133     }
    134 
    135     virtual void
    136     UpdateISAToDescriptorMapIfNeeded();
    137 
    138     virtual TypeVendor *
    139     GetTypeVendor();
    140 
    141 protected:
    142     virtual lldb::BreakpointResolverSP
    143     CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp);
    144 
    145 
    146     class HashTableSignature
    147     {
    148     public:
    149         HashTableSignature () :
    150             m_count (0),
    151             m_num_buckets (0),
    152             m_buckets_ptr (LLDB_INVALID_ADDRESS)
    153         {
    154         }
    155 
    156         bool
    157         NeedsUpdate (uint32_t count,
    158                      uint32_t num_buckets,
    159                      lldb::addr_t buckets_ptr)
    160         {
    161             return m_count       != count       ||
    162                    m_num_buckets != num_buckets ||
    163                    m_buckets_ptr != buckets_ptr ;
    164         }
    165 
    166         void
    167         UpdateSignature (uint32_t count,
    168                          uint32_t num_buckets,
    169                          lldb::addr_t buckets_ptr)
    170         {
    171             m_count = count;
    172             m_num_buckets = num_buckets;
    173             m_buckets_ptr = buckets_ptr;
    174         }
    175 
    176     protected:
    177         uint32_t m_count;
    178         uint32_t m_num_buckets;
    179         lldb::addr_t m_buckets_ptr;
    180     };
    181 
    182 
    183     lldb::addr_t
    184     GetISAHashTablePointer ();
    185 
    186     HashTableSignature m_hash_signature;
    187     lldb::addr_t m_isa_hash_table_ptr;
    188     std::unique_ptr<TypeVendor> m_type_vendor_ap;
    189 private:
    190     AppleObjCRuntimeV1(Process *process);
    191 };
    192 
    193 } // namespace lldb_private
    194 
    195 #endif  // liblldb_AppleObjCRuntimeV1_h_
    196