forked from OSchip/llvm-project
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 llvm-svn: 234871
This commit is contained in:
parent
3f57216ca4
commit
ef20b08ff3
|
@ -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 lldb::ModuleSP &module_sp)
|
|||
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 : public CommandObjectMultiword
|
|||
|
||||
~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)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -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_private::CPPLanguageRuntime
|
|||
|
||||
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_private::CPPLanguageRuntime
|
|||
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.
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue