1254721Semaste//===-- SBCommandInterpreter.h ----------------------------------*- C++ -*-===// 2254721Semaste// 3254721Semaste// The LLVM Compiler Infrastructure 4254721Semaste// 5254721Semaste// This file is distributed under the University of Illinois Open Source 6254721Semaste// License. See LICENSE.TXT for details. 7254721Semaste// 8254721Semaste//===----------------------------------------------------------------------===// 9254721Semaste 10254721Semaste#ifndef LLDB_SBCommandInterpreter_h_ 11254721Semaste#define LLDB_SBCommandInterpreter_h_ 12254721Semaste 13254721Semaste#include "lldb/API/SBDefines.h" 14254721Semaste#include "lldb/API/SBDebugger.h" 15254721Semaste 16254721Semastenamespace lldb { 17254721Semaste 18254721Semasteclass SBCommandInterpreter 19254721Semaste{ 20254721Semastepublic: 21254721Semaste enum 22254721Semaste { 23254721Semaste eBroadcastBitThreadShouldExit = (1 << 0), 24254721Semaste eBroadcastBitResetPrompt = (1 << 1), 25254721Semaste eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit 26254721Semaste eBroadcastBitAsynchronousOutputData = (1 << 3), 27254721Semaste eBroadcastBitAsynchronousErrorData = (1 << 4) 28254721Semaste }; 29254721Semaste 30254721Semaste SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs); 31254721Semaste 32254721Semaste const lldb::SBCommandInterpreter & 33254721Semaste operator = (const lldb::SBCommandInterpreter &rhs); 34254721Semaste 35254721Semaste ~SBCommandInterpreter (); 36254721Semaste 37254721Semaste static const char * 38254721Semaste GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type); 39254721Semaste 40254721Semaste static const char * 41254721Semaste GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type); 42254721Semaste 43254721Semaste bool 44254721Semaste IsValid() const; 45254721Semaste 46254721Semaste bool 47254721Semaste CommandExists (const char *cmd); 48254721Semaste 49254721Semaste bool 50254721Semaste AliasExists (const char *cmd); 51254721Semaste 52254721Semaste lldb::SBBroadcaster 53254721Semaste GetBroadcaster (); 54254721Semaste 55254721Semaste static const char * 56254721Semaste GetBroadcasterClass (); 57254721Semaste 58254721Semaste bool 59254721Semaste HasCommands (); 60254721Semaste 61254721Semaste bool 62254721Semaste HasAliases (); 63254721Semaste 64254721Semaste bool 65254721Semaste HasAliasOptions (); 66254721Semaste 67254721Semaste lldb::SBProcess 68254721Semaste GetProcess (); 69254721Semaste 70254721Semaste lldb::SBDebugger 71254721Semaste GetDebugger (); 72254721Semaste 73254721Semaste lldb::SBCommand 74254721Semaste AddMultiwordCommand (const char* name, const char* help); 75254721Semaste 76254721Semaste lldb::SBCommand 77254721Semaste AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, const char* help); 78254721Semaste 79254721Semaste void 80254721Semaste SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result); 81254721Semaste 82254721Semaste void 83254721Semaste SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result); 84254721Semaste 85254721Semaste lldb::ReturnStatus 86254721Semaste HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false); 87254721Semaste 88254721Semaste // The pointer based interface is not useful in SWIG, since the cursor & last_char arguments are string pointers INTO current_line 89254721Semaste // and you can't do that in a scripting language interface in general... 90254721Semaste 91254721Semaste // In either case, the way this works is that the you give it a line and cursor position in the line. The function 92254721Semaste // will return the number of completions. The matches list will contain number_of_completions + 1 elements. The first 93254721Semaste // element is the common substring after the cursor position for all the matches. The rest of the elements are the 94254721Semaste // matches. The first element is useful if you are emulating the common shell behavior where the tab completes 95254721Semaste // to the string that is common among all the matches, then you should first check if the first element is non-empty, 96254721Semaste // and if so just insert it and move the cursor to the end of the insertion. The next tab will return an empty 97254721Semaste // common substring, and a list of choices (if any), at which point you should display the choices and let the user 98254721Semaste // type further to disambiguate. 99254721Semaste 100254721Semaste int 101254721Semaste HandleCompletion (const char *current_line, 102254721Semaste const char *cursor, 103254721Semaste const char *last_char, 104254721Semaste int match_start_point, 105254721Semaste int max_return_elements, 106254721Semaste lldb::SBStringList &matches); 107254721Semaste 108254721Semaste int 109254721Semaste HandleCompletion (const char *current_line, 110254721Semaste uint32_t cursor_pos, 111254721Semaste int match_start_point, 112254721Semaste int max_return_elements, 113254721Semaste lldb::SBStringList &matches); 114254721Semaste 115254721Semaste // Catch commands before they execute by registering a callback that will 116254721Semaste // get called when the command gets executed. This allows GUI or command 117254721Semaste // line interfaces to intercept a command and stop it from happening 118254721Semaste bool 119254721Semaste SetCommandOverrideCallback (const char *command_name, 120254721Semaste lldb::CommandOverrideCallback callback, 121254721Semaste void *baton); 122254721Semaste 123254721Semaste SBCommandInterpreter (lldb_private::CommandInterpreter *interpreter_ptr = NULL); // Access using SBDebugger::GetCommandInterpreter(); 124254721Semaste 125254721Semasteprotected: 126254721Semaste 127254721Semaste lldb_private::CommandInterpreter & 128254721Semaste ref (); 129254721Semaste 130254721Semaste lldb_private::CommandInterpreter * 131254721Semaste get (); 132254721Semaste 133254721Semaste void 134254721Semaste reset (lldb_private::CommandInterpreter *); 135254721Semasteprivate: 136254721Semaste friend class SBDebugger; 137254721Semaste 138254721Semaste static void 139254721Semaste InitializeSWIG (); 140254721Semaste 141254721Semaste lldb_private::CommandInterpreter *m_opaque_ptr; 142254721Semaste}; 143254721Semaste 144254721Semasteclass SBCommandPluginInterface 145254721Semaste{ 146254721Semastepublic: 147254721Semaste virtual bool 148254721Semaste DoExecute (lldb::SBDebugger debugger, 149254721Semaste char** command, 150254721Semaste lldb::SBCommandReturnObject &result) 151254721Semaste { 152254721Semaste return false; 153254721Semaste } 154254721Semaste 155254721Semaste virtual 156254721Semaste ~SBCommandPluginInterface () 157254721Semaste {} 158254721Semaste}; 159254721Semaste 160254721Semasteclass SBCommand 161254721Semaste{ 162254721Semastepublic: 163254721Semaste 164254721Semaste SBCommand (); 165254721Semaste 166254721Semaste bool 167254721Semaste IsValid (); 168254721Semaste 169254721Semaste const char* 170254721Semaste GetName (); 171254721Semaste 172254721Semaste const char* 173254721Semaste GetHelp (); 174254721Semaste 175254721Semaste lldb::SBCommand 176254721Semaste AddMultiwordCommand (const char* name, const char* help = NULL); 177254721Semaste 178254721Semaste lldb::SBCommand 179254721Semaste AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help = NULL); 180254721Semaste 181254721Semasteprivate: 182254721Semaste 183254721Semaste friend class SBDebugger; 184254721Semaste friend class SBCommandInterpreter; 185254721Semaste 186254721Semaste SBCommand (lldb::CommandObjectSP cmd_sp); 187254721Semaste 188254721Semaste lldb::CommandObjectSP m_opaque_sp; 189254721Semaste}; 190254721Semaste 191254721Semaste} // namespace lldb 192254721Semaste 193254721Semaste#endif // LLDB_SBCommandInterpreter_h_ 194