1 //===-- SWIG Interface for SBCommandInterpreter -----------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 "SBCommandInterpreterRunOptions controls how the RunCommandInterpreter runs the code it is fed.
13 A default SBCommandInterpreterRunOptions object has:
21 ") SBCommandInterpreterRunOptions;
22 class SBCommandInterpreterRunOptions
24 friend class SBDebugger;
26 SBCommandInterpreterRunOptions();
27 ~SBCommandInterpreterRunOptions();
30 GetStopOnContinue () const;
33 SetStopOnContinue (bool);
36 GetStopOnError () const;
39 SetStopOnError (bool);
42 GetStopOnCrash () const;
45 SetStopOnCrash (bool);
48 GetEchoCommands () const;
51 SetEchoCommands (bool);
54 GetPrintResults () const;
57 SetPrintResults (bool);
60 GetAddToHistory () const;
63 SetAddToHistory (bool);
65 lldb_private::CommandInterpreterRunOptions *
68 lldb_private::CommandInterpreterRunOptions &
71 // This is set in the constructor and will always be valid.
72 mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions> m_opaque_up;
76 "SBCommandInterpreter handles/interprets commands for lldb. You get the
77 command interpreter from the SBDebugger instance. For example (from test/
78 python_api/interpreter/TestCommandInterpreterAPI.py),
80 def command_interpreter_api(self):
81 '''Test the SBCommandInterpreter APIs.'''
82 exe = os.path.join(os.getcwd(), 'a.out')
84 # Create a target by the debugger.
85 target = self.dbg.CreateTarget(exe)
86 self.assertTrue(target, VALID_TARGET)
88 # Retrieve the associated command interpreter from our debugger.
89 ci = self.dbg.GetCommandInterpreter()
90 self.assertTrue(ci, VALID_COMMAND_INTERPRETER)
92 # Exercise some APIs....
94 self.assertTrue(ci.HasCommands())
95 self.assertTrue(ci.HasAliases())
96 self.assertTrue(ci.HasAliasOptions())
97 self.assertTrue(ci.CommandExists('breakpoint'))
98 self.assertTrue(ci.CommandExists('target'))
99 self.assertTrue(ci.CommandExists('platform'))
100 self.assertTrue(ci.AliasExists('file'))
101 self.assertTrue(ci.AliasExists('run'))
102 self.assertTrue(ci.AliasExists('bt'))
104 res = lldb.SBCommandReturnObject()
105 ci.HandleCommand('breakpoint set -f main.c -l %d' % self.line, res)
106 self.assertTrue(res.Succeeded())
107 ci.HandleCommand('process launch', res)
108 self.assertTrue(res.Succeeded())
110 process = ci.GetProcess()
111 self.assertTrue(process)
115 The HandleCommand() instance method takes two args: the command string and
116 an SBCommandReturnObject instance which encapsulates the result of command
117 execution.") SBCommandInterpreter;
118 class SBCommandInterpreter
123 eBroadcastBitThreadShouldExit = (1 << 0),
124 eBroadcastBitResetPrompt = (1 << 1),
125 eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
126 eBroadcastBitAsynchronousOutputData = (1 << 3),
127 eBroadcastBitAsynchronousErrorData = (1 << 4)
130 SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs);
132 ~SBCommandInterpreter ();
135 GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
138 GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type);
141 EventIsCommandInterpreterEvent (const lldb::SBEvent &event);
146 explicit operator bool() const;
149 GetIOHandlerControlSequence(char ch);
155 SetPromptOnQuit(bool b);
158 AllowExitCodeOnQuit(bool b);
161 HasCustomQuitExitCode();
167 ResolveCommand(const char *command_line, SBCommandReturnObject &result);
170 CommandExists (const char *cmd);
173 AliasExists (const char *cmd);
179 GetBroadcasterClass ();
197 SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
200 SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result);
203 HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
206 HandleCommand (const char *command_line, SBExecutionContext &exe_ctx, SBCommandReturnObject &result, bool add_to_history = false);
209 HandleCommandsFromFile (lldb::SBFileSpec &file,
210 lldb::SBExecutionContext &override_context,
211 lldb::SBCommandInterpreterRunOptions &options,
212 lldb::SBCommandReturnObject result);
215 HandleCompletion (const char *current_line,
217 int match_start_point,
218 int max_return_elements,
219 lldb::SBStringList &matches);
222 HandleCompletionWithDescriptions (const char *current_line,
224 int match_start_point,
225 int max_return_elements,
226 lldb::SBStringList &matches,
227 lldb::SBStringList &descriptions);
232 WasInterrupted () const;