LLDB mainline
RenderScriptScriptGroup.cpp
Go to the documentation of this file.
1//===-- RenderScriptScriptGroup.cpp ---------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "lldb/Core/Debugger.h"
16#include "lldb/Symbol/Symbol.h"
17#include "lldb/Symbol/Type.h"
19#include "lldb/Target/Process.h"
20#include "lldb/Target/Target.h"
21#include "lldb/Utility/Args.h"
23#include "lldb/Utility/Log.h"
24#include "lldb/Utility/Status.h"
25
26#include "RenderScriptRuntime.h"
28
29using namespace lldb;
30using namespace lldb_private;
31using namespace lldb_renderscript;
32
34 : public CommandObjectParsed {
35public:
37 CommandInterpreter &interpreter)
39 interpreter, "renderscript scriptgroup breakpoint set",
40 "Place a breakpoint on all kernels forming a script group.",
41 "renderscript scriptgroup breakpoint set <group_name>",
42 eCommandRequiresProcess | eCommandProcessMustBeLaunched) {
44 m_arguments.push_back({name_arg});
45 }
46
48
49 bool DoExecute(Args &command, CommandReturnObject &result) override {
50 Stream &stream = result.GetOutputStream();
51 RenderScriptRuntime *runtime = static_cast<RenderScriptRuntime *>(
54 assert(runtime);
55 auto &target = m_exe_ctx.GetTargetSP();
56 bool stop_on_all = false;
57 const llvm::StringRef long_stop_all("--stop-on-all"), short_stop_all("-a");
58 std::vector<ConstString> sites;
59 sites.reserve(command.GetArgumentCount());
60 for (size_t i = 0; i < command.GetArgumentCount(); ++i) {
61 const auto arg = command.GetArgumentAtIndex(i);
62 if (long_stop_all == arg || short_stop_all == arg)
63 stop_on_all = true;
64 else
65 sites.push_back(ConstString(arg));
66 }
67 for (const auto &name : sites) {
68 runtime->PlaceBreakpointOnScriptGroup(target, stream, name, stop_on_all);
69 }
71 return true;
72 }
73};
74
76 : public CommandObjectMultiword {
77public:
79 CommandInterpreter &interpreter)
81 interpreter, "renderscript scriptgroup breakpoint",
82 "Renderscript scriptgroup breakpoint interaction.",
83 "renderscript scriptgroup breakpoint set [--stop-on-all/-a]"
84 "<scriptgroup name> ...",
85 eCommandRequiresProcess | eCommandProcessMustBeLaunched) {
87 "set",
89 interpreter)));
90 }
91
93};
94
96public:
98 : CommandObjectParsed(interpreter, "renderscript scriptgroup list",
99 "List all currently discovered script groups.",
100 "renderscript scriptgroup list",
101 eCommandRequiresProcess |
102 eCommandProcessMustBeLaunched) {}
103
105
106 bool DoExecute(Args &command, CommandReturnObject &result) override {
107 Stream &stream = result.GetOutputStream();
108 RenderScriptRuntime *runtime = static_cast<RenderScriptRuntime *>(
111 assert(runtime);
112 const RSScriptGroupList &groups = runtime->GetScriptGroups();
113 // print script group count
114 stream.Printf("%" PRIu64 " script %s", uint64_t(groups.size()),
115 (groups.size() == 1) ? "group" : "groups");
116 stream.EOL();
117 // print script group details
118 stream.IndentMore();
119 for (const RSScriptGroupDescriptorSP &g : groups) {
120 if (g) {
121 stream.Indent();
122 // script group name
123 stream.Printf("%s", g->m_name.AsCString());
124 stream.EOL();
125 // print out the kernels
126 stream.IndentMore();
127 for (const auto &k : g->m_kernels) {
128 stream.Indent();
129 stream.Printf(". %s", k.m_name.AsCString());
130 stream.EOL();
131 }
132 stream.IndentLess();
133 }
134 }
135 stream.IndentLess();
137 return true;
138 }
139};
140
142public:
144 : CommandObjectMultiword(interpreter, "renderscript scriptgroup",
145 "Command set for interacting with scriptgroups.",
146 nullptr, eCommandRequiresProcess |
147 eCommandProcessMustBeLaunched) {
149 "breakpoint",
150 CommandObjectSP(
153 "list", CommandObjectSP(
155 }
156
158};
159
162 return CommandObjectSP(new CommandObjectRenderScriptScriptGroup(interpreter));
163}
lldb::CommandObjectSP NewCommandObjectRenderScriptScriptGroup(lldb_private::CommandInterpreter &interpreter)
bool DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectRenderScriptScriptGroupBreakpointSet() override=default
CommandObjectRenderScriptScriptGroupBreakpointSet(CommandInterpreter &interpreter)
CommandObjectRenderScriptScriptGroupBreakpoint(CommandInterpreter &interpreter)
~CommandObjectRenderScriptScriptGroupBreakpoint() override=default
bool DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectRenderScriptScriptGroupList() override=default
CommandObjectRenderScriptScriptGroupList(CommandInterpreter &interpreter)
CommandObjectRenderScriptScriptGroup(CommandInterpreter &interpreter)
~CommandObjectRenderScriptScriptGroup() override=default
A command line argument class.
Definition: Args.h:33
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition: Args.h:116
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
Definition: Args.cpp:264
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
ExecutionContext m_exe_ctx
std::vector< CommandArgumentEntry > m_arguments
void SetStatus(lldb::ReturnStatus status)
A uniqued constant string class.
Definition: ConstString.h:39
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
Process * GetProcessPtr() const
Returns a pointer to the process object.
LanguageRuntime * GetLanguageRuntime(lldb::LanguageType language)
Definition: Process.cpp:1513
const lldb_renderscript::RSScriptGroupList & GetScriptGroups() const
bool PlaceBreakpointOnScriptGroup(lldb::TargetSP target, Stream &strm, ConstString name, bool stop_on_all)
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:130
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition: Stream.cpp:171
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition: Stream.cpp:168
std::shared_ptr< RSScriptGroupDescriptor > RSScriptGroupDescriptorSP
std::vector< RSScriptGroupDescriptorSP > RSScriptGroupList
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
@ eLanguageTypeExtRenderScript
RenderScript.
@ eReturnStatusSuccessFinishResult
Used to build individual command argument lists.
Definition: CommandObject.h:93