[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
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index bad04d8..d636178 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -184,6 +184,8 @@
         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 @@
             // 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 @@
         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 @@
 
     Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE);
 
+    Error error;
+
     // get the current stack pointer
     uint64_t sp = ctx.reg_ctx->GetSP();
 
@@ -275,7 +279,6 @@
             // 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 @@
         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 @@
 
     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 @@
 
     Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE);
 
+    Error error;
+
     // get the current stack pointer
     uint64_t sp = ctx.reg_ctx->GetSP();
 
@@ -402,7 +413,6 @@
             // 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 @@
         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;
         }
     }