1 //===-- RenderScriptRuntime.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_RenderScriptRuntime_h_
11 #define liblldb_RenderScriptRuntime_h_
15 // Other libraries and framework 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"
22 namespace lldb_private
25 typedef uint32_t RSSlot;
26 class RSModuleDescriptor;
27 struct RSGlobalDescriptor;
28 struct RSKernelDescriptor;
30 typedef std::shared_ptr<RSModuleDescriptor> RSModuleDescriptorSP;
31 typedef std::shared_ptr<RSGlobalDescriptor> RSGlobalDescriptorSP;
32 typedef std::shared_ptr<RSKernelDescriptor> RSKernelDescriptorSP;
36 struct RSKernelDescriptor
39 RSKernelDescriptor(const RSModuleDescriptor *module, const char *name, uint32_t slot)
46 void Dump(Stream &strm) const;
48 const RSModuleDescriptor *m_module;
53 struct RSGlobalDescriptor
56 RSGlobalDescriptor(const RSModuleDescriptor *module, const char *name )
62 void Dump(Stream &strm) const;
64 const RSModuleDescriptor *m_module;
68 class RSModuleDescriptor
71 RSModuleDescriptor(const lldb::ModuleSP &module)
76 ~RSModuleDescriptor() {}
80 void Dump(Stream &strm) const;
82 const lldb::ModuleSP m_module;
83 std::vector<RSKernelDescriptor> m_kernels;
84 std::vector<RSGlobalDescriptor> m_globals;
85 std::map<std::string, std::string> m_pragmas;
86 std::string m_resname;
89 class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime
103 ~RenderScriptRuntime() {}
105 //------------------------------------------------------------------
107 //------------------------------------------------------------------
108 static void Initialize();
110 static void Terminate();
112 static lldb_private::LanguageRuntime *CreateInstance(Process *process, lldb::LanguageType language);
114 static lldb::CommandObjectSP GetCommandObject(CommandInterpreter& interpreter);
116 static lldb_private::ConstString GetPluginNameStatic();
118 static bool IsRenderScriptModule(const lldb::ModuleSP &module_sp);
120 static ModuleKind GetModuleKind(const lldb::ModuleSP &module_sp);
122 static void ModulesDidLoad(const lldb::ProcessSP& process_sp, const ModuleList &module_list );
124 //------------------------------------------------------------------
125 // PluginInterface protocol
126 //------------------------------------------------------------------
127 virtual lldb_private::ConstString GetPluginName();
129 virtual uint32_t GetPluginVersion();
131 virtual bool IsVTableName(const char *name);
133 virtual bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
134 TypeAndOrName &class_type_or_name, Address &address);
136 virtual bool CouldHaveDynamicValue(ValueObject &in_value);
138 virtual lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp);
140 bool LoadModule(const lldb::ModuleSP &module_sp);
142 bool ProbeModules(const ModuleList module_list);
144 void DumpModules(Stream &strm) const;
146 void DumpContexts(Stream &strm) const;
148 void DumpKernels(Stream &strm) const;
150 void AttemptBreakpointAtKernelName(Stream &strm, const char *name, Error &error);
152 void Status(Stream &strm) const;
154 virtual size_t GetAlternateManglings(const ConstString &mangled, std::vector<ConstString> &alternates) {
155 return static_cast<size_t>(0);
158 virtual void ModulesDidLoad(const ModuleList &module_list );
166 void FixupScriptDetails(RSModuleDescriptorSP rsmodule_sp);
168 void LoadRuntimeHooks(lldb::ModuleSP module, ModuleKind kind);
171 typedef void (RenderScriptRuntime::*CaptureStateFn)(RuntimeHook* hook_info, ExecutionContext &context); // Please do this!
176 const char * symbol_name;
179 CaptureStateFn grabber;
184 lldb::addr_t address;
185 const HookDefn *defn;
186 lldb::BreakpointSP bp_sp;
189 typedef std::shared_ptr<RuntimeHook> RuntimeHookSP;
194 std::string scriptDyLib;
195 std::string cachedir;
196 lldb::addr_t context;
200 lldb::ModuleSP m_libRS;
201 lldb::ModuleSP m_libRSDriver;
202 lldb::ModuleSP m_libRSCpuRef;
203 std::vector<RSModuleDescriptorSP> m_rsmodules;
204 std::vector<ScriptDetails> m_scripts;
206 std::map<lldb::addr_t, RSModuleDescriptorSP> m_scriptMappings;
207 std::map<lldb::addr_t, RuntimeHookSP> m_runtimeHooks;
210 bool m_debuggerPresentFlagged;
211 static const HookDefn s_runtimeHookDefns[];
212 static const size_t s_runtimeHookCount;
215 RenderScriptRuntime(Process *process); // Call CreateInstance instead.
217 static bool HookCallback(void *baton, StoppointCallbackContext *ctx, lldb::user_id_t break_id,
218 lldb::user_id_t break_loc_id);
220 void HookCallback(RuntimeHook* hook_info, ExecutionContext& context);
222 bool GetArg32Simple(ExecutionContext& context, uint32_t arg, uint32_t *data);
224 void CaptureScriptInit1(RuntimeHook* hook_info, ExecutionContext& context);
225 void CaptureAllocationInit1(RuntimeHook* hook_info, ExecutionContext& context);
226 void CaptureSetGlobalVar1(RuntimeHook* hook_info, ExecutionContext& context);
230 } // namespace lldb_private
232 #endif // liblldb_RenderScriptRuntime_h_