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 "SBCommandInterpreter handles/interprets commands for lldb. You get the
13 command interpreter from the SBDebugger instance. For example (from test/
14 python_api/interpreter/TestCommandInterpreterAPI.py),
16 def command_interpreter_api(self):
17 '''Test the SBCommandInterpreter APIs.'''
18 exe = os.path.join(os.getcwd(), 'a.out')
20 # Create a target by the debugger.
21 target = self.dbg.CreateTarget(exe)
22 self.assertTrue(target, VALID_TARGET)
24 # Retrieve the associated command interpreter from our debugger.
25 ci = self.dbg.GetCommandInterpreter()
26 self.assertTrue(ci, VALID_COMMAND_INTERPRETER)
28 # Exercise some APIs....
30 self.assertTrue(ci.HasCommands())
31 self.assertTrue(ci.HasAliases())
32 self.assertTrue(ci.HasAliasOptions())
33 self.assertTrue(ci.CommandExists('breakpoint'))
34 self.assertTrue(ci.CommandExists('target'))
35 self.assertTrue(ci.CommandExists('platform'))
36 self.assertTrue(ci.AliasExists('file'))
37 self.assertTrue(ci.AliasExists('run'))
38 self.assertTrue(ci.AliasExists('bt'))
40 res = lldb.SBCommandReturnObject()
41 ci.HandleCommand('breakpoint set -f main.c -l %d' % self.line, res)
42 self.assertTrue(res.Succeeded())
43 ci.HandleCommand('process launch', res)
44 self.assertTrue(res.Succeeded())
46 process = ci.GetProcess()
47 self.assertTrue(process)
51 The HandleCommand() instance method takes two args: the command string and
52 an SBCommandReturnObject instance which encapsulates the result of command
53 execution.") SBCommandInterpreter;
54 class SBCommandInterpreter
59 eBroadcastBitThreadShouldExit = (1 << 0),
60 eBroadcastBitResetPrompt = (1 << 1),
61 eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
62 eBroadcastBitAsynchronousOutputData = (1 << 3),
63 eBroadcastBitAsynchronousErrorData = (1 << 4)
66 SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs);
68 ~SBCommandInterpreter ();
71 GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
74 GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type);
77 EventIsCommandInterpreterEvent (const lldb::SBEvent &event);
82 explicit operator bool() const;
85 GetIOHandlerControlSequence(char ch);
91 SetPromptOnQuit(bool b);
94 AllowExitCodeOnQuit(bool b);
97 HasCustomQuitExitCode();
103 ResolveCommand(const char *command_line, SBCommandReturnObject &result);
106 CommandExists (const char *cmd);
109 AliasExists (const char *cmd);
115 GetBroadcasterClass ();
133 SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
136 SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result);
139 HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
142 HandleCommand (const char *command_line, SBExecutionContext &exe_ctx, SBCommandReturnObject &result, bool add_to_history = false);
145 HandleCommandsFromFile (lldb::SBFileSpec &file,
146 lldb::SBExecutionContext &override_context,
147 lldb::SBCommandInterpreterRunOptions &options,
148 lldb::SBCommandReturnObject result);
151 HandleCompletion (const char *current_line,
153 int match_start_point,
154 int max_return_elements,
155 lldb::SBStringList &matches);
158 HandleCompletionWithDescriptions (const char *current_line,
160 int match_start_point,
161 int max_return_elements,
162 lldb::SBStringList &matches,
163 lldb::SBStringList &descriptions);
168 WasInterrupted () const;