LLVM: SBCommandInterpreter.h Source File
Description: C++ source code API documentation for LLDB.
Keywords: LLDB,C++,doxygen,API,documentation

LLDB API Documentation

- Main Page
- Namespaces
- Classes
- Files

- File List

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 // C Includes
14 // C++ Includes
15 #include <memory>
16
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/API/SBDebugger.h"
20 #include "lldb/API/SBDefines.h"
21
22 namespace lldb {
23
24 class LLDB_API SBCommandInterpreterRunOptions {
25 friend class SBDebugger;
26 friend class SBCommandInterpreter;
27
28 public:
29 SBCommandInterpreterRunOptions();
30 ~SBCommandInterpreterRunOptions();
31
32 bool GetStopOnContinue() const;
33
34 void SetStopOnContinue(bool);
35
36 bool GetStopOnError() const;
37
38 void SetStopOnError(bool);
39
40 bool GetStopOnCrash() const;
41
42 void SetStopOnCrash(bool);
43
44 bool GetEchoCommands() const;
45
46 void SetEchoCommands(bool);
47
48 bool GetPrintResults() const;
49
50 void SetPrintResults(bool);
51
52 bool GetAddToHistory() const;
53
54 void SetAddToHistory(bool);
55
56 private:
57 lldb_private::CommandInterpreterRunOptions *get() const;
58
59 lldb_private::CommandInterpreterRunOptions &ref() const;
60
61 // This is set in the constructor and will always be valid.
62 mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions>
63 m_opaque_up;
64 };
65
66 class SBCommandInterpreter {
67 public:
68 enum {
69 eBroadcastBitThreadShouldExit = (1 << 0),
70 eBroadcastBitResetPrompt = (1 << 1),
71 eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
72 eBroadcastBitAsynchronousOutputData = (1 << 3),
73 eBroadcastBitAsynchronousErrorData = (1 << 4)
74 };
75
76 SBCommandInterpreter(const lldb::SBCommandInterpreter &rhs);
77
78 ~SBCommandInterpreter();
79
80 const lldb::SBCommandInterpreter &
81 operator=(const lldb::SBCommandInterpreter &rhs);
82
83 static const char *
84 GetArgumentTypeAsCString(const lldb::CommandArgumentType arg_type);
85
86 static const char *
87 GetArgumentDescriptionAsCString(const lldb::CommandArgumentType arg_type);
88
89 static bool EventIsCommandInterpreterEvent(const lldb::SBEvent &event);
90
91 bool IsValid() const;
92
93 bool CommandExists(const char *cmd);
94
95 bool AliasExists(const char *cmd);
96
97 lldb::SBBroadcaster GetBroadcaster();
98
99 static const char *GetBroadcasterClass();
100
101 bool HasCommands();
102
103 bool HasAliases();
104
105 bool HasAliasOptions();
106
107 lldb::SBProcess GetProcess();
108
109 lldb::SBDebugger GetDebugger();
110
111 lldb::SBCommand AddMultiwordCommand(const char *name, const char *help);
112
113 lldb::SBCommand AddCommand(const char *name,
114 lldb::SBCommandPluginInterface *impl,
115 const char *help);
116
117 lldb::SBCommand AddCommand(const char *name,
118 lldb::SBCommandPluginInterface *impl,
119 const char *help, const char *syntax);
120
121 void SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &result);
122
123 void
124 SourceInitFileInCurrentWorkingDirectory(lldb::SBCommandReturnObject &result);
125
126 lldb::ReturnStatus HandleCommand(const char *command_line,
127 lldb::SBCommandReturnObject &result,
128 bool add_to_history = false);
129
130 lldb::ReturnStatus HandleCommand(const char *command_line,
131 SBExecutionContext &exe_ctx,
132 SBCommandReturnObject &result,
133 bool add_to_history = false);
134
135 void HandleCommandsFromFile(lldb::SBFileSpec &file,
136 lldb::SBExecutionContext &override_context,
137 lldb::SBCommandInterpreterRunOptions &options,
138 lldb::SBCommandReturnObject result);
139
140 // The pointer based interface is not useful in SWIG, since the cursor &
141 // last_char arguments are string pointers INTO current_line
142 // and you can't do that in a scripting language interface in general...
143
144 // In either case, the way this works is that the you give it a line and
145 // cursor position in the line. The function
146 // will return the number of completions. The matches list will contain
147 // number_of_completions + 1 elements. The first
148 // element is the common substring after the cursor position for all the
149 // matches. The rest of the elements are the
150 // matches. The first element is useful if you are emulating the common shell
151 // behavior where the tab completes
152 // to the string that is common among all the matches, then you should first
153 // check if the first element is non-empty,
154 // and if so just insert it and move the cursor to the end of the insertion.
155 // The next tab will return an empty
156 // common substring, and a list of choices (if any), at which point you should
157 // display the choices and let the user
158 // type further to disambiguate.
159
160 int HandleCompletion(const char *current_line, const char *cursor,
161 const char *last_char, int match_start_point,
162 int max_return_elements, lldb::SBStringList &matches);
163
164 int HandleCompletion(const char *current_line, uint32_t cursor_pos,
165 int match_start_point, int max_return_elements,
166 lldb::SBStringList &matches);
167
168 // Catch commands before they execute by registering a callback that will
169 // get called when the command gets executed. This allows GUI or command
170 // line interfaces to intercept a command and stop it from happening
171 bool SetCommandOverrideCallback(const char *command_name,
172 lldb::CommandOverrideCallback callback,
173 void *baton);
174
175 SBCommandInterpreter(
176 lldb_private::CommandInterpreter *interpreter_ptr =
177 nullptr); // Access using SBDebugger::GetCommandInterpreter();
178
179 //----------------------------------------------------------------------
180 /// Return true if the command interpreter is the active IO handler.
181 ///
182 /// This indicates that any input coming into the debugger handles will
183 /// go to the command interpreter and will result in LLDB command line
184 /// commands being executed.
185 //----------------------------------------------------------------------
186 bool IsActive();
187
188 //----------------------------------------------------------------------
189 /// Get the string that needs to be written to the debugger stdin file
190 /// handle when a control character is typed.
191 ///
192 /// Some GUI programs will intercept "control + char" sequences and want
193 /// to have them do what normally would happen when using a real
194 /// terminal, so this function allows GUI programs to emulate this
195 /// functionality.
196 ///
197 /// @param[in] ch
198 /// The character that was typed along with the control key
199 ///
200 /// @return
201 /// The string that should be written into the file handle that is
202 /// feeding the input stream for the debugger, or nullptr if there is
203 /// no string for this control key.
204 //----------------------------------------------------------------------
205 const char *GetIOHandlerControlSequence(char ch);
206
207 bool GetPromptOnQuit();
208
209 void SetPromptOnQuit(bool b);
210
211 //----------------------------------------------------------------------
212 /// Resolve the command just as HandleCommand would, expanding abbreviations
213 /// and aliases. If successful, result->GetOutput has the full expansion.
214 //----------------------------------------------------------------------
215 void ResolveCommand(const char *command_line, SBCommandReturnObject &result);
216
217 protected:
218 lldb_private::CommandInterpreter &ref();
219
220 lldb_private::CommandInterpreter *get();
221
222 void reset(lldb_private::CommandInterpreter *);
223
224 private:
225 friend class SBDebugger;
226
227 static void InitializeSWIG();
228
229 lldb_private::CommandInterpreter *m_opaque_ptr;
230 };
231
232 class SBCommandPluginInterface {
233 public:
234 virtual ~SBCommandPluginInterface() = default;
235
236 virtual bool DoExecute(lldb::SBDebugger /*debugger*/, char ** /*command*/,
237 lldb::SBCommandReturnObject & /*result*/) {
238 return false;
239 }
240 };
241
242 class SBCommand {
243 public:
244 SBCommand();
245
246 bool IsValid();
247
248 const char *GetName();
249
250 const char *GetHelp();
251
252 const char *GetHelpLong();
253
254 void SetHelp(const char *);
255
256 void SetHelpLong(const char *);
257
258 uint32_t GetFlags();
259
260 void SetFlags(uint32_t flags);
261
262 lldb::SBCommand AddMultiwordCommand(const char *name,
263 const char *help = nullptr);
264
265 lldb::SBCommand AddCommand(const char *name,
266 lldb::SBCommandPluginInterface *impl,
267 const char *help = nullptr);
268
269 lldb::SBCommand AddCommand(const char *name,
270 lldb::SBCommandPluginInterface *impl,
271 const char *help, const char *syntax);
272
273 private:
274 friend class SBDebugger;
275 friend class SBCommandInterpreter;
276
277 SBCommand(lldb::CommandObjectSP cmd_sp);
278
279 lldb::CommandObjectSP m_opaque_sp;
280 };
281
282 } // namespace lldb
283
284 #endif // LLDB_SBCommandInterpreter_h_
lldb::SBCommandInterpreter::EventIsCommandInterpreterEvent
static bool EventIsCommandInterpreterEvent(const lldb::SBEvent &event)
lldb::SBBroadcaster
Definition: SBBroadcaster.h:17
lldb::SBCommandInterpreter::GetProcess
lldb::SBProcess GetProcess()
lldb::SBCommandInterpreter::HasAliasOptions
bool HasAliasOptions()
lldb::SBCommandInterpreter::GetArgumentDescriptionAsCString
static const char * GetArgumentDescriptionAsCString(const lldb::CommandArgumentType arg_type)
lldb::SBCommandInterpreter::SetCommandOverrideCallback
bool SetCommandOverrideCallback(const char *command_name, lldb::CommandOverrideCallback callback, void *baton)
lldb::SBCommandInterpreter::HasAliases
bool HasAliases()
lldb::SBCommandInterpreter::AliasExists
bool AliasExists(const char *cmd)
lldb::SBCommandInterpreter::SBCommandInterpreter
SBCommandInterpreter(const lldb::SBCommandInterpreter &rhs)
lldb::SBCommandInterpreter::GetBroadcasterClass
static const char * GetBroadcasterClass()
SBDefines.h
lldb::SBCommandInterpreter::eBroadcastBitResetPrompt
Definition: SBCommandInterpreter.h:70
lldb::SBCommandInterpreter::CommandExists
bool CommandExists(const char *cmd)
lldb::SBCommand
class LLDB_API SBCommand
Definition: SBDefines.h:36
lldb::SBCommandInterpreter::eBroadcastBitThreadShouldExit
Definition: SBCommandInterpreter.h:69
lldb::SBCommandInterpreter
Definition: SBCommandInterpreter.h:66
lldb::SBCommandInterpreter::eBroadcastBitQuitCommandReceived
Definition: SBCommandInterpreter.h:71
lldb::SBCommandInterpreter::AddCommand
lldb::SBCommand AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help)
lldb::SBCommandInterpreter::HandleCommand
lldb::ReturnStatus HandleCommand(const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history=false)
lldb::SBCommandInterpreter::~SBCommandInterpreter
~SBCommandInterpreter()
lldb::SBCommandInterpreterRunOptions
class LLDB_API SBCommandInterpreterRunOptions
Definition: SBDefines.h:38
lldb::SBCommandInterpreter::HandleCommandsFromFile
void HandleCommandsFromFile(lldb::SBFileSpec &file, lldb::SBExecutionContext &override_context, lldb::SBCommandInterpreterRunOptions &options, lldb::SBCommandReturnObject result)
lldb::SBCommandInterpreter::HandleCompletion
int HandleCompletion(const char *current_line, const char *cursor, const char *last_char, int match_start_point, int max_return_elements, lldb::SBStringList &matches)
lldb::SBCommand
Definition: SBCommandInterpreter.h:242
lldb::SBCommandInterpreter::ResolveCommand
void ResolveCommand(const char *command_line, SBCommandReturnObject &result)
lldb::SBCommandInterpreter::SetPromptOnQuit
void SetPromptOnQuit(bool b)
lldb::SBCommandInterpreter::GetDebugger
lldb::SBDebugger GetDebugger()
lldb::SBStringList
Definition: SBStringList.h:17
lldb::SBFileSpec
Definition: SBFileSpec.h:17
lldb::SBCommandInterpreter::GetIOHandlerControlSequence
const char * GetIOHandlerControlSequence(char ch)
lldb::SBCommandPluginInterface
Definition: SBCommandInterpreter.h:232
lldb::SBCommandPluginInterface::DoExecute
virtual bool DoExecute(lldb::SBDebugger, char **, lldb::SBCommandReturnObject &)
Definition: SBCommandInterpreter.h:236
lldb::SBCommandInterpreter::HasCommands
bool HasCommands()
lldb::SBDebugger
Definition: SBDebugger.h:35
lldb::SBCommandInterpreter::GetPromptOnQuit
bool GetPromptOnQuit()
lldb::SBCommandInterpreter::SourceInitFileInHomeDirectory
void SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &result)
lldb::SBCommandInterpreter::AddMultiwordCommand
lldb::SBCommand AddMultiwordCommand(const char *name, const char *help)
lldb::SBProcess
Definition: SBProcess.h:23
lldb::SBCommandInterpreter::IsValid
bool IsValid() const
lldb::SBCommandInterpreter::GetArgumentTypeAsCString
static const char * GetArgumentTypeAsCString(const lldb::CommandArgumentType arg_type)
lldb::SBExecutionContext
Definition: SBExecutionContext.h:21
lldb::SBEvent
Definition: SBEvent.h:22
lldb::SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory
void SourceInitFileInCurrentWorkingDirectory(lldb::SBCommandReturnObject &result)
lldb::SBCommandInterpreter::reset
void reset(lldb_private::CommandInterpreter *)
lldb::SBCommandInterpreter::GetBroadcaster
lldb::SBBroadcaster GetBroadcaster()
SBDebugger.h
lldb::SBCommandInterpreterRunOptions
Definition: SBCommandInterpreter.h:24
lldb::SBCommandInterpreter::IsActive
bool IsActive()
lldb::SBCommandInterpreter::ref
lldb_private::CommandInterpreter & ref()
lldb::SBCommandReturnObject
Definition: SBCommandReturnObject.h:25
lldb::SBCommandInterpreter::eBroadcastBitAsynchronousErrorData
Definition: SBCommandInterpreter.h:73
lldb::SBCommandInterpreter::operator=
const lldb::SBCommandInterpreter & operator=(const lldb::SBCommandInterpreter &rhs)
lldb::SBCommandInterpreter::eBroadcastBitAsynchronousOutputData
Definition: SBCommandInterpreter.h:72