1 //===-- SWIG Interface for SBCommandInterpreter -----------------*- 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 namespace lldb { 11 12 %feature("docstring", 13 "SBCommandInterpreter handles/interprets commands for lldb. You get the 14 command interpreter from the SBDebugger instance. For example (from test/ 15 python_api/interpreter/TestCommandInterpreterAPI.py), 16 17 def command_interpreter_api(self): 18 '''Test the SBCommandInterpreter APIs.''' 19 exe = os.path.join(os.getcwd(), 'a.out') 20 21 # Create a target by the debugger. 22 target = self.dbg.CreateTarget(exe) 23 self.assertTrue(target, VALID_TARGET) 24 25 # Retrieve the associated command interpreter from our debugger. 26 ci = self.dbg.GetCommandInterpreter() 27 self.assertTrue(ci, VALID_COMMAND_INTERPRETER) 28 29 # Exercise some APIs.... 30 31 self.assertTrue(ci.HasCommands()) 32 self.assertTrue(ci.HasAliases()) 33 self.assertTrue(ci.HasAliasOptions()) 34 self.assertTrue(ci.CommandExists('breakpoint')) 35 self.assertTrue(ci.CommandExists('target')) 36 self.assertTrue(ci.CommandExists('platform')) 37 self.assertTrue(ci.AliasExists('file')) 38 self.assertTrue(ci.AliasExists('run')) 39 self.assertTrue(ci.AliasExists('bt')) 40 41 res = lldb.SBCommandReturnObject() 42 ci.HandleCommand('breakpoint set -f main.c -l %d' % self.line, res) 43 self.assertTrue(res.Succeeded()) 44 ci.HandleCommand('process launch', res) 45 self.assertTrue(res.Succeeded()) 46 47 process = ci.GetProcess() 48 self.assertTrue(process) 49 50 ... 51 52 The HandleCommand() instance method takes two args: the command string and 53 an SBCommandReturnObject instance which encapsulates the result of command 54 execution. 55 ") SBCommandInterpreter; 56 class SBCommandInterpreter 57 { 58 public: 59 enum 60 { 61 eBroadcastBitThreadShouldExit = (1 << 0), 62 eBroadcastBitResetPrompt = (1 << 1), 63 eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit 64 eBroadcastBitAsynchronousOutputData = (1 << 3), 65 eBroadcastBitAsynchronousErrorData = (1 << 4) 66 }; 67 68 SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs); 69 70 ~SBCommandInterpreter (); 71 72 static const char * 73 GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type); 74 75 static const char * 76 GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type); 77 78 bool 79 IsValid() const; 80 81 bool 82 CommandExists (const char *cmd); 83 84 bool 85 AliasExists (const char *cmd); 86 87 lldb::SBBroadcaster 88 GetBroadcaster (); 89 90 static const char * 91 GetBroadcasterClass (); 92 93 bool 94 HasCommands (); 95 96 bool 97 HasAliases (); 98 99 bool 100 HasAliasOptions (); 101 102 lldb::SBProcess 103 GetProcess (); 104 105 lldb::SBDebugger 106 GetDebugger (); 107 108 void 109 SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result); 110 111 void 112 SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result); 113 114 lldb::ReturnStatus 115 HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false); 116 117 int 118 HandleCompletion (const char *current_line, 119 uint32_t cursor_pos, 120 int match_start_point, 121 int max_return_elements, 122 lldb::SBStringList &matches); 123 }; 124 125 } // namespace lldb 126