[Renderscript] Add stack argument reading code for Mipsel
This commit implements the reading of stack spilled function arguments for little endian MIPS targets. Committed on behalf of: Dean De Leo <dean@codeplay.com> llvm-svn: 263130
This commit is contained in:
parent
8433fdbedf
commit
17e07c0ab4
|
@ -184,6 +184,8 @@ GetArgsX86_64(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args)
|
|||
4, // eBool,
|
||||
}};
|
||||
|
||||
Error error;
|
||||
|
||||
// get the current stack pointer
|
||||
uint64_t sp = ctx.reg_ctx->GetSP();
|
||||
// step over the return address
|
||||
|
@ -227,7 +229,6 @@ GetArgsX86_64(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args)
|
|||
// read the argument from memory
|
||||
arg.value = 0;
|
||||
// note: due to little endian layout reading 4 or 8 bytes will give the correct value.
|
||||
Error error;
|
||||
size_t read = ctx.process->ReadMemory(sp, &arg.value, size, error);
|
||||
success = (error.Success() && read==size);
|
||||
// advance past this argument
|
||||
|
@ -237,7 +238,8 @@ GetArgsX86_64(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args)
|
|||
if (!success)
|
||||
{
|
||||
if (log)
|
||||
log->Printf("%s - error reading argument: %" PRIu64, __FUNCTION__, uint64_t(i));
|
||||
log->Printf("%s - error reading argument: %" PRIu64", reason: %s",
|
||||
__FUNCTION__, uint64_t(i), error.AsCString("n/a"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -252,6 +254,8 @@ GetArgsArm(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args)
|
|||
|
||||
Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE);
|
||||
|
||||
Error error;
|
||||
|
||||
// get the current stack pointer
|
||||
uint64_t sp = ctx.reg_ctx->GetSP();
|
||||
|
||||
|
@ -275,7 +279,6 @@ GetArgsArm(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args)
|
|||
// clear all 64bits
|
||||
arg.value = 0;
|
||||
// read this argument from memory
|
||||
Error error;
|
||||
size_t bytes_read = ctx.process->ReadMemory(sp, &arg.value, arg_size, error);
|
||||
success = (error.Success() && bytes_read == arg_size);
|
||||
// advance the stack pointer
|
||||
|
@ -285,7 +288,8 @@ GetArgsArm(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args)
|
|||
if (!success)
|
||||
{
|
||||
if (log)
|
||||
log->Printf("%s - error reading argument: %" PRIu64, __FUNCTION__, uint64_t(i));
|
||||
log->Printf("%s - error reading argument: %" PRIu64", reason: %s",
|
||||
__FUNCTION__, uint64_t(i), error.AsCString("n/a"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -340,6 +344,11 @@ GetArgsMipsel(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args)
|
|||
|
||||
Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE);
|
||||
|
||||
Error error;
|
||||
|
||||
// find offset to arguments on the stack (+16 to skip over a0-a3 shadow space)
|
||||
uint64_t sp = ctx.reg_ctx->GetSP() + 16;
|
||||
|
||||
for (size_t i = 0; i < num_args; ++i)
|
||||
{
|
||||
bool success = false;
|
||||
|
@ -379,6 +388,8 @@ GetArgsMips64el(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args)
|
|||
|
||||
Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE);
|
||||
|
||||
Error error;
|
||||
|
||||
// get the current stack pointer
|
||||
uint64_t sp = ctx.reg_ctx->GetSP();
|
||||
|
||||
|
@ -402,7 +413,6 @@ GetArgsMips64el(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args)
|
|||
// clear all 64bits
|
||||
arg.value = 0;
|
||||
// read this argument from memory
|
||||
Error error;
|
||||
size_t bytes_read = ctx.process->ReadMemory(sp, &arg.value, arg_size, error);
|
||||
success = (error.Success() && bytes_read == arg_size);
|
||||
// advance the stack pointer
|
||||
|
@ -412,7 +422,8 @@ GetArgsMips64el(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args)
|
|||
if (!success)
|
||||
{
|
||||
if (log)
|
||||
log->Printf("%s - error reading argument: %" PRIu64, __FUNCTION__, uint64_t(i));
|
||||
log->Printf("%s - error reading argument: %" PRIu64", reason: %s",
|
||||
__FUNCTION__, uint64_t(i), error.AsCString("n/a"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue