2011-07-20 06:41:47 +08:00
|
|
|
//===-- SWIG Interface for SBCommandInterpreter -----------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2011-07-20 06:41:47 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
namespace lldb {
|
|
|
|
|
2011-07-21 06:50:58 +08:00
|
|
|
%feature("docstring",
|
2021-01-15 21:43:26 +08:00
|
|
|
"SBCommandInterpreter handles/interprets commands for lldb.
|
|
|
|
|
|
|
|
You get the command interpreter from the :py:class:`SBDebugger` instance.
|
|
|
|
|
|
|
|
For example (from test/ python_api/interpreter/TestCommandInterpreterAPI.py),::
|
2011-07-21 06:50:58 +08:00
|
|
|
|
|
|
|
def command_interpreter_api(self):
|
|
|
|
'''Test the SBCommandInterpreter APIs.'''
|
|
|
|
exe = os.path.join(os.getcwd(), 'a.out')
|
|
|
|
|
|
|
|
# Create a target by the debugger.
|
|
|
|
target = self.dbg.CreateTarget(exe)
|
|
|
|
self.assertTrue(target, VALID_TARGET)
|
|
|
|
|
|
|
|
# Retrieve the associated command interpreter from our debugger.
|
|
|
|
ci = self.dbg.GetCommandInterpreter()
|
|
|
|
self.assertTrue(ci, VALID_COMMAND_INTERPRETER)
|
|
|
|
|
|
|
|
# Exercise some APIs....
|
|
|
|
|
|
|
|
self.assertTrue(ci.HasCommands())
|
|
|
|
self.assertTrue(ci.HasAliases())
|
|
|
|
self.assertTrue(ci.HasAliasOptions())
|
|
|
|
self.assertTrue(ci.CommandExists('breakpoint'))
|
|
|
|
self.assertTrue(ci.CommandExists('target'))
|
|
|
|
self.assertTrue(ci.CommandExists('platform'))
|
|
|
|
self.assertTrue(ci.AliasExists('file'))
|
|
|
|
self.assertTrue(ci.AliasExists('run'))
|
|
|
|
self.assertTrue(ci.AliasExists('bt'))
|
|
|
|
|
|
|
|
res = lldb.SBCommandReturnObject()
|
|
|
|
ci.HandleCommand('breakpoint set -f main.c -l %d' % self.line, res)
|
|
|
|
self.assertTrue(res.Succeeded())
|
|
|
|
ci.HandleCommand('process launch', res)
|
|
|
|
self.assertTrue(res.Succeeded())
|
|
|
|
|
|
|
|
process = ci.GetProcess()
|
|
|
|
self.assertTrue(process)
|
|
|
|
|
|
|
|
...
|
|
|
|
|
|
|
|
The HandleCommand() instance method takes two args: the command string and
|
|
|
|
an SBCommandReturnObject instance which encapsulates the result of command
|
2019-04-19 00:23:33 +08:00
|
|
|
execution.") SBCommandInterpreter;
|
2011-07-20 06:41:47 +08:00
|
|
|
class SBCommandInterpreter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
eBroadcastBitThreadShouldExit = (1 << 0),
|
|
|
|
eBroadcastBitResetPrompt = (1 << 1),
|
2017-10-06 07:41:28 +08:00
|
|
|
eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
|
2011-07-20 06:41:47 +08:00
|
|
|
eBroadcastBitAsynchronousOutputData = (1 << 3),
|
|
|
|
eBroadcastBitAsynchronousErrorData = (1 << 4)
|
|
|
|
};
|
|
|
|
|
|
|
|
SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs);
|
2017-10-06 07:41:28 +08:00
|
|
|
|
2011-07-20 06:41:47 +08:00
|
|
|
~SBCommandInterpreter ();
|
|
|
|
|
2017-10-06 07:41:28 +08:00
|
|
|
static const char *
|
2011-07-20 06:41:47 +08:00
|
|
|
GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
|
2017-10-06 07:41:28 +08:00
|
|
|
|
2011-07-20 06:41:47 +08:00
|
|
|
static const char *
|
|
|
|
GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type);
|
2015-03-24 05:50:21 +08:00
|
|
|
|
|
|
|
static bool
|
|
|
|
EventIsCommandInterpreterEvent (const lldb::SBEvent &event);
|
|
|
|
|
2011-07-20 06:41:47 +08:00
|
|
|
bool
|
|
|
|
IsValid() const;
|
|
|
|
|
Add "operator bool" to SB APIs
Summary:
Our python version of the SB API has (the python equivalent of)
operator bool, but the C++ version doesn't.
This is because our python operators are added by modify-python-lldb.py,
which performs postprocessing on the swig-generated interface files.
In this patch, I add the "operator bool" to all SB classes which have an
IsValid method (which is the same logic used by modify-python-lldb.py).
This way, we make the two interfaces more constent, and it allows us to
rely on swig's automatic syntesis of python __nonzero__ methods instead
of doing manual fixups.
Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille
Subscribers: jdoerfert, lldb-commits
Differential Revision: https://reviews.llvm.org/D58792
llvm-svn: 355824
2019-03-11 21:58:46 +08:00
|
|
|
explicit operator bool() const;
|
|
|
|
|
2014-01-28 07:43:24 +08:00
|
|
|
const char *
|
|
|
|
GetIOHandlerControlSequence(char ch);
|
|
|
|
|
2015-03-24 06:45:13 +08:00
|
|
|
bool
|
|
|
|
GetPromptOnQuit();
|
|
|
|
|
|
|
|
void
|
|
|
|
SetPromptOnQuit(bool b);
|
|
|
|
|
2018-07-12 01:18:01 +08:00
|
|
|
void
|
|
|
|
AllowExitCodeOnQuit(bool b);
|
|
|
|
|
|
|
|
bool
|
|
|
|
HasCustomQuitExitCode();
|
|
|
|
|
|
|
|
int
|
|
|
|
GetQuitStatus();
|
|
|
|
|
2015-04-24 04:00:25 +08:00
|
|
|
void
|
|
|
|
ResolveCommand(const char *command_line, SBCommandReturnObject &result);
|
|
|
|
|
2011-07-20 06:41:47 +08:00
|
|
|
bool
|
|
|
|
CommandExists (const char *cmd);
|
|
|
|
|
|
|
|
bool
|
|
|
|
AliasExists (const char *cmd);
|
|
|
|
|
|
|
|
lldb::SBBroadcaster
|
|
|
|
GetBroadcaster ();
|
|
|
|
|
2012-02-16 14:50:00 +08:00
|
|
|
static const char *
|
|
|
|
GetBroadcasterClass ();
|
|
|
|
|
2011-07-20 06:41:47 +08:00
|
|
|
bool
|
|
|
|
HasCommands ();
|
|
|
|
|
|
|
|
bool
|
|
|
|
HasAliases ();
|
|
|
|
|
|
|
|
bool
|
|
|
|
HasAliasOptions ();
|
|
|
|
|
2022-02-11 08:12:59 +08:00
|
|
|
bool
|
|
|
|
IsInteractive ();
|
|
|
|
|
2011-07-20 06:41:47 +08:00
|
|
|
lldb::SBProcess
|
|
|
|
GetProcess ();
|
2017-10-06 07:41:28 +08:00
|
|
|
|
2012-09-29 07:57:51 +08:00
|
|
|
lldb::SBDebugger
|
|
|
|
GetDebugger ();
|
2011-07-20 06:41:47 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
|
|
|
|
|
|
|
|
void
|
|
|
|
SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result);
|
|
|
|
|
|
|
|
lldb::ReturnStatus
|
|
|
|
HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
|
|
|
|
|
2014-10-14 09:20:07 +08:00
|
|
|
lldb::ReturnStatus
|
|
|
|
HandleCommand (const char *command_line, SBExecutionContext &exe_ctx, SBCommandReturnObject &result, bool add_to_history = false);
|
|
|
|
|
|
|
|
void
|
|
|
|
HandleCommandsFromFile (lldb::SBFileSpec &file,
|
|
|
|
lldb::SBExecutionContext &override_context,
|
|
|
|
lldb::SBCommandInterpreterRunOptions &options,
|
|
|
|
lldb::SBCommandReturnObject result);
|
|
|
|
|
2011-07-20 06:41:47 +08:00
|
|
|
int
|
|
|
|
HandleCompletion (const char *current_line,
|
2011-09-21 09:17:13 +08:00
|
|
|
uint32_t cursor_pos,
|
2011-07-20 06:41:47 +08:00
|
|
|
int match_start_point,
|
|
|
|
int max_return_elements,
|
|
|
|
lldb::SBStringList &matches);
|
2017-10-06 07:41:28 +08:00
|
|
|
|
2018-09-14 05:26:00 +08:00
|
|
|
int
|
|
|
|
HandleCompletionWithDescriptions (const char *current_line,
|
|
|
|
uint32_t cursor_pos,
|
|
|
|
int match_start_point,
|
|
|
|
int max_return_elements,
|
|
|
|
lldb::SBStringList &matches,
|
|
|
|
lldb::SBStringList &descriptions);
|
2014-01-28 07:43:24 +08:00
|
|
|
bool
|
|
|
|
IsActive ();
|
|
|
|
|
2017-10-06 07:41:28 +08:00
|
|
|
bool
|
|
|
|
WasInterrupted () const;
|
2011-07-20 06:41:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace lldb
|