1 //===-- RenderScriptRuntime.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_RenderScriptRuntime_h_
11 #define liblldb_RenderScriptRuntime_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/CPPLanguageRuntime.h"
20 #include "lldb/Core/Module.h"
21 
22 namespace lldb_private
23 {
24 
25 typedef uint32_t RSSlot;
26 class RSModuleDescriptor;
27 
28 struct RSKernelDescriptor
29 {
30   public:
31     RSKernelDescriptor(const RSModuleDescriptor &module, const char *name, uint32_t slot)
32         : m_module(module)
33         , m_name(name)
34         , m_slot(slot)
35     {
36     }
37 
38     void Dump(Stream &strm) const;
39 
40     const RSModuleDescriptor &m_module;
41     ConstString m_name;
42     RSSlot m_slot;
43 };
44 
45 struct RSGlobalDescriptor
46 {
47   public:
48     RSGlobalDescriptor(const RSModuleDescriptor &module, const char *name)
49         : m_module(module)
50         , m_name(name)
51     {
52     }
53 
54     void Dump(Stream &strm) const;
55 
56     const RSModuleDescriptor &m_module;
57     ConstString m_name;
58     RSSlot m_slot;
59 };
60 
61 class RSModuleDescriptor
62 {
63   public:
64     RSModuleDescriptor(const lldb::ModuleSP &module)
65         : m_module(module)
66     {
67     }
68 
69     ~RSModuleDescriptor() {}
70 
71     bool ParseRSInfo();
72 
73     void Dump(Stream &strm) const;
74 
75     const lldb::ModuleSP m_module;
76     std::vector<RSKernelDescriptor> m_kernels;
77     std::vector<RSGlobalDescriptor> m_globals;
78 };
79 
80 class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime
81 {
82   public:
83 
84     enum ModuleKind
85     {
86         eModuleKindIgnored,
87         eModuleKindLibRS,
88         eModuleKindDriver,
89         eModuleKindImpl,
90         eModuleKindKernelObj
91     };
92 
93     ~RenderScriptRuntime() {}
94 
95     //------------------------------------------------------------------
96     // Static Functions
97     //------------------------------------------------------------------
98     static void Initialize();
99 
100     static void Terminate();
101 
102     static lldb_private::LanguageRuntime *CreateInstance(Process *process, lldb::LanguageType language);
103 
104     static lldb_private::ConstString GetPluginNameStatic();
105 
106     static bool IsRenderScriptModule(const lldb::ModuleSP &module_sp);
107 
108     static ModuleKind GetModuleKind(const lldb::ModuleSP &module_sp);
109 
110     static void ModulesDidLoad(const lldb::ProcessSP& process_sp, const ModuleList &module_list );
111 
112     //------------------------------------------------------------------
113     // PluginInterface protocol
114     //------------------------------------------------------------------
115     virtual lldb_private::ConstString GetPluginName();
116 
117     virtual uint32_t GetPluginVersion();
118 
119     virtual bool IsVTableName(const char *name);
120 
121     virtual bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
122                                           TypeAndOrName &class_type_or_name, Address &address);
123 
124     virtual bool CouldHaveDynamicValue(ValueObject &in_value);
125 
126     virtual lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp);
127 
128     bool LoadModule(const lldb::ModuleSP &module_sp);
129 
130     bool ProbeModules(const ModuleList module_list);
131 
132     void DumpModules(Stream &strm) const;
133 
134     virtual size_t GetAlternateManglings(const ConstString &mangled, std::vector<ConstString> &alternates) {
135         return static_cast<size_t>(0);
136     }
137 
138     virtual void ModulesDidLoad(const ModuleList &module_list );
139 
140     void Update();
141 
142     void Initiate();
143 
144   protected:
145     std::vector<RSModuleDescriptor> m_rsmodules;
146     bool m_initiated;
147   private:
148     RenderScriptRuntime(Process *process); // Call CreateInstance instead.
149 };
150 
151 } // namespace lldb_private
152 
153 #endif // liblldb_RenderScriptRuntime_h_
154