[RenderScript] Support for mips64 runtime hook

Previously we could not hook the RS runtime on mips64 architectures.

Patch implements ABI specific code for inspecting function arguments.

Author: Dean De Leo, dean@codeplay.com
llvm-svn: 251003
This commit is contained in:
Ewan Crawford
2015-10-22 09:01:05 +00:00
parent 0cb1561e42
commit 02f1c5d132

View File

@@ -609,25 +609,30 @@ RenderScriptRuntime::GetArgSimple(ExecutionContext &context, uint32_t arg, uint6
{
const RegisterInfo* rArg = reg_ctx->GetRegisterInfoAtIndex(arg);
RegisterValue rVal;
reg_ctx->ReadRegister(rArg, rVal);
(*data) = rVal.GetAsUInt32();
success = true;
success = reg_ctx->ReadRegister(rArg, rVal);
if (success)
{
(*data) = rVal.GetAsUInt32();
}
else
{
if (log)
log->Printf ("RenderScriptRuntime:: GetArgSimple - error reading ARM register: %d.", arg);
}
}
else
{
uint64_t sp = reg_ctx->GetSP();
uint32_t offset = (arg-4) * sizeof(uint32_t);
process->ReadMemory(sp + offset, &data, sizeof(uint32_t), error);
if (error.Fail())
{
uint32_t offset = (arg-4) * sizeof(uint32_t);
process->ReadMemory(sp + offset, &data, sizeof(uint32_t), error);
if (error.Fail())
{
if (log)
log->Printf ("RenderScriptRuntime:: GetArgSimple - error reading ARM stack: %s.", error.AsCString());
}
else
{
success = true;
}
if (log)
log->Printf ("RenderScriptRuntime:: GetArgSimple - error reading ARM stack: %s.", error.AsCString());
}
else
{
success = true;
}
}
@@ -660,6 +665,44 @@ RenderScriptRuntime::GetArgSimple(ExecutionContext &context, uint32_t arg, uint6
}
break;
}
case llvm::Triple::ArchType::mips64el:
{
// read from the registers
if (arg < 8)
{
const RegisterInfo* rArg = reg_ctx->GetRegisterInfoAtIndex(arg + 4);
RegisterValue rVal;
success = reg_ctx->ReadRegister(rArg, rVal);
if (success)
{
(*data) = rVal.GetAsUInt64();
}
else
{
if (log)
log->Printf("RenderScriptRuntime::GetArgSimple - Mips64 - Error reading the argument #%d", arg);
}
}
// read from the stack
else
{
uint64_t sp = reg_ctx->GetSP();
uint32_t offset = (arg - 8) * sizeof(uint64_t);
process->ReadMemory(sp + offset, &data, sizeof(uint64_t), error);
if (error.Fail())
{
if (log)
log->Printf ("RenderScriptRuntime::GetArgSimple - Mips64 - Error reading Mips64 stack: %s.", error.AsCString());
}
else
{
success = true;
}
}
break;
}
default:
{
// invalid architecture
@@ -841,10 +884,12 @@ RenderScriptRuntime::LoadRuntimeHooks(lldb::ModuleSP module, ModuleKind kind)
if (targetArchType != llvm::Triple::ArchType::x86
&& targetArchType != llvm::Triple::ArchType::arm
&& targetArchType != llvm::Triple::ArchType::aarch64)
&& targetArchType != llvm::Triple::ArchType::aarch64
&& targetArchType != llvm::Triple::ArchType::mips64el
)
{
if (log)
log->Printf ("RenderScriptRuntime::LoadRuntimeHooks - Unable to hook runtime. Only X86, ARM supported currently.");
log->Printf ("RenderScriptRuntime::LoadRuntimeHooks - Unable to hook runtime. Only X86, ARM, Mips64 supported currently.");
return;
}