Author: ewancrawford
Date: Thu Feb  4 03:44:23 2016
New Revision: 259773

URL: http://llvm.org/viewvc/llvm-project?rev=259773&view=rev
Log:
[RenderScript] Add command for recalculating allocation details

Patch replaces the --refresh flag removed in r258800 with it's own command, 
'language renderscript allocation refresh'.
Since there is no reason this functionality should be tied to another command 
as an option. 
The command itself simply re-JITs all our cached information about allocations.

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

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=259773&r1=259772&r2=259773&view=diff
==============================================================================
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Thu Feb  4 03:44:23 2016
@@ -2861,6 +2861,30 @@ RenderScriptRuntime::DumpAllocation(Stre
     return true;
 }
 
+// Function recalculates all our cached information about allocations by 
jitting the
+// RS runtime regarding each allocation we know about.
+// Returns true if all allocations could be recomputed, false otherwise.
+bool
+RenderScriptRuntime::RecomputeAllAllocations(Stream &strm, StackFrame 
*frame_ptr)
+{
+    bool success = true;
+    for (auto &alloc : m_allocations)
+    {
+        // JIT current allocation information
+        if (!RefreshAllocation(alloc.get(), frame_ptr))
+        {
+            strm.Printf("Error: Couldn't evaluate details for allocation %" 
PRIu32 "\n", alloc->id);
+            success = false;
+        }
+    }
+
+    if (success)
+        strm.Printf("All allocations successfully recomputed");
+    strm.EOL();
+
+    return success;
+}
+
 // Prints information regarding currently loaded allocations.
 // These details are gathered by jitting the runtime, which has as latency.
 // Index parameter specifies a single allocation ID to print, or a zero value 
to print them all
@@ -4036,6 +4060,39 @@ public:
     }
 };
 
+class CommandObjectRenderScriptRuntimeAllocationRefresh : public 
CommandObjectParsed
+{
+public:
+    CommandObjectRenderScriptRuntimeAllocationRefresh(CommandInterpreter 
&interpreter)
+        : CommandObjectParsed(interpreter, "renderscript allocation refresh",
+                              "Recomputes the details of all allocations.", 
"renderscript allocation refresh",
+                              eCommandRequiresProcess | 
eCommandProcessMustBeLaunched)
+    {
+    }
+
+    ~CommandObjectRenderScriptRuntimeAllocationRefresh() override = default;
+
+    bool
+    DoExecute(Args &command, CommandReturnObject &result) override
+    {
+        RenderScriptRuntime *runtime = static_cast<RenderScriptRuntime *>(
+            
m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript));
+
+        bool success = 
runtime->RecomputeAllAllocations(result.GetOutputStream(), 
m_exe_ctx.GetFramePtr());
+
+        if (success)
+        {
+            result.SetStatus(eReturnStatusSuccessFinishResult);
+            return true;
+        }
+        else
+        {
+            result.SetStatus(eReturnStatusFailed);
+            return false;
+        }
+    }
+};
+
 class CommandObjectRenderScriptRuntimeAllocation : public 
CommandObjectMultiword
 {
 public:
@@ -4047,6 +4104,7 @@ public:
         LoadSubCommand("dump", CommandObjectSP(new 
CommandObjectRenderScriptRuntimeAllocationDump(interpreter)));
         LoadSubCommand("save", CommandObjectSP(new 
CommandObjectRenderScriptRuntimeAllocationSave(interpreter)));
         LoadSubCommand("load", CommandObjectSP(new 
CommandObjectRenderScriptRuntimeAllocationLoad(interpreter)));
+        LoadSubCommand("refresh", CommandObjectSP(new 
CommandObjectRenderScriptRuntimeAllocationRefresh(interpreter)));
     }
 
     ~CommandObjectRenderScriptRuntimeAllocation() override = default;

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h?rev=259773&r1=259772&r2=259773&view=diff
==============================================================================
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
 Thu Feb  4 03:44:23 2016
@@ -209,6 +209,9 @@ public:
     void
     ListAllocations(Stream &strm, StackFrame *frame_ptr, const uint32_t index);
 
+    bool
+    RecomputeAllAllocations(Stream &strm, StackFrame *frame_ptr);
+
     void
     PlaceBreakpointOnKernel(Stream &strm, const char *name, const 
std::array<int, 3> coords, Error &error,
                             lldb::TargetSP target);


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to