1//===-- AppleObjCRuntime.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_AppleObjCRuntime_h_
11#define liblldb_AppleObjCRuntime_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/LanguageRuntime.h"
19#include "lldb/Target/ObjCLanguageRuntime.h"
20#include "lldb/Core/ValueObject.h"
21#include "AppleObjCTrampolineHandler.h"
22#include "AppleThreadPlanStepThroughObjCTrampoline.h"
23
24namespace lldb_private {
25
26class AppleObjCRuntime :
27        public lldb_private::ObjCLanguageRuntime
28{
29public:
30
31    virtual ~AppleObjCRuntime() { }
32
33    // These are generic runtime functions:
34    virtual bool
35    GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope);
36
37    virtual bool
38    GetObjectDescription (Stream &str, ValueObject &object);
39
40    virtual bool
41    CouldHaveDynamicValue (ValueObject &in_value);
42
43    virtual bool
44    GetDynamicTypeAndAddress (ValueObject &in_value,
45                              lldb::DynamicValueType use_dynamic,
46                              TypeAndOrName &class_type_or_name,
47                              Address &address);
48
49    // These are the ObjC specific functions.
50
51    virtual bool
52    IsModuleObjCLibrary (const lldb::ModuleSP &module_sp);
53
54    virtual bool
55    ReadObjCLibrary (const lldb::ModuleSP &module_sp);
56
57    virtual bool
58    HasReadObjCLibrary ()
59    {
60        return m_read_objc_library;
61    }
62
63    virtual lldb::ThreadPlanSP
64    GetStepThroughTrampolinePlan (Thread &thread, bool stop_others);
65
66    // Get the "libobjc.A.dylib" module from the current target if we can find
67    // it, also cache it once it is found to ensure quick lookups.
68    lldb::ModuleSP
69    GetObjCModule ();
70
71    //------------------------------------------------------------------
72    // Static Functions
73    //------------------------------------------------------------------
74    // Note there is no CreateInstance, Initialize & Terminate functions here, because
75    // you can't make an instance of this generic runtime.
76
77protected:
78    virtual bool
79    CalculateHasNewLiteralsAndIndexing();
80
81    static bool
82    AppleIsModuleObjCLibrary (const lldb::ModuleSP &module_sp);
83
84    static enum ObjCRuntimeVersions
85    GetObjCVersion (Process *process, lldb::ModuleSP &objc_module_sp);
86
87    //------------------------------------------------------------------
88    // PluginInterface protocol
89    //------------------------------------------------------------------
90public:
91    virtual void
92    SetExceptionBreakpoints();
93
94    virtual void
95    ClearExceptionBreakpoints ();
96
97    virtual bool
98    ExceptionBreakpointsExplainStop (lldb::StopInfoSP stop_reason);
99
100    virtual lldb::SearchFilterSP
101    CreateExceptionSearchFilter ();
102
103protected:
104    Address *
105    GetPrintForDebuggerAddr();
106
107    std::unique_ptr<Address>  m_PrintForDebugger_addr;
108    bool m_read_objc_library;
109    std::unique_ptr<lldb_private::AppleObjCTrampolineHandler> m_objc_trampoline_handler_ap;
110    lldb::BreakpointSP m_objc_exception_bp_sp;
111    lldb::ModuleWP m_objc_module_wp;
112
113    AppleObjCRuntime(Process *process) :
114        lldb_private::ObjCLanguageRuntime(process),
115        m_read_objc_library (false),
116        m_objc_trampoline_handler_ap ()
117     {
118         // Call CreateInstance instead.
119     }
120};
121
122} // namespace lldb_private
123
124#endif  // liblldb_AppleObjCRuntime_h_
125