Skip to content

Commit

Permalink
[RenderScript] Provide option to specify a single allocation to print
Browse files Browse the repository at this point in the history
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.

llvm-svn: 258800
  • Loading branch information
EwanC committed Jan 26, 2016
1 parent f2cdd14 commit b649b00
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
Expand Up @@ -2870,24 +2870,26 @@ RenderScriptRuntime::DumpAllocation(Stream &strm, StackFrame* frame_ptr, const u
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();
strm.IndentMore();

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;
}

Expand Down Expand Up @@ -3926,9 +3928,7 @@ class CommandObjectRenderScriptRuntimeAllocationList : public CommandObjectParse
class CommandOptions : public Options
{
public:
CommandOptions(CommandInterpreter &interpreter) : Options(interpreter), m_refresh(false)
{
}
CommandOptions(CommandInterpreter &interpreter) : Options(interpreter), m_id(0) {}

~CommandOptions() override = default;

Expand All @@ -3940,8 +3940,11 @@ class CommandObjectRenderScriptRuntimeAllocationList : public CommandObjectParse

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);
Expand All @@ -3953,7 +3956,7 @@ class CommandObjectRenderScriptRuntimeAllocationList : public CommandObjectParse
void
OptionParsingStarting() override
{
m_refresh = false;
m_id = 0;
}

const OptionDefinition*
Expand All @@ -3963,15 +3966,15 @@ class CommandObjectRenderScriptRuntimeAllocationList : public CommandObjectParse
}

static OptionDefinition g_option_table[];
bool m_refresh;
uint32_t m_id;
};

bool
DoExecute(Args &command, CommandReturnObject &result) override
{
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;
}
Expand All @@ -3980,13 +3983,10 @@ class CommandObjectRenderScriptRuntimeAllocationList : public CommandObjectParse
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
{
Expand Down
Expand Up @@ -199,7 +199,8 @@ class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime

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);
Expand Down

0 comments on commit b649b00

Please sign in to comment.