Coverage Report

Created: 2022-07-16 07:03

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
Line
Count
Source
1
//===-- CommandObjectMultiword.h --------------------------------*- C++ -*-===//
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
#ifndef LLDB_INTERPRETER_COMMANDOBJECTMULTIWORD_H
10
#define LLDB_INTERPRETER_COMMANDOBJECTMULTIWORD_H
11
12
#include "lldb/Interpreter/CommandObject.h"
13
#include "lldb/Utility/CompletionRequest.h"
14
15
namespace lldb_private {
16
17
// CommandObjectMultiword
18
19
class CommandObjectMultiword : public CommandObject {
20
  // These two want to iterate over the subcommand dictionary.
21
  friend class CommandInterpreter;
22
  friend class CommandObjectSyntax;
23
24
public:
25
  CommandObjectMultiword(CommandInterpreter &interpreter, const char *name,
26
                         const char *help = nullptr,
27
                         const char *syntax = nullptr, uint32_t flags = 0);
28
29
  ~CommandObjectMultiword() override;
30
31
290k
  bool IsMultiwordObject() override { return true; }
32
33
483
  CommandObjectMultiword *GetAsMultiwordCommand() override { return this; }
34
35
  bool LoadSubCommand(llvm::StringRef cmd_name,
36
                      const lldb::CommandObjectSP &command_obj) override;
37
38
  llvm::Error LoadUserSubcommand(llvm::StringRef cmd_name,
39
                                 const lldb::CommandObjectSP &command_obj,
40
                                 bool can_replace) override;
41
42
  llvm::Error RemoveUserSubcommand(llvm::StringRef cmd_name, bool multiword_okay);
43
44
  void GenerateHelpText(Stream &output_stream) override;
45
46
  lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
47
                                        StringList *matches = nullptr) override;
48
49
  lldb::CommandObjectSP GetSubcommandSPExact(llvm::StringRef sub_cmd) override;
50
51
  CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
52
                                     StringList *matches = nullptr) override;
53
54
70.4k
  bool WantsRawCommandString() override { return false; }
55
56
  void HandleCompletion(CompletionRequest &request) override;
57
58
  llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
59
                                               uint32_t index) override;
60
61
  bool Execute(const char *args_string, CommandReturnObject &result) override;
62
63
21
  bool IsRemovable() const override { return m_can_be_removed; }
64
65
3
  void SetRemovable(bool removable) { m_can_be_removed = removable; }
66
67
protected:
68
445
  CommandObject::CommandMap &GetSubcommandDictionary() {
69
445
    return m_subcommand_dict;
70
445
  }
71
72
  CommandObject::CommandMap m_subcommand_dict;
73
  bool m_can_be_removed;
74
};
75
76
class CommandObjectProxy : public CommandObject {
77
public:
78
  CommandObjectProxy(CommandInterpreter &interpreter, const char *name,
79
                     const char *help = nullptr, const char *syntax = nullptr,
80
                     uint32_t flags = 0);
81
82
  ~CommandObjectProxy() override;
83
84
  // Subclasses must provide a command object that will be transparently used
85
  // for this object.
86
  virtual CommandObject *GetProxyCommandObject() = 0;
87
88
  llvm::StringRef GetSyntax() override;
89
90
  llvm::StringRef GetHelp() override;
91
92
  llvm::StringRef GetHelpLong() override;
93
94
  bool IsRemovable() const override;
95
96
  bool IsMultiwordObject() override;
97
98
  CommandObjectMultiword *GetAsMultiwordCommand() override;
99
100
  void GenerateHelpText(Stream &result) override;
101
102
  lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
103
                                        StringList *matches = nullptr) override;
104
105
  CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
106
                                     StringList *matches = nullptr) override;
107
108
  bool LoadSubCommand(llvm::StringRef cmd_name,
109
                      const lldb::CommandObjectSP &command_obj) override;
110
111
  bool WantsRawCommandString() override;
112
113
  bool WantsCompletion() override;
114
115
  Options *GetOptions() override;
116
117
  void HandleCompletion(CompletionRequest &request) override;
118
119
  void
120
  HandleArgumentCompletion(CompletionRequest &request,
121
                           OptionElementVector &opt_element_vector) override;
122
123
  llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
124
                                               uint32_t index) override;
125
126
  /// \return
127
  ///     An error message to be displayed when the command is executed (i.e.
128
  ///     Execute is called) and \a GetProxyCommandObject returned null.
129
  virtual llvm::StringRef GetUnsupportedError();
130
131
  bool Execute(const char *args_string, CommandReturnObject &result) override;
132
133
protected:
134
  // These two want to iterate over the subcommand dictionary.
135
  friend class CommandInterpreter;
136
  friend class CommandObjectSyntax;
137
};
138
139
} // namespace lldb_private
140
141
#endif // LLDB_INTERPRETER_COMMANDOBJECTMULTIWORD_H