[Lldb-commits] [lldb] r263130 - [Renderscript] Add stack argument reading code for Mipsel

Aidan Dodds via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 10 09:27:42 PST 2016


Author: aidandodds
Date: Thu Mar 10 11:27:41 2016
New Revision: 263130

URL: http://llvm.org/viewvc/llvm-project?rev=263130&view=rev
Log:
[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 at codeplay.com>

Modified:
    lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

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=263130&r1=263129&r2=263130&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp Thu Mar 10 11:27:41 2016
@@ -184,6 +184,8 @@ GetArgsX86_64(GetArgsCtx &ctx, ArgItem *
         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 *
             // 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 *
         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
 
     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
             // 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
         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 *
 
     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
 
     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
             // 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
         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;
         }
     }




More information about the lldb-commits mailing list