LLDB API Documentation

SBCommandInterpreter.h
Go to the documentation of this file.
1 //===-- SBCommandInterpreter.h ----------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLDB_SBCommandInterpreter_h_
11 #define LLDB_SBCommandInterpreter_h_
12 
13 #include "lldb/API/SBDefines.h"
14 #include "lldb/API/SBDebugger.h"
15 
16 namespace lldb {
17 
19 {
20 public:
21  enum
22  {
25  eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
28  };
29 
31 
34 
36 
37  static const char *
38  GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
39 
40  static const char *
41  GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type);
42 
43  bool
44  IsValid() const;
45 
46  bool
47  CommandExists (const char *cmd);
48 
49  bool
50  AliasExists (const char *cmd);
51 
53  GetBroadcaster ();
54 
55  static const char *
57 
58  bool
59  HasCommands ();
60 
61  bool
62  HasAliases ();
63 
64  bool
65  HasAliasOptions ();
66 
68  GetProcess ();
69 
71  GetDebugger ();
72 
74  AddMultiwordCommand (const char* name, const char* help);
75 
77  AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, const char* help);
78 
79  void
81 
82  void
84 
85  lldb::ReturnStatus
86  HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
87 
88  // The pointer based interface is not useful in SWIG, since the cursor & last_char arguments are string pointers INTO current_line
89  // and you can't do that in a scripting language interface in general...
90 
91  // In either case, the way this works is that the you give it a line and cursor position in the line. The function
92  // will return the number of completions. The matches list will contain number_of_completions + 1 elements. The first
93  // element is the common substring after the cursor position for all the matches. The rest of the elements are the
94  // matches. The first element is useful if you are emulating the common shell behavior where the tab completes
95  // to the string that is common among all the matches, then you should first check if the first element is non-empty,
96  // and if so just insert it and move the cursor to the end of the insertion. The next tab will return an empty
97  // common substring, and a list of choices (if any), at which point you should display the choices and let the user
98  // type further to disambiguate.
99 
100  int
101  HandleCompletion (const char *current_line,
102  const char *cursor,
103  const char *last_char,
104  int match_start_point,
105  int max_return_elements,
106  lldb::SBStringList &matches);
107 
108  int
109  HandleCompletion (const char *current_line,
110  uint32_t cursor_pos,
111  int match_start_point,
112  int max_return_elements,
113  lldb::SBStringList &matches);
114 
115  // Catch commands before they execute by registering a callback that will
116  // get called when the command gets executed. This allows GUI or command
117  // line interfaces to intercept a command and stop it from happening
118  bool
119  SetCommandOverrideCallback (const char *command_name,
120  lldb::CommandOverrideCallback callback,
121  void *baton);
122 
123  SBCommandInterpreter (lldb_private::CommandInterpreter *interpreter_ptr = NULL); // Access using SBDebugger::GetCommandInterpreter();
124 
125 protected:
126 
127  lldb_private::CommandInterpreter &
128  ref ();
129 
130  lldb_private::CommandInterpreter *
131  get ();
132 
133  void
134  reset (lldb_private::CommandInterpreter *);
135 private:
136  friend class SBDebugger;
137 
138  static void
139  InitializeSWIG ();
140 
141  lldb_private::CommandInterpreter *m_opaque_ptr;
142 };
143 
145 {
146 public:
147  virtual bool
148  DoExecute (lldb::SBDebugger debugger,
149  char** command,
151  {
152  return false;
153  }
154 
155  virtual
157  {}
158 };
159 
161 {
162 public:
163 
164  SBCommand ();
165 
166  bool
167  IsValid ();
168 
169  const char*
170  GetName ();
171 
172  const char*
173  GetHelp ();
174 
176  AddMultiwordCommand (const char* name, const char* help = NULL);
177 
179  AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help = NULL);
180 
181 private:
182 
183  friend class SBDebugger;
184  friend class SBCommandInterpreter;
185 
186  SBCommand (lldb::CommandObjectSP cmd_sp);
187 
188  lldb::CommandObjectSP m_opaque_sp;
189 };
190 
191 } // namespace lldb
192 
193 #endif // LLDB_SBCommandInterpreter_h_