1 //===-- SBCommandInterpreter.h ----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLDB_SBCommandInterpreter_h_
11 #define LLDB_SBCommandInterpreter_h_
13 #include "lldb/API/SBDefines.h"
14 #include "lldb/API/SBDebugger.h"
18 class SBCommandInterpreter
23 eBroadcastBitThreadShouldExit = (1 << 0),
24 eBroadcastBitResetPrompt = (1 << 1),
25 eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
26 eBroadcastBitAsynchronousOutputData = (1 << 3),
27 eBroadcastBitAsynchronousErrorData = (1 << 4)
30 SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs);
32 const lldb::SBCommandInterpreter &
33 operator = (const lldb::SBCommandInterpreter &rhs);
35 ~SBCommandInterpreter ();
38 GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
41 GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type);
47 CommandExists (const char *cmd);
50 AliasExists (const char *cmd);
56 GetBroadcasterClass ();
74 AddMultiwordCommand (const char* name, const char* help);
77 AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, const char* help);
80 SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
83 SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result);
86 HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
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...
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.
101 HandleCompletion (const char *current_line,
103 const char *last_char,
104 int match_start_point,
105 int max_return_elements,
106 lldb::SBStringList &matches);
109 HandleCompletion (const char *current_line,
111 int match_start_point,
112 int max_return_elements,
113 lldb::SBStringList &matches);
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
119 SetCommandOverrideCallback (const char *command_name,
120 lldb::CommandOverrideCallback callback,
123 SBCommandInterpreter (lldb_private::CommandInterpreter *interpreter_ptr = NULL); // Access using SBDebugger::GetCommandInterpreter();
125 //----------------------------------------------------------------------
126 /// Return true if the command interpreter is the active IO handler.
128 /// This indicates that any input coming into the debugger handles will
129 /// go to the command interpreter and will result in LLDB command line
130 /// commands being executed.
131 //----------------------------------------------------------------------
135 //----------------------------------------------------------------------
136 /// Get the string that needs to be written to the debugger stdin file
137 /// handle when a control character is typed.
139 /// Some GUI programs will intercept "control + char" sequences and want
140 /// to have them do what normally would happen when using a real
141 /// terminal, so this function allows GUI programs to emulate this
145 /// The character that was typed along with the control key
148 /// The string that should be written into the file handle that is
149 /// feeding the input stream for the debugger, or NULL if there is
150 /// no string for this control key.
151 //----------------------------------------------------------------------
153 GetIOHandlerControlSequence(char ch);
157 lldb_private::CommandInterpreter &
160 lldb_private::CommandInterpreter *
164 reset (lldb_private::CommandInterpreter *);
166 friend class SBDebugger;
171 lldb_private::CommandInterpreter *m_opaque_ptr;
174 class SBCommandPluginInterface
178 DoExecute (lldb::SBDebugger debugger,
180 lldb::SBCommandReturnObject &result)
186 ~SBCommandPluginInterface ()
206 AddMultiwordCommand (const char* name, const char* help = NULL);
209 AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help = NULL);
213 friend class SBDebugger;
214 friend class SBCommandInterpreter;
216 SBCommand (lldb::CommandObjectSP cmd_sp);
218 lldb::CommandObjectSP m_opaque_sp;
223 #endif // LLDB_SBCommandInterpreter_h_