[Lldb-commits] [lldb] r258800 - [RenderScript] Provide option to specify a single allocation to print

Ewan Crawford via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 26 02:41:10 PST 2016


Author: ewancrawford
Date: Tue Jan 26 04:41:08 2016
New Revision: 258800

URL: http://llvm.org/viewvc/llvm-project?rev=258800&view=rev
Log:
[RenderScript] Provide option to specify a single allocation to print

Patch replaces the 'renderscript allocation list' command flag --refresh, with a new option --id <ID>.
This new option only prints the details of a single allocation with a given id, rather than printing all the allocations.
Functionality from the removed '--refresh' flag will be moved into its own command in a subsequent commit.

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=258800&r1=258799&r2=258800&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp Tue Jan 26 04:41:08 2016
@@ -2870,10 +2870,11 @@ RenderScriptRuntime::DumpAllocation(Stre
     return true;
 }
 
-// Prints infomation regarding all the currently loaded allocations.
+// 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
 void
-RenderScriptRuntime::ListAllocations(Stream &strm, StackFrame* frame_ptr, bool recompute)
+RenderScriptRuntime::ListAllocations(Stream &strm, StackFrame *frame_ptr, const uint32_t index)
 {
     strm.Printf("RenderScript Allocations:");
     strm.EOL();
@@ -2881,13 +2882,14 @@ RenderScriptRuntime::ListAllocations(Str
 
     for (auto &alloc : m_allocations)
     {
-        // JIT the allocation info if we haven't done it, or the user forces us to.
-        bool do_refresh = alloc->shouldRefresh() || recompute;
+        // index will only be zero if we want to print all allocations
+        if (index != 0 && index != alloc->id)
+            continue;
 
         // JIT current allocation information
-        if (do_refresh && !RefreshAllocation(alloc.get(), frame_ptr))
+        if (alloc->shouldRefresh() && !RefreshAllocation(alloc.get(), frame_ptr))
         {
-            strm.Printf("Error: Couldn't evaluate details for allocation %u\n", alloc->id);
+            strm.Printf("Error: Couldn't evaluate details for allocation %" PRIu32 "\n", alloc->id);
             continue;
         }
 
@@ -3926,9 +3928,7 @@ public:
     class CommandOptions : public Options
     {
     public:
-        CommandOptions(CommandInterpreter &interpreter) : Options(interpreter), m_refresh(false)
-        {
-        }
+        CommandOptions(CommandInterpreter &interpreter) : Options(interpreter), m_id(0) {}
 
         ~CommandOptions() override = default;
 
@@ -3940,8 +3940,11 @@ public:
 
             switch (short_option)
             {
-                case 'r':
-                    m_refresh = true;
+                case 'i':
+                    bool success;
+                    m_id = StringConvert::ToUInt32(option_arg, 0, 0, &success);
+                    if (!success)
+                        error.SetErrorStringWithFormat("invalid integer value for option '%c'", short_option);
                     break;
                 default:
                     error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
@@ -3953,7 +3956,7 @@ public:
         void
         OptionParsingStarting() override
         {
-            m_refresh = false;
+            m_id = 0;
         }
 
         const OptionDefinition*
@@ -3963,7 +3966,7 @@ public:
         }
 
         static OptionDefinition g_option_table[];
-        bool m_refresh;
+        uint32_t m_id;
     };
 
     bool
@@ -3971,7 +3974,7 @@ public:
     {
         RenderScriptRuntime *runtime =
           static_cast<RenderScriptRuntime *>(m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript));
-        runtime->ListAllocations(result.GetOutputStream(), m_exe_ctx.GetFramePtr(), m_options.m_refresh);
+        runtime->ListAllocations(result.GetOutputStream(), m_exe_ctx.GetFramePtr(), m_options.m_id);
         result.SetStatus(eReturnStatusSuccessFinishResult);
         return true;
     }
@@ -3980,13 +3983,10 @@ private:
     CommandOptions m_options;
 };
 
-OptionDefinition
-CommandObjectRenderScriptRuntimeAllocationList::CommandOptions::g_option_table[] =
-{
-    { LLDB_OPT_SET_1, false, "refresh", 'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
-      "Recompute allocation details."},
-    { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
-};
+OptionDefinition CommandObjectRenderScriptRuntimeAllocationList::CommandOptions::g_option_table[] = {
+    {LLDB_OPT_SET_1, false, "id", 'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeIndex,
+     "Only show details of a single allocation with specified id."},
+    {0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL}};
 
 class CommandObjectRenderScriptRuntimeAllocationLoad : public CommandObjectParsed
 {

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=258800&r1=258799&r2=258800&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h Tue Jan 26 04:41:08 2016
@@ -199,7 +199,8 @@ public:
 
     bool DumpAllocation(Stream &strm, StackFrame* frame_ptr, const uint32_t id);
 
-    void ListAllocations(Stream &strm, StackFrame* frame_ptr, bool recompute);
+    void
+    ListAllocations(Stream &strm, StackFrame *frame_ptr, const uint32_t index);
 
     void PlaceBreakpointOnKernel(Stream &strm, const char *name, const std::array<int,3> coords,
                                  Error &error, lldb::TargetSP target);




More information about the lldb-commits mailing list