[Lldb-commits] [lldb] r234871 - Additions to RenderScriptRuntime in prep for detection of RenderScript modules and moving of the command interpreter manipulation to after construction.
Colin Riley
colin at codeplay.com
Tue Apr 14 00:39:24 PDT 2015
Author: domipheus
Date: Tue Apr 14 02:39:24 2015
New Revision: 234871
URL: http://llvm.org/viewvc/llvm-project?rev=234871&view=rev
Log:
Additions to RenderScriptRuntime in prep for detection of RenderScript modules and moving of the command interpreter manipulation to after construction.
Differential Revision: http://reviews.llvm.org/D9001
Modified:
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
Modified: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=234871&r1=234870&r2=234871&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp Tue Apr 14 02:39:24 2015
@@ -58,6 +58,45 @@ RenderScriptRuntime::GetPluginNameStatic
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 @@ RenderScriptRuntime::LoadModule(const ll
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 @@ class CommandObjectRenderScriptRuntime :
~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)
+{
+
+}
Modified: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h?rev=234871&r1=234870&r2=234871&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h Tue Apr 14 02:39:24 2015
@@ -80,6 +80,16 @@ class RSModuleDescriptor
class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime
{
public:
+
+ enum ModuleKind
+ {
+ eModuleKindIgnored,
+ eModuleKindLibRS,
+ eModuleKindDriver,
+ eModuleKindImpl,
+ eModuleKindKernelObj
+ };
+
~RenderScriptRuntime() {}
//------------------------------------------------------------------
@@ -93,6 +103,12 @@ class RenderScriptRuntime : public lldb_
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 @@ class RenderScriptRuntime : public lldb_
return static_cast<size_t>(0);
}
+ virtual void ModulesDidLoad(const ModuleList &module_list );
+
+ void Update();
+
+ void Initiate();
+
protected:
std::vector<RSModuleDescriptor> m_rsmodules;
-
+ bool m_initiated;
private:
RenderScriptRuntime(Process *process); // Call CreateInstance instead.
};
More information about the lldb-commits
mailing list