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 
29 using namespace lldb;
30 using namespace lldb_private;
31 using namespace lldb_renderscript;
32 
34  : public CommandObjectParsed {
35 public:
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) {}
43 
45 
46  bool DoExecute(Args &command, CommandReturnObject &result) override {
47  Stream &stream = result.GetOutputStream();
48  RenderScriptRuntime *runtime = static_cast<RenderScriptRuntime *>(
49  m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
51  assert(runtime);
52  auto &target = m_exe_ctx.GetTargetSP();
53  bool stop_on_all = false;
54  const llvm::StringRef long_stop_all("--stop-on-all"), short_stop_all("-a");
55  std::vector<ConstString> sites;
56  sites.reserve(command.GetArgumentCount());
57  for (size_t i = 0; i < command.GetArgumentCount(); ++i) {
58  const auto arg = command.GetArgumentAtIndex(i);
59  if (long_stop_all == arg || short_stop_all == arg)
60  stop_on_all = true;
61  else
62  sites.push_back(ConstString(arg));
63  }
64  for (const auto &name : sites) {
65  runtime->PlaceBreakpointOnScriptGroup(target, stream, name, stop_on_all);
66  }
68  return true;
69  }
70 };
71 
73  : public CommandObjectMultiword {
74 public:
76  CommandInterpreter &interpreter)
78  interpreter, "renderscript scriptgroup breakpoint",
79  "Renderscript scriptgroup breakpoint interaction.",
80  "renderscript scriptgroup breakpoint set [--stop-on-all/-a]"
81  "<scriptgroup name> ...",
82  eCommandRequiresProcess | eCommandProcessMustBeLaunched) {
83  LoadSubCommand(
84  "set",
86  interpreter)));
87  }
88 
90 };
91 
93 public:
95  : CommandObjectParsed(interpreter, "renderscript scriptgroup list",
96  "List all currently discovered script groups.",
97  "renderscript scriptgroup list",
98  eCommandRequiresProcess |
99  eCommandProcessMustBeLaunched) {}
100 
101  ~CommandObjectRenderScriptScriptGroupList() override = default;
102 
103  bool DoExecute(Args &command, CommandReturnObject &result) override {
104  Stream &stream = result.GetOutputStream();
105  RenderScriptRuntime *runtime = static_cast<RenderScriptRuntime *>(
106  m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
108  assert(runtime);
109  const RSScriptGroupList &groups = runtime->GetScriptGroups();
110  // print script group count
111  stream.Printf("%" PRIu64 " script %s", uint64_t(groups.size()),
112  (groups.size() == 1) ? "group" : "groups");
113  stream.EOL();
114  // print script group details
115  stream.IndentMore();
116  for (const RSScriptGroupDescriptorSP &g : groups) {
117  if (g) {
118  stream.Indent();
119  // script group name
120  stream.Printf("%s", g->m_name.AsCString());
121  stream.EOL();
122  // print out the kernels
123  stream.IndentMore();
124  for (const auto &k : g->m_kernels) {
125  stream.Indent();
126  stream.Printf(". %s", k.m_name.AsCString());
127  stream.EOL();
128  }
129  stream.IndentLess();
130  }
131  }
132  stream.IndentLess();
134  return true;
135  }
136 };
137 
139 public:
141  : CommandObjectMultiword(interpreter, "renderscript scriptgroup",
142  "Command set for interacting with scriptgroups.",
143  nullptr, eCommandRequiresProcess |
144  eCommandProcessMustBeLaunched) {
145  LoadSubCommand(
146  "breakpoint",
147  CommandObjectSP(
149  LoadSubCommand(
150  "list", CommandObjectSP(
151  new CommandObjectRenderScriptScriptGroupList(interpreter)));
152  }
153 
154  ~CommandObjectRenderScriptScriptGroup() override = default;
155 };
156 
158  lldb_private::CommandInterpreter &interpreter) {
159  return CommandObjectSP(new CommandObjectRenderScriptScriptGroup(interpreter));
160 }
lldb_private::Stream::IndentLess
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition: Stream.cpp:171
lldb_private::CommandObjectParsed
Definition: CommandObject.h:394
lldb_private::RenderScriptRuntime
Definition: RenderScriptRuntime.h:298
NewCommandObjectRenderScriptScriptGroup
lldb::CommandObjectSP NewCommandObjectRenderScriptScriptGroup(lldb_private::CommandInterpreter &interpreter)
Definition: RenderScriptScriptGroup.cpp:157
StoppointCallbackContext.h
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Args
Definition: Args.h:33
CommandReturnObject.h
Debugger.h
Process.h
Target.h
lldb_private::CommandObjectMultiword
Definition: CommandObjectMultiword.h:19
Options.h
lldb_private::Stream::Indent
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:130
Log.h
CommandObjectRenderScriptScriptGroupBreakpoint
Definition: RenderScriptScriptGroup.cpp:72
Args.h
lldb_private::CommandReturnObject::SetStatus
void SetStatus(lldb::ReturnStatus status)
Definition: CommandReturnObject.cpp:121
lldb_private::RenderScriptRuntime::GetScriptGroups
const lldb_renderscript::RSScriptGroupList & GetScriptGroups() const
Definition: RenderScriptRuntime.h:398
Type.h
lldb_private::CommandReturnObject::GetOutputStream
Stream & GetOutputStream()
Definition: CommandReturnObject.h:45
lldb_private::ConstString
Definition: ConstString.h:40
RenderScriptRuntime.h
CommandObjectRenderScriptScriptGroupBreakpointSet::CommandObjectRenderScriptScriptGroupBreakpointSet
CommandObjectRenderScriptScriptGroupBreakpointSet(CommandInterpreter &interpreter)
Definition: RenderScriptScriptGroup.cpp:36
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
CommandObjectMultiword.h
CommandObjectRenderScriptScriptGroupList
Definition: RenderScriptScriptGroup.cpp:92
VariableList.h
lldb_private::RenderScriptRuntime::PlaceBreakpointOnScriptGroup
bool PlaceBreakpointOnScriptGroup(lldb::TargetSP target, Stream &strm, ConstString name, bool stop_on_all)
Definition: RenderScriptRuntime.cpp:3776
CommandObjectRenderScriptScriptGroup::CommandObjectRenderScriptScriptGroup
CommandObjectRenderScriptScriptGroup(CommandInterpreter &interpreter)
Definition: RenderScriptScriptGroup.cpp:140
Symbol.h
lldb_private::lldb_renderscript::RSScriptGroupList
std::vector< RSScriptGroupDescriptorSP > RSScriptGroupList
Definition: RenderScriptRuntime.h:249
lldb_private::Args::GetArgumentAtIndex
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
Definition: Args.cpp:259
CommandObjectRenderScriptScriptGroupBreakpointSet::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: RenderScriptScriptGroup.cpp:46
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:25
lldb::eLanguageTypeExtRenderScript
@ eLanguageTypeExtRenderScript
RenderScript.
Definition: lldb-enumerations.h:481
lldb_private::Stream::IndentMore
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition: Stream.cpp:168
lldb::eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishResult
Definition: lldb-enumerations.h:261
CommandObjectRenderScriptScriptGroupList::CommandObjectRenderScriptScriptGroupList
CommandObjectRenderScriptScriptGroupList(CommandInterpreter &interpreter)
Definition: RenderScriptScriptGroup.cpp:94
lldb_private::Stream::EOL
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
RenderScriptScriptGroup.h
CommandObjectRenderScriptScriptGroupBreakpoint::CommandObjectRenderScriptScriptGroupBreakpoint
CommandObjectRenderScriptScriptGroupBreakpoint(CommandInterpreter &interpreter)
Definition: RenderScriptScriptGroup.cpp:75
PluginManager.h
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
Status.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
CommandInterpreter.h
ConstString.h
CommandObjectRenderScriptScriptGroupList::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: RenderScriptScriptGroup.cpp:103
lldb_private::lldb_renderscript::RSScriptGroupDescriptorSP
std::shared_ptr< RSScriptGroupDescriptor > RSScriptGroupDescriptorSP
Definition: RenderScriptRuntime.h:44
lldb_private::Args::GetArgumentCount
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition: Args.h:118
lldb
Definition: SBAddress.h:15
CommandObjectRenderScriptScriptGroup
Definition: RenderScriptScriptGroup.cpp:138
CommandObjectRenderScriptScriptGroupBreakpointSet
Definition: RenderScriptScriptGroup.cpp:33