Johnny Chen | fdc4a86 | 2011-07-19 22:41:47 +0000 | [diff] [blame] | 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 | |
Johnny Chen | ad4fe1b | 2011-07-20 22:50:58 +0000 | [diff] [blame] | 12 | %feature("docstring", |
Jim Ingham | 26c7bf9 | 2014-10-11 00:38:27 +0000 | [diff] [blame] | 13 | "SBCommandInterpreterRunOptions controls how the RunCommandInterpreter runs the code it is fed. |
| 14 | A default SBCommandInterpreterRunOptions object has: |
| 15 | StopOnContinue: false |
| 16 | StopOnError: false |
| 17 | StopOnCrash: false |
| 18 | EchoCommands: true |
| 19 | PrintResults: true |
| 20 | AddToHistory: true |
| 21 | |
| 22 | |
| 23 | ") SBCommandInterpreterRunOptions; |
| 24 | class SBCommandInterpreterRunOptions |
| 25 | { |
| 26 | friend class SBDebugger; |
| 27 | public: |
| 28 | SBCommandInterpreterRunOptions(); |
| 29 | ~SBCommandInterpreterRunOptions(); |
| 30 | |
| 31 | bool |
| 32 | GetStopOnContinue () const; |
| 33 | |
| 34 | void |
| 35 | SetStopOnContinue (bool); |
| 36 | |
| 37 | bool |
| 38 | GetStopOnError () const; |
| 39 | |
| 40 | void |
| 41 | SetStopOnError (bool); |
| 42 | |
| 43 | bool |
| 44 | GetStopOnCrash () const; |
| 45 | |
| 46 | void |
| 47 | SetStopOnCrash (bool); |
| 48 | |
| 49 | bool |
| 50 | GetEchoCommands () const; |
| 51 | |
| 52 | void |
| 53 | SetEchoCommands (bool); |
| 54 | |
| 55 | bool |
| 56 | GetPrintResults () const; |
| 57 | |
| 58 | void |
| 59 | SetPrintResults (bool); |
| 60 | |
| 61 | bool |
| 62 | GetAddToHistory () const; |
| 63 | |
| 64 | void |
| 65 | SetAddToHistory (bool); |
| 66 | private: |
| 67 | lldb_private::CommandInterpreterRunOptions * |
| 68 | get () const; |
| 69 | |
| 70 | lldb_private::CommandInterpreterRunOptions & |
| 71 | ref () const; |
| 72 | |
| 73 | // This is set in the constructor and will always be valid. |
| 74 | mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions> m_opaque_up; |
| 75 | }; |
| 76 | |
| 77 | %feature("docstring", |
Johnny Chen | ad4fe1b | 2011-07-20 22:50:58 +0000 | [diff] [blame] | 78 | "SBCommandInterpreter handles/interprets commands for lldb. You get the |
| 79 | command interpreter from the SBDebugger instance. For example (from test/ |
| 80 | python_api/interpreter/TestCommandInterpreterAPI.py), |
| 81 | |
| 82 | def command_interpreter_api(self): |
| 83 | '''Test the SBCommandInterpreter APIs.''' |
| 84 | exe = os.path.join(os.getcwd(), 'a.out') |
| 85 | |
| 86 | # Create a target by the debugger. |
| 87 | target = self.dbg.CreateTarget(exe) |
| 88 | self.assertTrue(target, VALID_TARGET) |
| 89 | |
| 90 | # Retrieve the associated command interpreter from our debugger. |
| 91 | ci = self.dbg.GetCommandInterpreter() |
| 92 | self.assertTrue(ci, VALID_COMMAND_INTERPRETER) |
| 93 | |
| 94 | # Exercise some APIs.... |
| 95 | |
| 96 | self.assertTrue(ci.HasCommands()) |
| 97 | self.assertTrue(ci.HasAliases()) |
| 98 | self.assertTrue(ci.HasAliasOptions()) |
| 99 | self.assertTrue(ci.CommandExists('breakpoint')) |
| 100 | self.assertTrue(ci.CommandExists('target')) |
| 101 | self.assertTrue(ci.CommandExists('platform')) |
| 102 | self.assertTrue(ci.AliasExists('file')) |
| 103 | self.assertTrue(ci.AliasExists('run')) |
| 104 | self.assertTrue(ci.AliasExists('bt')) |
| 105 | |
| 106 | res = lldb.SBCommandReturnObject() |
| 107 | ci.HandleCommand('breakpoint set -f main.c -l %d' % self.line, res) |
| 108 | self.assertTrue(res.Succeeded()) |
| 109 | ci.HandleCommand('process launch', res) |
| 110 | self.assertTrue(res.Succeeded()) |
| 111 | |
| 112 | process = ci.GetProcess() |
| 113 | self.assertTrue(process) |
| 114 | |
| 115 | ... |
| 116 | |
| 117 | The HandleCommand() instance method takes two args: the command string and |
| 118 | an SBCommandReturnObject instance which encapsulates the result of command |
| 119 | execution. |
| 120 | ") SBCommandInterpreter; |
Johnny Chen | fdc4a86 | 2011-07-19 22:41:47 +0000 | [diff] [blame] | 121 | class SBCommandInterpreter |
| 122 | { |
| 123 | public: |
| 124 | enum |
| 125 | { |
| 126 | eBroadcastBitThreadShouldExit = (1 << 0), |
| 127 | eBroadcastBitResetPrompt = (1 << 1), |
| 128 | eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit |
| 129 | eBroadcastBitAsynchronousOutputData = (1 << 3), |
| 130 | eBroadcastBitAsynchronousErrorData = (1 << 4) |
| 131 | }; |
| 132 | |
| 133 | SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs); |
| 134 | |
| 135 | ~SBCommandInterpreter (); |
| 136 | |
| 137 | static const char * |
| 138 | GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type); |
| 139 | |
| 140 | static const char * |
| 141 | GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type); |
| 142 | |
| 143 | bool |
| 144 | IsValid() const; |
| 145 | |
Greg Clayton | 44d9378 | 2014-01-27 23:43:24 +0000 | [diff] [blame] | 146 | const char * |
| 147 | GetIOHandlerControlSequence(char ch); |
| 148 | |
Johnny Chen | fdc4a86 | 2011-07-19 22:41:47 +0000 | [diff] [blame] | 149 | bool |
| 150 | CommandExists (const char *cmd); |
| 151 | |
| 152 | bool |
| 153 | AliasExists (const char *cmd); |
| 154 | |
| 155 | lldb::SBBroadcaster |
| 156 | GetBroadcaster (); |
| 157 | |
Jim Ingham | 4bddaeb | 2012-02-16 06:50:00 +0000 | [diff] [blame] | 158 | static const char * |
| 159 | GetBroadcasterClass (); |
| 160 | |
Johnny Chen | fdc4a86 | 2011-07-19 22:41:47 +0000 | [diff] [blame] | 161 | bool |
| 162 | HasCommands (); |
| 163 | |
| 164 | bool |
| 165 | HasAliases (); |
| 166 | |
| 167 | bool |
| 168 | HasAliasOptions (); |
| 169 | |
| 170 | lldb::SBProcess |
| 171 | GetProcess (); |
Enrico Granata | 21dfcd9 | 2012-09-28 23:57:51 +0000 | [diff] [blame] | 172 | |
| 173 | lldb::SBDebugger |
| 174 | GetDebugger (); |
Johnny Chen | fdc4a86 | 2011-07-19 22:41:47 +0000 | [diff] [blame] | 175 | |
Johnny Chen | fdc4a86 | 2011-07-19 22:41:47 +0000 | [diff] [blame] | 176 | void |
| 177 | SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result); |
| 178 | |
| 179 | void |
| 180 | SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result); |
| 181 | |
| 182 | lldb::ReturnStatus |
| 183 | HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false); |
| 184 | |
Jim Ingham | ffc9f1d | 2014-10-14 01:20:07 +0000 | [diff] [blame] | 185 | lldb::ReturnStatus |
| 186 | HandleCommand (const char *command_line, SBExecutionContext &exe_ctx, SBCommandReturnObject &result, bool add_to_history = false); |
| 187 | |
| 188 | void |
| 189 | HandleCommandsFromFile (lldb::SBFileSpec &file, |
| 190 | lldb::SBExecutionContext &override_context, |
| 191 | lldb::SBCommandInterpreterRunOptions &options, |
| 192 | lldb::SBCommandReturnObject result); |
| 193 | |
Johnny Chen | fdc4a86 | 2011-07-19 22:41:47 +0000 | [diff] [blame] | 194 | int |
| 195 | HandleCompletion (const char *current_line, |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 196 | uint32_t cursor_pos, |
Johnny Chen | fdc4a86 | 2011-07-19 22:41:47 +0000 | [diff] [blame] | 197 | int match_start_point, |
| 198 | int max_return_elements, |
| 199 | lldb::SBStringList &matches); |
Greg Clayton | 44d9378 | 2014-01-27 23:43:24 +0000 | [diff] [blame] | 200 | |
| 201 | bool |
| 202 | IsActive (); |
| 203 | |
Johnny Chen | fdc4a86 | 2011-07-19 22:41:47 +0000 | [diff] [blame] | 204 | }; |
| 205 | |
| 206 | } // namespace lldb |