Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h =================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h +++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h @@ -80,6 +80,16 @@ class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime { public: + + enum ModuleKind + { + eModuleKindIgnored, + eModuleKindLibRS, + eModuleKindDriver, + eModuleKindImpl, + eModuleKindKernelObj + }; + ~RenderScriptRuntime() {} //------------------------------------------------------------------ @@ -93,6 +103,12 @@ static lldb_private::ConstString GetPluginNameStatic(); + static bool IsRenderScriptModule(const lldb::ModuleSP &module_sp); + + static ModuleKind GetModuleKind(const lldb::ModuleSP &module_sp); + + static void ModulesDidLoad(const lldb::ProcessSP& process_sp, const ModuleList &module_list ); + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ @@ -119,9 +135,15 @@ return static_cast(0); } + virtual void ModulesDidLoad(const ModuleList &module_list ); + + void Update(); + + void Initiate(); + protected: std::vector m_rsmodules; - + bool m_initiated; private: RenderScriptRuntime(Process *process); // Call CreateInstance instead. }; Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp =================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -58,6 +58,45 @@ return g_name; } +RenderScriptRuntime::ModuleKind +RenderScriptRuntime::GetModuleKind(const lldb::ModuleSP &module_sp) +{ + if (module_sp) + { + // Is this a module containing renderscript kernels? + const Symbol *info_sym = module_sp->FindFirstSymbolWithNameAndType(ConstString(".rs.info"), eSymbolTypeData); + if (info_sym) + { + return eModuleKindKernelObj; + } + } + return eModuleKindIgnored; +} + +bool +RenderScriptRuntime::IsRenderScriptModule(const lldb::ModuleSP &module_sp) +{ + return GetModuleKind(module_sp) != eModuleKindIgnored; +} + + +void +RenderScriptRuntime::ModulesDidLoad(const ModuleList &module_list ) +{ + Mutex::Locker locker (module_list.GetMutex ()); + + size_t num_modules = module_list.GetSize(); + for (size_t i = 0; i < num_modules; i++) + { + auto mod = module_list.GetModuleAtIndex (i); + if (IsRenderScriptModule (mod)) + { + LoadModule(mod); + } + } +} + + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ @@ -109,16 +148,45 @@ if (rs_module.m_module == module_sp) return false; } - RSModuleDescriptor module_desc(module_sp); - if (module_desc.ParseRSInfo()) + bool module_loaded = false; + switch (GetModuleKind(module_sp)) { - m_rsmodules.push_back(module_desc); - return true; + case eModuleKindKernelObj: + { + RSModuleDescriptor module_desc(module_sp); + if (module_desc.ParseRSInfo()) + { + m_rsmodules.push_back(module_desc); + module_loaded = true; + } + break; + } + case eModuleKindDriver: + case eModuleKindImpl: + case eModuleKindLibRS: + default: + break; } + if (module_loaded) + Update(); + return module_loaded; } return false; } +void +RenderScriptRuntime::Update() +{ + if (m_rsmodules.size() > 0) + { + if (!m_initiated) + { + Initiate(); + } + } +} + + // The maximum line length of an .rs.info packet #define MAXLINE 500 @@ -344,13 +412,22 @@ ~CommandObjectRenderScriptRuntime() {} }; -RenderScriptRuntime::RenderScriptRuntime(Process *process) - : lldb_private::CPPLanguageRuntime(process) + +void +RenderScriptRuntime::Initiate() { + assert(!m_initiated); + Process* process = GetProcess(); if (process) { CommandInterpreter &interpreter = process->GetTarget().GetDebugger().GetCommandInterpreter(); - interpreter.AddCommand("renderscript", CommandObjectSP(new CommandObjectRenderScriptRuntime(interpreter)), - true); + m_initiated = interpreter.AddCommand("renderscript", CommandObjectSP( + new CommandObjectRenderScriptRuntime(interpreter)), true); } } + +RenderScriptRuntime::RenderScriptRuntime(Process *process) + : lldb_private::CPPLanguageRuntime(process), m_initiated(false) +{ + +}