Coverage Report

Created: 2022-01-18 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp
Line
Count
Source (jump to first uncovered line)
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
9
#include "lldb/Breakpoint/StoppointCallbackContext.h"
10
#include "lldb/Core/Debugger.h"
11
#include "lldb/Core/PluginManager.h"
12
#include "lldb/Interpreter/CommandInterpreter.h"
13
#include "lldb/Interpreter/CommandObjectMultiword.h"
14
#include "lldb/Interpreter/CommandReturnObject.h"
15
#include "lldb/Interpreter/Options.h"
16
#include "lldb/Symbol/Symbol.h"
17
#include "lldb/Symbol/Type.h"
18
#include "lldb/Symbol/VariableList.h"
19
#include "lldb/Target/Process.h"
20
#include "lldb/Target/Target.h"
21
#include "lldb/Utility/Args.h"
22
#include "lldb/Utility/ConstString.h"
23
#include "lldb/Utility/Log.h"
24
#include "lldb/Utility/Status.h"
25
26
#include "RenderScriptRuntime.h"
27
#include "RenderScriptScriptGroup.h"
28
29
using namespace lldb;
30
using namespace lldb_private;
31
using namespace lldb_renderscript;
32
33
class CommandObjectRenderScriptScriptGroupBreakpointSet
34
    : public CommandObjectParsed {
35
public:
36
  CommandObjectRenderScriptScriptGroupBreakpointSet(
37
      CommandInterpreter &interpreter)
38
      : CommandObjectParsed(
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
5.94k
            eCommandRequiresProcess | eCommandProcessMustBeLaunched) {}
43
44
5.93k
  ~CommandObjectRenderScriptScriptGroupBreakpointSet() override = default;
45
46
0
  bool DoExecute(Args &command, CommandReturnObject &result) override {
47
0
    Stream &stream = result.GetOutputStream();
48
0
    RenderScriptRuntime *runtime = static_cast<RenderScriptRuntime *>(
49
0
        m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
50
0
            eLanguageTypeExtRenderScript));
51
0
    assert(runtime);
52
0
    auto &target = m_exe_ctx.GetTargetSP();
53
0
    bool stop_on_all = false;
54
0
    const llvm::StringRef long_stop_all("--stop-on-all"), short_stop_all("-a");
55
0
    std::vector<ConstString> sites;
56
0
    sites.reserve(command.GetArgumentCount());
57
0
    for (size_t i = 0; i < command.GetArgumentCount(); ++i) {
58
0
      const auto arg = command.GetArgumentAtIndex(i);
59
0
      if (long_stop_all == arg || short_stop_all == arg)
60
0
        stop_on_all = true;
61
0
      else
62
0
        sites.push_back(ConstString(arg));
63
0
    }
64
0
    for (const auto &name : sites) {
65
0
      runtime->PlaceBreakpointOnScriptGroup(target, stream, name, stop_on_all);
66
0
    }
67
0
    result.SetStatus(eReturnStatusSuccessFinishResult);
68
0
    return true;
69
0
  }
70
};
71
72
class CommandObjectRenderScriptScriptGroupBreakpoint
73
    : public CommandObjectMultiword {
74
public:
75
  CommandObjectRenderScriptScriptGroupBreakpoint(
76
      CommandInterpreter &interpreter)
77
      : CommandObjectMultiword(
78
            interpreter, "renderscript scriptgroup breakpoint",
79
            "Renderscript scriptgroup breakpoint interaction.",
80
            "renderscript scriptgroup breakpoint set [--stop-on-all/-a]"
81
            "<scriptgroup name> ...",
82
5.94k
            eCommandRequiresProcess | eCommandProcessMustBeLaunched) {
83
5.94k
    LoadSubCommand(
84
5.94k
        "set",
85
5.94k
        CommandObjectSP(new CommandObjectRenderScriptScriptGroupBreakpointSet(
86
5.94k
            interpreter)));
87
5.94k
  }
88
89
5.93k
  ~CommandObjectRenderScriptScriptGroupBreakpoint() override = default;
90
};
91
92
class CommandObjectRenderScriptScriptGroupList : public CommandObjectParsed {
93
public:
94
  CommandObjectRenderScriptScriptGroupList(CommandInterpreter &interpreter)
95
      : CommandObjectParsed(interpreter, "renderscript scriptgroup list",
96
                            "List all currently discovered script groups.",
97
                            "renderscript scriptgroup list",
98
                            eCommandRequiresProcess |
99
5.94k
                                eCommandProcessMustBeLaunched) {}
100
101
5.93k
  ~CommandObjectRenderScriptScriptGroupList() override = default;
102
103
0
  bool DoExecute(Args &command, CommandReturnObject &result) override {
104
0
    Stream &stream = result.GetOutputStream();
105
0
    RenderScriptRuntime *runtime = static_cast<RenderScriptRuntime *>(
106
0
        m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
107
0
            eLanguageTypeExtRenderScript));
108
0
    assert(runtime);
109
0
    const RSScriptGroupList &groups = runtime->GetScriptGroups();
110
    // print script group count
111
0
    stream.Printf("%" PRIu64 " script %s", uint64_t(groups.size()),
112
0
                  (groups.size() == 1) ? "group" : "groups");
113
0
    stream.EOL();
114
    // print script group details
115
0
    stream.IndentMore();
116
0
    for (const RSScriptGroupDescriptorSP &g : groups) {
117
0
      if (g) {
118
0
        stream.Indent();
119
        // script group name
120
0
        stream.Printf("%s", g->m_name.AsCString());
121
0
        stream.EOL();
122
        // print out the kernels
123
0
        stream.IndentMore();
124
0
        for (const auto &k : g->m_kernels) {
125
0
          stream.Indent();
126
0
          stream.Printf(". %s", k.m_name.AsCString());
127
0
          stream.EOL();
128
0
        }
129
0
        stream.IndentLess();
130
0
      }
131
0
    }
132
0
    stream.IndentLess();
133
0
    result.SetStatus(eReturnStatusSuccessFinishResult);
134
0
    return true;
135
0
  }
136
};
137
138
class CommandObjectRenderScriptScriptGroup : public CommandObjectMultiword {
139
public:
140
  CommandObjectRenderScriptScriptGroup(CommandInterpreter &interpreter)
141
      : CommandObjectMultiword(interpreter, "renderscript scriptgroup",
142
                               "Command set for interacting with scriptgroups.",
143
                               nullptr, eCommandRequiresProcess |
144
5.94k
                                            eCommandProcessMustBeLaunched) {
145
5.94k
    LoadSubCommand(
146
5.94k
        "breakpoint",
147
5.94k
        CommandObjectSP(
148
5.94k
            new CommandObjectRenderScriptScriptGroupBreakpoint(interpreter)));
149
5.94k
    LoadSubCommand(
150
5.94k
        "list", CommandObjectSP(
151
5.94k
                    new CommandObjectRenderScriptScriptGroupList(interpreter)));
152
5.94k
  }
153
154
5.93k
  ~CommandObjectRenderScriptScriptGroup() override = default;
155
};
156
157
lldb::CommandObjectSP NewCommandObjectRenderScriptScriptGroup(
158
5.94k
    lldb_private::CommandInterpreter &interpreter) {
159
5.94k
  return CommandObjectSP(new CommandObjectRenderScriptScriptGroup(interpreter));
160
5.94k
}