LLDB  mainline
CommandAlias.h
Go to the documentation of this file.
1 //===-- CommandAlias.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_COMMANDALIAS_H
10 #define LLDB_INTERPRETER_COMMANDALIAS_H
11 
12 #include <memory>
13 
15 #include "lldb/Utility/Args.h"
17 #include "lldb/lldb-forward.h"
18 
19 namespace lldb_private {
20 class CommandAlias : public CommandObject {
21 public:
22  typedef std::unique_ptr<CommandAlias> UniquePointer;
23 
24  CommandAlias(CommandInterpreter &interpreter, lldb::CommandObjectSP cmd_sp,
25  llvm::StringRef options_args, llvm::StringRef name,
26  llvm::StringRef help = llvm::StringRef(),
27  llvm::StringRef syntax = llvm::StringRef(), uint32_t flags = 0);
28 
29  void GetAliasExpansion(StreamString &help_string) const;
30 
31  bool IsValid() const { return m_underlying_command_sp && m_option_args_sp; }
32 
33  explicit operator bool() const { return IsValid(); }
34 
35  bool WantsRawCommandString() override;
36 
37  bool WantsCompletion() override;
38 
39  void HandleCompletion(CompletionRequest &request) override;
40 
41  void
43  OptionElementVector &opt_element_vector) override;
44 
45  Options *GetOptions() override;
46 
47  bool IsAlias() override { return true; }
48 
49  bool IsDashDashCommand() override;
50 
51  llvm::StringRef GetHelp() override;
52 
53  llvm::StringRef GetHelpLong() override;
54 
55  void SetHelp(llvm::StringRef str) override;
56 
57  void SetHelpLong(llvm::StringRef str) override;
58 
59  bool Execute(const char *args_string, CommandReturnObject &result) override;
60 
61  lldb::CommandObjectSP GetUnderlyingCommand() {
63  }
65  const char *GetOptionString() { return m_option_string.c_str(); }
66 
67  // this takes an alias - potentially nested (i.e. an alias to an alias) and
68  // expands it all the way to a non-alias command
69  std::pair<lldb::CommandObjectSP, OptionArgVectorSP> Desugar();
70 
71 protected:
72  bool IsNestedAlias();
73 
74 private:
75  lldb::CommandObjectSP m_underlying_command_sp;
79  bool m_did_set_help : 1;
81 };
82 } // namespace lldb_private
83 
84 #endif // LLDB_INTERPRETER_COMMANDALIAS_H
lldb_private::CommandAlias::GetOptions
Options * GetOptions() override
Definition: CommandAlias.cpp:131
lldb_private::CommandAlias::GetHelpLong
llvm::StringRef GetHelpLong() override
Definition: CommandAlias.cpp:240
lldb_private::CommandAlias::IsNestedAlias
bool IsNestedAlias()
Definition: CommandAlias.cpp:198
lldb_private::CommandAlias::IsDashDashCommand
bool IsDashDashCommand() override
Definition: CommandAlias.cpp:170
lldb_private::CommandAlias::m_is_dashdash_alias
LazyBool m_is_dashdash_alias
Definition: CommandAlias.h:78
lldb_private::CommandAlias::UniquePointer
std::unique_ptr< CommandAlias > UniquePointer
Definition: CommandAlias.h:22
lldb_private::CommandAlias::CommandAlias
CommandAlias(CommandInterpreter &interpreter, lldb::CommandObjectSP cmd_sp, llvm::StringRef options_args, llvm::StringRef name, llvm::StringRef help=llvm::StringRef(), llvm::StringRef syntax=llvm::StringRef(), uint32_t flags=0)
Definition: CommandAlias.cpp:77
lldb_private::LazyBool
LazyBool
Definition: lldb-private-enumerations.h:115
CompletionRequest.h
lldb_private::CommandAlias::IsValid
bool IsValid() const
Definition: CommandAlias.h:31
lldb_private::CommandAlias::WantsRawCommandString
bool WantsRawCommandString() override
Definition: CommandAlias.cpp:107
lldb_private::Options
Definition: Options.h:57
Args.h
lldb_private::CommandAlias::m_option_args_sp
OptionArgVectorSP m_option_args_sp
Definition: CommandAlias.h:77
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:221
lldb_private::CommandAlias::m_did_set_help
bool m_did_set_help
Definition: CommandAlias.h:79
lldb_private::OptionElementVector
std::vector< OptionArgElement > OptionElementVector
Definition: Options.h:42
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:38
lldb_private::CommandAlias::SetHelp
void SetHelp(llvm::StringRef str) override
Definition: CommandAlias.cpp:222
lldb_private::CommandAlias::GetHelp
llvm::StringRef GetHelp() override
Definition: CommandAlias.cpp:232
lldb_private::CommandAlias::GetOptionString
const char * GetOptionString()
Definition: CommandAlias.h:65
lldb_private::CommandAlias::m_option_string
std::string m_option_string
Definition: CommandAlias.h:76
lldb_private::CommandObject
Definition: CommandObject.h:67
lldb_private::CommandAlias
Definition: CommandAlias.h:20
lldb_private::CommandAlias::SetHelpLong
void SetHelpLong(llvm::StringRef str) override
Definition: CommandAlias.cpp:227
lldb_private::CommandAlias::HandleCompletion
void HandleCompletion(CompletionRequest &request) override
This default version handles calling option argument completions and then calls HandleArgumentComplet...
Definition: CommandAlias.cpp:119
lldb_private::CommandAlias::Execute
bool Execute(const char *args_string, CommandReturnObject &result) override
Definition: CommandAlias.cpp:137
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:25
uint32_t
CommandObject.h
lldb_private::CommandAlias::Desugar
std::pair< lldb::CommandObjectSP, OptionArgVectorSP > Desugar()
Definition: CommandAlias.cpp:204
lldb_private::CommandAlias::GetAliasExpansion
void GetAliasExpansion(StreamString &help_string) const
Definition: CommandAlias.cpp:142
lldb_private::CommandAlias::HandleArgumentCompletion
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
Definition: CommandAlias.cpp:124
lldb_private::CommandAlias::GetUnderlyingCommand
lldb::CommandObjectSP GetUnderlyingCommand()
Definition: CommandAlias.h:61
lldb-forward.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::CommandAlias::GetOptionArguments
OptionArgVectorSP GetOptionArguments() const
Definition: CommandAlias.h:64
lldb_private::CommandAlias::m_underlying_command_sp
lldb::CommandObjectSP m_underlying_command_sp
Definition: CommandAlias.h:75
lldb_private::CommandAlias::IsAlias
bool IsAlias() override
Definition: CommandAlias.h:47
lldb_private::CommandAlias::m_did_set_help_long
bool m_did_set_help_long
Definition: CommandAlias.h:80
lldb_private::CompletionRequest
Definition: CompletionRequest.h:100
lldb_private::OptionArgVectorSP
std::shared_ptr< OptionArgVector > OptionArgVectorSP
Definition: Options.h:29
lldb_private::CommandAlias::WantsCompletion
bool WantsCompletion() override
Definition: CommandAlias.cpp:113