[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 08:23:27 +01:00
|
|
|
//===-- SBCommandInterpreter.cpp ------------------------------------------===//
|
2010-06-08 16:52:24 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00: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
|
2010-06-08 16:52:24 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "lldb/lldb-types.h"
|
2015-07-30 20:28:07 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
#include "SBReproducerPrivate.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
2012-09-28 23:57:51 +00:00
|
|
|
#include "lldb/Interpreter/CommandObjectMultiword.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
|
|
|
|
#include "lldb/Target/Target.h"
|
2018-12-14 15:59:49 +00:00
|
|
|
#include "lldb/Utility/Listener.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2010-06-09 07:37:52 +00:00
|
|
|
#include "lldb/API/SBBroadcaster.h"
|
|
|
|
|
#include "lldb/API/SBCommandInterpreter.h"
|
2020-04-30 13:28:42 -07:00
|
|
|
#include "lldb/API/SBCommandInterpreterRunOptions.h"
|
2010-06-09 07:37:52 +00:00
|
|
|
#include "lldb/API/SBCommandReturnObject.h"
|
Fix handling of CommandInterpreter's events in lldb-mi
Summary:
Previously lldb-mi contains a stub for that but it didn't work and all CommanInterpreter's events were ignored.
This commit adds a handling of CommandInterpreter's events in lldb-mi.
Steps:
# Fix CMICmnLLDBDebugger::InitSBListener
# Add SBCommandInterpreter::EventIsCommandInterpreterEvent
# Exit on lldb::SBCommandInterpreter::eBroadcastBitQuitCommandReceived
All tests pass on OS X.
In further we can remove "quit" hack in lldb-mi.
Test Plan:
# Create start_script file:
```
target create ~/p/hello
b main
r
quit
```
# Run lldb-mi --interpreter
# Execute start_script file by following command:
```
-interpreter-exec console "command source start_script"
```
Log:
```
$ bin/lldb-mi --interpreter
(gdb)
-interpreter-exec console "command source start_script"
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) b main
Breakpoint 1: where = hello`main + 29 at hello.cpp:12, address = 0x0000000100000e2d
(lldb) r
Process 1582 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) quit
^done
(gdb)
=thread-created,id="1",group-id="i1"
=thread-selected,id="1"
(gdb)
=shlibs-added,shlib-info=[num="1",name="hello",dyld-addr="-",reason="dyld",path="/Users/IliaK/p/hello",loaded_addr="-",dsym-objpath="/Users/IliaK/p/hello.dSYM/Contents/Resources/DWARF/hello"]
...
=shlibs-added,shlib-info=[num="132",name="libDiagnosticMessagesClient.dylib",dyld-addr="0x7fff91705000",reason="dyld",path="/usr/lib/libDiagnosticMessagesClient.dylib",loaded_addr="0x7fff91705000"]
(gdb)
*stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x100000e2d",func="main",args=[{name="argc",value="1"},{name="argv",value="0x00007fff5fbffc88"}],file="hello.cpp",fullname="/Users/IliaK/p/hello.cpp",line="12"},thread-id="1",stopped-threads="all"
(gdb)<press Enter>
MI: Program exited OK
```
Reviewers: abidh, clayborg
Reviewed By: abidh
Subscribers: jingham, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8382
llvm-svn: 232891
2015-03-21 10:53:37 +00:00
|
|
|
#include "lldb/API/SBEvent.h"
|
2014-10-14 01:20:07 +00:00
|
|
|
#include "lldb/API/SBExecutionContext.h"
|
2010-06-09 07:37:52 +00:00
|
|
|
#include "lldb/API/SBListener.h"
|
|
|
|
|
#include "lldb/API/SBProcess.h"
|
2010-10-26 03:11:13 +00:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-06-09 07:37:52 +00:00
|
|
|
#include "lldb/API/SBStringList.h"
|
|
|
|
|
#include "lldb/API/SBTarget.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2019-02-11 23:13:08 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
2012-09-28 23:57:51 +00:00
|
|
|
class CommandPluginInterfaceImplementation : public CommandObjectParsed {
|
|
|
|
|
public:
|
2015-10-31 01:22:59 +00:00
|
|
|
CommandPluginInterfaceImplementation(CommandInterpreter &interpreter,
|
|
|
|
|
const char *name,
|
|
|
|
|
lldb::SBCommandPluginInterface *backend,
|
|
|
|
|
const char *help = nullptr,
|
|
|
|
|
const char *syntax = nullptr,
|
2020-04-03 17:16:15 -07:00
|
|
|
uint32_t flags = 0,
|
|
|
|
|
const char *auto_repeat_command = "")
|
2012-09-28 23:57:51 +00:00
|
|
|
: CommandObjectParsed(interpreter, name, help, syntax, flags),
|
2020-04-03 17:16:15 -07:00
|
|
|
m_backend(backend) {
|
|
|
|
|
m_auto_repeat_command =
|
|
|
|
|
auto_repeat_command == nullptr
|
|
|
|
|
? llvm::None
|
|
|
|
|
: llvm::Optional<std::string>(auto_repeat_command);
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
bool IsRemovable() const override { return true; }
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2020-04-03 17:16:15 -07:00
|
|
|
/// More documentation is available in lldb::CommandObject::GetRepeatCommand,
|
|
|
|
|
/// but in short, if nullptr is returned, the previous command will be
|
|
|
|
|
/// repeated, and if an empty string is returned, no commands will be
|
|
|
|
|
/// executed.
|
|
|
|
|
const char *GetRepeatCommand(Args ¤t_command_args,
|
|
|
|
|
uint32_t index) override {
|
|
|
|
|
if (!m_auto_repeat_command)
|
|
|
|
|
return nullptr;
|
|
|
|
|
else
|
|
|
|
|
return m_auto_repeat_command->c_str();
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-28 23:57:51 +00:00
|
|
|
protected:
|
2015-10-31 01:22:59 +00:00
|
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
2019-10-04 19:32:57 +00:00
|
|
|
SBCommandReturnObject sb_return(result);
|
2012-09-28 23:57:51 +00:00
|
|
|
SBCommandInterpreter sb_interpreter(&m_interpreter);
|
|
|
|
|
SBDebugger debugger_sb(m_interpreter.GetDebugger().shared_from_this());
|
|
|
|
|
bool ret = m_backend->DoExecute(
|
2020-07-05 10:54:15 +02:00
|
|
|
debugger_sb, command.GetArgumentVector(), sb_return);
|
2012-09-28 23:57:51 +00:00
|
|
|
return ret;
|
|
|
|
|
}
|
2016-07-29 07:46:32 +00:00
|
|
|
std::shared_ptr<lldb::SBCommandPluginInterface> m_backend;
|
2020-04-03 17:16:15 -07:00
|
|
|
llvm::Optional<std::string> m_auto_repeat_command;
|
2012-09-28 23:57:51 +00:00
|
|
|
};
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2010-06-23 01:19:29 +00:00
|
|
|
SBCommandInterpreter::SBCommandInterpreter(CommandInterpreter *interpreter)
|
|
|
|
|
: m_opaque_ptr(interpreter) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreter,
|
|
|
|
|
(lldb_private::CommandInterpreter *), interpreter);
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-05 23:17:00 +00:00
|
|
|
SBCommandInterpreter::SBCommandInterpreter(const SBCommandInterpreter &rhs)
|
2019-03-06 00:06:00 +00:00
|
|
|
: m_opaque_ptr(rhs.m_opaque_ptr) {
|
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreter,
|
|
|
|
|
(const lldb::SBCommandInterpreter &), rhs);
|
|
|
|
|
}
|
2010-11-05 23:17:00 +00:00
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
SBCommandInterpreter::~SBCommandInterpreter() = default;
|
|
|
|
|
|
2010-11-05 23:17:00 +00:00
|
|
|
const SBCommandInterpreter &SBCommandInterpreter::
|
|
|
|
|
operator=(const SBCommandInterpreter &rhs) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
|
const lldb::SBCommandInterpreter &,
|
|
|
|
|
SBCommandInterpreter, operator=,(const lldb::SBCommandInterpreter &),
|
|
|
|
|
rhs);
|
|
|
|
|
|
2010-11-05 23:17:00 +00:00
|
|
|
m_opaque_ptr = rhs.m_opaque_ptr;
|
2019-04-03 21:31:22 +00:00
|
|
|
return LLDB_RECORD_RESULT(*this);
|
2010-11-05 23:17:00 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
bool SBCommandInterpreter::IsValid() const {
|
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreter, IsValid);
|
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 13:58:46 +00:00
|
|
|
return this->operator bool();
|
|
|
|
|
}
|
|
|
|
|
SBCommandInterpreter::operator bool() const {
|
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreter, operator bool);
|
2019-03-06 00:06:00 +00:00
|
|
|
|
|
|
|
|
return m_opaque_ptr != nullptr;
|
|
|
|
|
}
|
2010-06-23 01:19:29 +00:00
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
bool SBCommandInterpreter::CommandExists(const char *cmd) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(bool, SBCommandInterpreter, CommandExists, (const char *),
|
|
|
|
|
cmd);
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->CommandExists(cmd)
|
|
|
|
|
: false);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SBCommandInterpreter::AliasExists(const char *cmd) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(bool, SBCommandInterpreter, AliasExists, (const char *),
|
|
|
|
|
cmd);
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->AliasExists(cmd)
|
|
|
|
|
: false);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
bool SBCommandInterpreter::IsActive() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, IsActive);
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
return (IsValid() ? m_opaque_ptr->IsActive() : false);
|
2014-01-27 23:43:24 +00:00
|
|
|
}
|
|
|
|
|
|
2017-10-05 23:41:28 +00:00
|
|
|
bool SBCommandInterpreter::WasInterrupted() const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreter, WasInterrupted);
|
|
|
|
|
|
2017-10-05 23:41:28 +00:00
|
|
|
return (IsValid() ? m_opaque_ptr->WasInterrupted() : false);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-27 23:43:24 +00:00
|
|
|
const char *SBCommandInterpreter::GetIOHandlerControlSequence(char ch) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(const char *, SBCommandInterpreter,
|
|
|
|
|
GetIOHandlerControlSequence, (char), ch);
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
return (IsValid()
|
|
|
|
|
? m_opaque_ptr->GetDebugger()
|
|
|
|
|
.GetTopIOHandlerControlSequence(ch)
|
|
|
|
|
.GetCString()
|
|
|
|
|
: nullptr);
|
2014-10-14 01:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::ReturnStatus
|
|
|
|
|
SBCommandInterpreter::HandleCommand(const char *command_line,
|
|
|
|
|
SBCommandReturnObject &result,
|
|
|
|
|
bool add_to_history) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::ReturnStatus, SBCommandInterpreter, HandleCommand,
|
|
|
|
|
(const char *, lldb::SBCommandReturnObject &, bool),
|
|
|
|
|
command_line, result, add_to_history);
|
|
|
|
|
|
2014-10-14 01:20:07 +00:00
|
|
|
SBExecutionContext sb_exe_ctx;
|
|
|
|
|
return HandleCommand(command_line, sb_exe_ctx, result, add_to_history);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
lldb::ReturnStatus SBCommandInterpreter::HandleCommand(
|
2014-10-14 01:20:07 +00:00
|
|
|
const char *command_line, SBExecutionContext &override_context,
|
2010-06-08 16:52:24 +00:00
|
|
|
SBCommandReturnObject &result, bool add_to_history) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::ReturnStatus, SBCommandInterpreter, HandleCommand,
|
|
|
|
|
(const char *, lldb::SBExecutionContext &,
|
|
|
|
|
lldb::SBCommandReturnObject &, bool),
|
|
|
|
|
command_line, override_context, result, add_to_history);
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
result.Clear();
|
2015-10-31 01:22:59 +00:00
|
|
|
if (command_line && IsValid()) {
|
2014-07-15 00:25:59 +00:00
|
|
|
result.ref().SetInteractive(false);
|
2020-12-18 16:36:15 +03:00
|
|
|
auto do_add_to_history = add_to_history ? eLazyBoolYes : eLazyBoolNo;
|
|
|
|
|
if (override_context.get())
|
|
|
|
|
m_opaque_ptr->HandleCommand(command_line, do_add_to_history,
|
|
|
|
|
override_context.get()->Lock(true),
|
|
|
|
|
result.ref());
|
|
|
|
|
else
|
|
|
|
|
m_opaque_ptr->HandleCommand(command_line, do_add_to_history,
|
|
|
|
|
result.ref());
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2015-04-23 20:00:25 +00:00
|
|
|
result->AppendError(
|
2011-12-19 21:16:29 +00:00
|
|
|
"SBCommandInterpreter or the command line is not valid");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
return result.GetStatus();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-14 01:20:07 +00:00
|
|
|
void SBCommandInterpreter::HandleCommandsFromFile(
|
|
|
|
|
lldb::SBFileSpec &file, lldb::SBExecutionContext &override_context,
|
|
|
|
|
lldb::SBCommandInterpreterRunOptions &options,
|
|
|
|
|
lldb::SBCommandReturnObject result) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommandInterpreter, HandleCommandsFromFile,
|
|
|
|
|
(lldb::SBFileSpec &, lldb::SBExecutionContext &,
|
|
|
|
|
lldb::SBCommandInterpreterRunOptions &,
|
|
|
|
|
lldb::SBCommandReturnObject),
|
|
|
|
|
file, override_context, options, result);
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
if (!IsValid()) {
|
2014-10-14 01:20:07 +00:00
|
|
|
result->AppendError("SBCommandInterpreter is not valid.");
|
2016-09-06 20:57:50 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-14 01:20:07 +00:00
|
|
|
if (!file.IsValid()) {
|
|
|
|
|
SBStream s;
|
|
|
|
|
file.GetDescription(s);
|
|
|
|
|
result->AppendErrorWithFormat("File is not valid: %s.", s.GetData());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-14 01:20:07 +00:00
|
|
|
FileSpec tmp_spec = file.ref();
|
2020-12-18 16:36:15 +03:00
|
|
|
if (override_context.get())
|
|
|
|
|
m_opaque_ptr->HandleCommandsFromFile(tmp_spec,
|
|
|
|
|
override_context.get()->Lock(true),
|
|
|
|
|
options.ref(),
|
|
|
|
|
result.ref());
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
m_opaque_ptr->HandleCommandsFromFile(tmp_spec, options.ref(), result.ref());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
int SBCommandInterpreter::HandleCompletion(
|
2015-10-31 01:22:59 +00:00
|
|
|
const char *current_line, const char *cursor, const char *last_char,
|
2012-11-29 21:49:15 +00:00
|
|
|
int match_start_point, int max_return_elements, SBStringList &matches) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(int, SBCommandInterpreter, HandleCompletion,
|
|
|
|
|
(const char *, const char *, const char *, int, int,
|
|
|
|
|
lldb::SBStringList &),
|
|
|
|
|
current_line, cursor, last_char, match_start_point,
|
|
|
|
|
max_return_elements, matches);
|
|
|
|
|
|
2018-09-13 21:26:00 +00:00
|
|
|
SBStringList dummy_descriptions;
|
|
|
|
|
return HandleCompletionWithDescriptions(
|
|
|
|
|
current_line, cursor, last_char, match_start_point, max_return_elements,
|
|
|
|
|
matches, dummy_descriptions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SBCommandInterpreter::HandleCompletionWithDescriptions(
|
|
|
|
|
const char *current_line, const char *cursor, const char *last_char,
|
|
|
|
|
int match_start_point, int max_return_elements, SBStringList &matches,
|
|
|
|
|
SBStringList &descriptions) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(int, SBCommandInterpreter,
|
|
|
|
|
HandleCompletionWithDescriptions,
|
|
|
|
|
(const char *, const char *, const char *, int, int,
|
|
|
|
|
lldb::SBStringList &, lldb::SBStringList &),
|
|
|
|
|
current_line, cursor, last_char, match_start_point,
|
|
|
|
|
max_return_elements, matches, descriptions);
|
|
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// Sanity check the arguments that are passed in: cursor & last_char have to
|
|
|
|
|
// be within the current_line.
|
2015-10-31 01:22:59 +00:00
|
|
|
if (current_line == nullptr || cursor == nullptr || last_char == nullptr)
|
2011-12-05 19:24:15 +00:00
|
|
|
return 0;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-12-05 19:24:15 +00:00
|
|
|
if (cursor < current_line || last_char < current_line)
|
|
|
|
|
return 0;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-12-05 19:24:15 +00:00
|
|
|
size_t current_line_size = strlen(current_line);
|
2014-04-02 03:51:35 +00:00
|
|
|
if (cursor - current_line > static_cast<ptrdiff_t>(current_line_size) ||
|
|
|
|
|
last_char - current_line > static_cast<ptrdiff_t>(current_line_size))
|
2011-12-05 19:24:15 +00:00
|
|
|
return 0;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 07:41:23 +00:00
|
|
|
if (!IsValid())
|
|
|
|
|
return 0;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 07:41:23 +00:00
|
|
|
lldb_private::StringList lldb_matches, lldb_descriptions;
|
|
|
|
|
CompletionResult result;
|
|
|
|
|
CompletionRequest request(current_line, cursor - current_line, result);
|
|
|
|
|
m_opaque_ptr->HandleCompletion(request);
|
|
|
|
|
result.GetMatches(lldb_matches);
|
|
|
|
|
result.GetDescriptions(lldb_descriptions);
|
|
|
|
|
|
|
|
|
|
// Make the result array indexed from 1 again by adding the 'common prefix'
|
|
|
|
|
// of all completions as element 0. This is done to emulate the old API.
|
|
|
|
|
if (request.GetParsedLine().GetArgumentCount() == 0) {
|
|
|
|
|
// If we got an empty string, insert nothing.
|
|
|
|
|
lldb_matches.InsertStringAtIndex(0, "");
|
|
|
|
|
lldb_descriptions.InsertStringAtIndex(0, "");
|
|
|
|
|
} else {
|
|
|
|
|
// Now figure out if there is a common substring, and if so put that in
|
|
|
|
|
// element 0, otherwise put an empty string in element 0.
|
|
|
|
|
std::string command_partial_str = request.GetCursorArgumentPrefix().str();
|
|
|
|
|
|
|
|
|
|
std::string common_prefix = lldb_matches.LongestCommonPrefix();
|
|
|
|
|
const size_t partial_name_len = command_partial_str.size();
|
|
|
|
|
common_prefix.erase(0, partial_name_len);
|
|
|
|
|
|
|
|
|
|
// If we matched a unique single command, add a space... Only do this if
|
|
|
|
|
// the completer told us this was a complete word, however...
|
|
|
|
|
if (lldb_matches.GetSize() == 1) {
|
2019-09-13 08:26:00 +00:00
|
|
|
char quote_char = request.GetParsedArg().GetQuoteChar();
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 07:41:23 +00:00
|
|
|
common_prefix =
|
|
|
|
|
Args::EscapeLLDBCommandArgument(common_prefix, quote_char);
|
|
|
|
|
if (request.GetParsedArg().IsQuoted())
|
|
|
|
|
common_prefix.push_back(quote_char);
|
|
|
|
|
common_prefix.push_back(' ');
|
|
|
|
|
}
|
|
|
|
|
lldb_matches.InsertStringAtIndex(0, common_prefix.c_str());
|
|
|
|
|
lldb_descriptions.InsertStringAtIndex(0, "");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 07:41:23 +00:00
|
|
|
SBStringList temp_matches_list(&lldb_matches);
|
|
|
|
|
matches.AppendList(temp_matches_list);
|
|
|
|
|
SBStringList temp_descriptions_list(&lldb_descriptions);
|
|
|
|
|
descriptions.AppendList(temp_descriptions_list);
|
|
|
|
|
return result.GetNumberOfResults();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2018-09-13 21:26:00 +00:00
|
|
|
int SBCommandInterpreter::HandleCompletionWithDescriptions(
|
|
|
|
|
const char *current_line, uint32_t cursor_pos, int match_start_point,
|
|
|
|
|
int max_return_elements, SBStringList &matches,
|
|
|
|
|
SBStringList &descriptions) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(int, SBCommandInterpreter,
|
|
|
|
|
HandleCompletionWithDescriptions,
|
|
|
|
|
(const char *, uint32_t, int, int, lldb::SBStringList &,
|
|
|
|
|
lldb::SBStringList &),
|
|
|
|
|
current_line, cursor_pos, match_start_point,
|
|
|
|
|
max_return_elements, matches, descriptions);
|
|
|
|
|
|
2018-09-13 21:26:00 +00:00
|
|
|
const char *cursor = current_line + cursor_pos;
|
|
|
|
|
const char *last_char = current_line + strlen(current_line);
|
|
|
|
|
return HandleCompletionWithDescriptions(
|
|
|
|
|
current_line, cursor, last_char, match_start_point, max_return_elements,
|
|
|
|
|
matches, descriptions);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
int SBCommandInterpreter::HandleCompletion(const char *current_line,
|
2011-09-21 01:17:13 +00:00
|
|
|
uint32_t cursor_pos,
|
2010-06-08 16:52:24 +00:00
|
|
|
int match_start_point,
|
|
|
|
|
int max_return_elements,
|
2011-09-21 01:17:13 +00:00
|
|
|
lldb::SBStringList &matches) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(int, SBCommandInterpreter, HandleCompletion,
|
|
|
|
|
(const char *, uint32_t, int, int, lldb::SBStringList &),
|
|
|
|
|
current_line, cursor_pos, match_start_point,
|
|
|
|
|
max_return_elements, matches);
|
|
|
|
|
|
2011-09-21 01:17:13 +00:00
|
|
|
const char *cursor = current_line + cursor_pos;
|
|
|
|
|
const char *last_char = current_line + strlen(current_line);
|
|
|
|
|
return HandleCompletion(current_line, cursor, last_char, match_start_point,
|
|
|
|
|
max_return_elements, matches);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
bool SBCommandInterpreter::HasCommands() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasCommands);
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
return (IsValid() ? m_opaque_ptr->HasCommands() : false);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
bool SBCommandInterpreter::HasAliases() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasAliases);
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
return (IsValid() ? m_opaque_ptr->HasAliases() : false);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
bool SBCommandInterpreter::HasAliasOptions() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasAliasOptions);
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
return (IsValid() ? m_opaque_ptr->HasAliasOptions() : false);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-30 04:51:46 +00:00
|
|
|
SBProcess SBCommandInterpreter::GetProcess() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBCommandInterpreter, GetProcess);
|
|
|
|
|
|
2012-01-30 07:41:31 +00:00
|
|
|
SBProcess sb_process;
|
|
|
|
|
ProcessSP process_sp;
|
2015-10-31 01:22:59 +00:00
|
|
|
if (IsValid()) {
|
2010-12-20 20:49:23 +00:00
|
|
|
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
|
|
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2012-01-30 07:41:31 +00:00
|
|
|
process_sp = target_sp->GetProcessSP();
|
|
|
|
|
sb_process.SetSP(process_sp);
|
2014-10-14 01:20:07 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-10-14 01:20:07 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_process);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-14 01:20:07 +00:00
|
|
|
SBDebugger SBCommandInterpreter::GetDebugger() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBDebugger, SBCommandInterpreter,
|
|
|
|
|
GetDebugger);
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBDebugger sb_debugger;
|
2015-10-31 01:22:59 +00:00
|
|
|
if (IsValid())
|
2014-04-04 04:06:10 +00:00
|
|
|
sb_debugger.reset(m_opaque_ptr->GetDebugger().shared_from_this());
|
2010-10-30 04:51:46 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_debugger);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2012-09-28 23:57:51 +00:00
|
|
|
bool SBCommandInterpreter::GetPromptOnQuit() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, GetPromptOnQuit);
|
|
|
|
|
|
2012-09-28 23:57:51 +00:00
|
|
|
return (IsValid() ? m_opaque_ptr->GetPromptOnQuit() : false);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-23 22:45:13 +00:00
|
|
|
void SBCommandInterpreter::SetPromptOnQuit(bool b) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommandInterpreter, SetPromptOnQuit, (bool), b);
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
if (IsValid())
|
|
|
|
|
m_opaque_ptr->SetPromptOnQuit(b);
|
2015-03-23 22:45:13 +00:00
|
|
|
}
|
|
|
|
|
|
2018-07-11 17:18:01 +00:00
|
|
|
void SBCommandInterpreter::AllowExitCodeOnQuit(bool allow) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommandInterpreter, AllowExitCodeOnQuit, (bool),
|
|
|
|
|
allow);
|
|
|
|
|
|
2018-07-11 17:18:01 +00:00
|
|
|
if (m_opaque_ptr)
|
|
|
|
|
m_opaque_ptr->AllowExitCodeOnQuit(allow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SBCommandInterpreter::HasCustomQuitExitCode() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasCustomQuitExitCode);
|
|
|
|
|
|
2018-07-11 17:18:01 +00:00
|
|
|
bool exited = false;
|
|
|
|
|
if (m_opaque_ptr)
|
|
|
|
|
m_opaque_ptr->GetQuitExitCode(exited);
|
|
|
|
|
return exited;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SBCommandInterpreter::GetQuitStatus() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(int, SBCommandInterpreter, GetQuitStatus);
|
|
|
|
|
|
2018-07-11 17:18:01 +00:00
|
|
|
bool exited = false;
|
|
|
|
|
return (m_opaque_ptr ? m_opaque_ptr->GetQuitExitCode(exited) : 0);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-23 22:45:13 +00:00
|
|
|
void SBCommandInterpreter::ResolveCommand(const char *command_line,
|
|
|
|
|
SBCommandReturnObject &result) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommandInterpreter, ResolveCommand,
|
|
|
|
|
(const char *, lldb::SBCommandReturnObject &),
|
|
|
|
|
command_line, result);
|
|
|
|
|
|
2015-04-23 20:00:25 +00:00
|
|
|
result.Clear();
|
2015-10-31 01:22:59 +00:00
|
|
|
if (command_line && IsValid()) {
|
2015-03-23 22:45:13 +00:00
|
|
|
m_opaque_ptr->ResolveCommand(command_line, result.ref());
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2015-03-23 22:45:13 +00:00
|
|
|
result->AppendError(
|
|
|
|
|
"SBCommandInterpreter or the command line is not valid");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-03-23 22:45:13 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-23 20:00:25 +00:00
|
|
|
CommandInterpreter *SBCommandInterpreter::get() { return m_opaque_ptr; }
|
|
|
|
|
|
2010-06-23 01:19:29 +00:00
|
|
|
CommandInterpreter &SBCommandInterpreter::ref() {
|
|
|
|
|
assert(m_opaque_ptr);
|
|
|
|
|
return *m_opaque_ptr;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-23 01:19:29 +00:00
|
|
|
void SBCommandInterpreter::reset(
|
|
|
|
|
lldb_private::CommandInterpreter *interpreter) {
|
|
|
|
|
m_opaque_ptr = interpreter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SBCommandInterpreter::SourceInitFileInHomeDirectory(
|
2010-06-08 16:52:24 +00:00
|
|
|
SBCommandReturnObject &result) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory,
|
|
|
|
|
(lldb::SBCommandReturnObject &), result);
|
|
|
|
|
|
2015-04-23 20:00:25 +00:00
|
|
|
result.Clear();
|
2010-06-23 01:19:29 +00:00
|
|
|
if (IsValid()) {
|
|
|
|
|
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
|
2016-05-19 05:13:57 +00:00
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
2010-12-20 20:49:23 +00:00
|
|
|
if (target_sp)
|
2010-06-23 01:19:29 +00:00
|
|
|
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
|
2019-05-17 22:53:04 +00:00
|
|
|
m_opaque_ptr->SourceInitFileHome(result.ref());
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2010-06-23 01:19:29 +00:00
|
|
|
result->AppendError("SBCommandInterpreter is not valid");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2020-08-19 22:04:35 +02:00
|
|
|
void SBCommandInterpreter::SourceInitFileInHomeDirectory(
|
|
|
|
|
SBCommandReturnObject &result, bool is_repl) {
|
|
|
|
|
LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory,
|
|
|
|
|
(lldb::SBCommandReturnObject &, bool), result, is_repl);
|
|
|
|
|
|
|
|
|
|
result.Clear();
|
|
|
|
|
if (IsValid()) {
|
|
|
|
|
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
|
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
|
if (target_sp)
|
|
|
|
|
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
|
|
|
|
|
m_opaque_ptr->SourceInitFileHome(result.ref(), is_repl);
|
|
|
|
|
} else {
|
|
|
|
|
result->AppendError("SBCommandInterpreter is not valid");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory(
|
|
|
|
|
SBCommandReturnObject &result) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommandInterpreter,
|
|
|
|
|
SourceInitFileInCurrentWorkingDirectory,
|
|
|
|
|
(lldb::SBCommandReturnObject &), result);
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
result.Clear();
|
2015-10-31 01:22:59 +00:00
|
|
|
if (IsValid()) {
|
2010-12-20 20:49:23 +00:00
|
|
|
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
|
2016-05-19 05:13:57 +00:00
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
|
if (target_sp)
|
|
|
|
|
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
|
2019-05-17 22:53:04 +00:00
|
|
|
m_opaque_ptr->SourceInitFileCwd(result.ref());
|
2010-06-23 01:19:29 +00:00
|
|
|
} else {
|
|
|
|
|
result->AppendError("SBCommandInterpreter is not valid");
|
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SBBroadcaster SBCommandInterpreter::GetBroadcaster() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBroadcaster, SBCommandInterpreter,
|
|
|
|
|
GetBroadcaster);
|
|
|
|
|
|
2010-10-26 03:11:13 +00:00
|
|
|
|
2010-06-23 01:19:29 +00:00
|
|
|
SBBroadcaster broadcaster(m_opaque_ptr, false);
|
2010-10-26 03:11:13 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(broadcaster);
|
2012-02-16 06:50:00 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-20 02:15:07 +00:00
|
|
|
const char *SBCommandInterpreter::GetBroadcasterClass() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBCommandInterpreter,
|
|
|
|
|
GetBroadcasterClass);
|
|
|
|
|
|
2011-02-20 02:15:07 +00:00
|
|
|
return CommandInterpreter::GetStaticBroadcasterClass().AsCString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *SBCommandInterpreter::GetArgumentTypeAsCString(
|
|
|
|
|
const lldb::CommandArgumentType arg_type) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_STATIC_METHOD(const char *, SBCommandInterpreter,
|
|
|
|
|
GetArgumentTypeAsCString,
|
|
|
|
|
(const lldb::CommandArgumentType), arg_type);
|
|
|
|
|
|
2011-02-20 02:15:07 +00:00
|
|
|
return CommandObject::GetArgumentTypeAsCString(arg_type);
|
|
|
|
|
}
|
|
|
|
|
|
Fix handling of CommandInterpreter's events in lldb-mi
Summary:
Previously lldb-mi contains a stub for that but it didn't work and all CommanInterpreter's events were ignored.
This commit adds a handling of CommandInterpreter's events in lldb-mi.
Steps:
# Fix CMICmnLLDBDebugger::InitSBListener
# Add SBCommandInterpreter::EventIsCommandInterpreterEvent
# Exit on lldb::SBCommandInterpreter::eBroadcastBitQuitCommandReceived
All tests pass on OS X.
In further we can remove "quit" hack in lldb-mi.
Test Plan:
# Create start_script file:
```
target create ~/p/hello
b main
r
quit
```
# Run lldb-mi --interpreter
# Execute start_script file by following command:
```
-interpreter-exec console "command source start_script"
```
Log:
```
$ bin/lldb-mi --interpreter
(gdb)
-interpreter-exec console "command source start_script"
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) b main
Breakpoint 1: where = hello`main + 29 at hello.cpp:12, address = 0x0000000100000e2d
(lldb) r
Process 1582 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) quit
^done
(gdb)
=thread-created,id="1",group-id="i1"
=thread-selected,id="1"
(gdb)
=shlibs-added,shlib-info=[num="1",name="hello",dyld-addr="-",reason="dyld",path="/Users/IliaK/p/hello",loaded_addr="-",dsym-objpath="/Users/IliaK/p/hello.dSYM/Contents/Resources/DWARF/hello"]
...
=shlibs-added,shlib-info=[num="132",name="libDiagnosticMessagesClient.dylib",dyld-addr="0x7fff91705000",reason="dyld",path="/usr/lib/libDiagnosticMessagesClient.dylib",loaded_addr="0x7fff91705000"]
(gdb)
*stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x100000e2d",func="main",args=[{name="argc",value="1"},{name="argv",value="0x00007fff5fbffc88"}],file="hello.cpp",fullname="/Users/IliaK/p/hello.cpp",line="12"},thread-id="1",stopped-threads="all"
(gdb)<press Enter>
MI: Program exited OK
```
Reviewers: abidh, clayborg
Reviewed By: abidh
Subscribers: jingham, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8382
llvm-svn: 232891
2015-03-21 10:53:37 +00:00
|
|
|
const char *SBCommandInterpreter::GetArgumentDescriptionAsCString(
|
|
|
|
|
const lldb::CommandArgumentType arg_type) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_STATIC_METHOD(const char *, SBCommandInterpreter,
|
|
|
|
|
GetArgumentDescriptionAsCString,
|
|
|
|
|
(const lldb::CommandArgumentType), arg_type);
|
|
|
|
|
|
2015-03-21 11:11:07 +00:00
|
|
|
return CommandObject::GetArgumentDescriptionAsCString(arg_type);
|
Fix handling of CommandInterpreter's events in lldb-mi
Summary:
Previously lldb-mi contains a stub for that but it didn't work and all CommanInterpreter's events were ignored.
This commit adds a handling of CommandInterpreter's events in lldb-mi.
Steps:
# Fix CMICmnLLDBDebugger::InitSBListener
# Add SBCommandInterpreter::EventIsCommandInterpreterEvent
# Exit on lldb::SBCommandInterpreter::eBroadcastBitQuitCommandReceived
All tests pass on OS X.
In further we can remove "quit" hack in lldb-mi.
Test Plan:
# Create start_script file:
```
target create ~/p/hello
b main
r
quit
```
# Run lldb-mi --interpreter
# Execute start_script file by following command:
```
-interpreter-exec console "command source start_script"
```
Log:
```
$ bin/lldb-mi --interpreter
(gdb)
-interpreter-exec console "command source start_script"
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) b main
Breakpoint 1: where = hello`main + 29 at hello.cpp:12, address = 0x0000000100000e2d
(lldb) r
Process 1582 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) quit
^done
(gdb)
=thread-created,id="1",group-id="i1"
=thread-selected,id="1"
(gdb)
=shlibs-added,shlib-info=[num="1",name="hello",dyld-addr="-",reason="dyld",path="/Users/IliaK/p/hello",loaded_addr="-",dsym-objpath="/Users/IliaK/p/hello.dSYM/Contents/Resources/DWARF/hello"]
...
=shlibs-added,shlib-info=[num="132",name="libDiagnosticMessagesClient.dylib",dyld-addr="0x7fff91705000",reason="dyld",path="/usr/lib/libDiagnosticMessagesClient.dylib",loaded_addr="0x7fff91705000"]
(gdb)
*stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x100000e2d",func="main",args=[{name="argc",value="1"},{name="argv",value="0x00007fff5fbffc88"}],file="hello.cpp",fullname="/Users/IliaK/p/hello.cpp",line="12"},thread-id="1",stopped-threads="all"
(gdb)<press Enter>
MI: Program exited OK
```
Reviewers: abidh, clayborg
Reviewed By: abidh
Subscribers: jingham, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8382
llvm-svn: 232891
2015-03-21 10:53:37 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-02-29 04:21:24 +00:00
|
|
|
bool SBCommandInterpreter::EventIsCommandInterpreterEvent(
|
|
|
|
|
const lldb::SBEvent &event) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_STATIC_METHOD(bool, SBCommandInterpreter,
|
|
|
|
|
EventIsCommandInterpreterEvent,
|
|
|
|
|
(const lldb::SBEvent &), event);
|
|
|
|
|
|
2015-03-21 11:11:07 +00:00
|
|
|
return event.GetBroadcasterClass() ==
|
2012-02-29 04:21:24 +00:00
|
|
|
SBCommandInterpreter::GetBroadcasterClass();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-29 04:21:24 +00:00
|
|
|
bool SBCommandInterpreter::SetCommandOverrideCallback(
|
|
|
|
|
const char *command_name, lldb::CommandOverrideCallback callback,
|
|
|
|
|
void *baton) {
|
2019-03-08 19:09:27 +00:00
|
|
|
LLDB_RECORD_DUMMY(bool, SBCommandInterpreter, SetCommandOverrideCallback,
|
|
|
|
|
(const char *, lldb::CommandOverrideCallback, void *),
|
|
|
|
|
command_name, callback, baton);
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
if (command_name && command_name[0] && IsValid()) {
|
2016-10-05 21:14:56 +00:00
|
|
|
llvm::StringRef command_name_str = command_name;
|
2012-05-08 04:29:20 +00:00
|
|
|
CommandObject *cmd_obj =
|
|
|
|
|
m_opaque_ptr->GetCommandObjectForCommand(command_name_str);
|
2012-02-29 04:21:24 +00:00
|
|
|
if (cmd_obj) {
|
2012-05-08 04:29:20 +00:00
|
|
|
assert(command_name_str.empty());
|
2012-02-29 04:21:24 +00:00
|
|
|
cmd_obj->SetOverrideCallback(callback, baton);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-02-29 04:21:24 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2011-02-20 02:15:07 +00:00
|
|
|
|
2012-09-28 23:57:51 +00:00
|
|
|
lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand(const char *name,
|
|
|
|
|
const char *help) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBCommand, SBCommandInterpreter, AddMultiwordCommand,
|
|
|
|
|
(const char *, const char *), name, help);
|
|
|
|
|
|
2021-10-12 10:55:24 -07:00
|
|
|
lldb::CommandObjectSP new_command_sp(
|
|
|
|
|
new CommandObjectMultiword(*m_opaque_ptr, name, help));
|
|
|
|
|
new_command_sp->GetAsMultiwordCommand()->SetRemovable(true);
|
|
|
|
|
Status add_error = m_opaque_ptr->AddUserCommand(name, new_command_sp, true);
|
|
|
|
|
if (add_error.Success())
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp));
|
|
|
|
|
return LLDB_RECORD_RESULT(lldb::SBCommand());
|
2012-09-28 23:57:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::SBCommand SBCommandInterpreter::AddCommand(
|
|
|
|
|
const char *name, lldb::SBCommandPluginInterface *impl, const char *help) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
|
lldb::SBCommand, SBCommandInterpreter, AddCommand,
|
|
|
|
|
(const char *, lldb::SBCommandPluginInterface *, const char *), name,
|
|
|
|
|
impl, help);
|
|
|
|
|
|
2020-04-03 17:16:15 -07:00
|
|
|
return LLDB_RECORD_RESULT(AddCommand(name, impl, help, /*syntax=*/nullptr,
|
|
|
|
|
/*auto_repeat_command=*/""))
|
2012-09-28 23:57:51 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-29 07:46:32 +00:00
|
|
|
lldb::SBCommand
|
|
|
|
|
SBCommandInterpreter::AddCommand(const char *name,
|
|
|
|
|
lldb::SBCommandPluginInterface *impl,
|
|
|
|
|
const char *help, const char *syntax) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand,
|
|
|
|
|
(const char *, lldb::SBCommandPluginInterface *,
|
|
|
|
|
const char *, const char *),
|
|
|
|
|
name, impl, help, syntax);
|
2020-04-03 17:16:15 -07:00
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
|
AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/""))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::SBCommand SBCommandInterpreter::AddCommand(
|
|
|
|
|
const char *name, lldb::SBCommandPluginInterface *impl, const char *help,
|
|
|
|
|
const char *syntax, const char *auto_repeat_command) {
|
|
|
|
|
LLDB_RECORD_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand,
|
|
|
|
|
(const char *, lldb::SBCommandPluginInterface *,
|
|
|
|
|
const char *, const char *, const char *),
|
|
|
|
|
name, impl, help, syntax, auto_repeat_command);
|
2019-03-06 00:06:00 +00:00
|
|
|
|
2016-07-29 07:46:32 +00:00
|
|
|
lldb::CommandObjectSP new_command_sp;
|
2019-02-11 23:13:08 +00:00
|
|
|
new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
|
2020-04-03 17:16:15 -07:00
|
|
|
*m_opaque_ptr, name, impl, help, syntax, /*flags=*/0,
|
|
|
|
|
auto_repeat_command);
|
2016-07-29 07:46:32 +00:00
|
|
|
|
2021-10-12 10:55:24 -07:00
|
|
|
Status add_error = m_opaque_ptr->AddUserCommand(name, new_command_sp, true);
|
|
|
|
|
if (add_error.Success())
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp));
|
|
|
|
|
return LLDB_RECORD_RESULT(lldb::SBCommand());
|
2016-07-29 07:46:32 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
SBCommand::SBCommand() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommand); }
|
2012-09-28 23:57:51 +00:00
|
|
|
|
|
|
|
|
SBCommand::SBCommand(lldb::CommandObjectSP cmd_sp) : m_opaque_sp(cmd_sp) {}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
bool SBCommand::IsValid() {
|
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommand, IsValid);
|
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 13:58:46 +00:00
|
|
|
return this->operator bool();
|
|
|
|
|
}
|
|
|
|
|
SBCommand::operator bool() const {
|
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommand, operator bool);
|
2019-03-06 00:06:00 +00:00
|
|
|
|
|
|
|
|
return m_opaque_sp.get() != nullptr;
|
|
|
|
|
}
|
2012-09-28 23:57:51 +00:00
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
const char *SBCommand::GetName() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommand, GetName);
|
|
|
|
|
|
2016-10-05 21:14:38 +00:00
|
|
|
return (IsValid() ? ConstString(m_opaque_sp->GetCommandName()).AsCString() : nullptr);
|
2012-09-28 23:57:51 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
const char *SBCommand::GetHelp() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommand, GetHelp);
|
|
|
|
|
|
2016-11-12 20:41:02 +00:00
|
|
|
return (IsValid() ? ConstString(m_opaque_sp->GetHelp()).AsCString()
|
|
|
|
|
: nullptr);
|
2012-09-28 23:57:51 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
const char *SBCommand::GetHelpLong() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommand, GetHelpLong);
|
|
|
|
|
|
2016-11-12 20:41:02 +00:00
|
|
|
return (IsValid() ? ConstString(m_opaque_sp->GetHelpLong()).AsCString()
|
|
|
|
|
: nullptr);
|
2015-03-13 22:32:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SBCommand::SetHelp(const char *help) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommand, SetHelp, (const char *), help);
|
|
|
|
|
|
2015-03-13 22:32:11 +00:00
|
|
|
if (IsValid())
|
|
|
|
|
m_opaque_sp->SetHelp(help);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SBCommand::SetHelpLong(const char *help) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommand, SetHelpLong, (const char *), help);
|
|
|
|
|
|
2015-03-13 22:32:11 +00:00
|
|
|
if (IsValid())
|
|
|
|
|
m_opaque_sp->SetHelpLong(help);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-28 23:57:51 +00:00
|
|
|
lldb::SBCommand SBCommand::AddMultiwordCommand(const char *name,
|
|
|
|
|
const char *help) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBCommand, SBCommand, AddMultiwordCommand,
|
|
|
|
|
(const char *, const char *), name, help);
|
|
|
|
|
|
2012-09-28 23:57:51 +00:00
|
|
|
if (!IsValid())
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(lldb::SBCommand());
|
2015-10-31 01:22:59 +00:00
|
|
|
if (!m_opaque_sp->IsMultiwordObject())
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(lldb::SBCommand());
|
2016-07-29 07:46:32 +00:00
|
|
|
CommandObjectMultiword *new_command = new CommandObjectMultiword(
|
|
|
|
|
m_opaque_sp->GetCommandInterpreter(), name, help);
|
|
|
|
|
new_command->SetRemovable(true);
|
|
|
|
|
lldb::CommandObjectSP new_command_sp(new_command);
|
|
|
|
|
if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp))
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp));
|
|
|
|
|
return LLDB_RECORD_RESULT(lldb::SBCommand());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-09-28 23:57:51 +00:00
|
|
|
lldb::SBCommand SBCommand::AddCommand(const char *name,
|
|
|
|
|
lldb::SBCommandPluginInterface *impl,
|
|
|
|
|
const char *help) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
|
lldb::SBCommand, SBCommand, AddCommand,
|
|
|
|
|
(const char *, lldb::SBCommandPluginInterface *, const char *), name,
|
|
|
|
|
impl, help);
|
2020-04-03 17:16:15 -07:00
|
|
|
return LLDB_RECORD_RESULT(AddCommand(name, impl, help, /*syntax=*/nullptr,
|
|
|
|
|
/*auto_repeat_command=*/""))
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-09-28 23:57:51 +00:00
|
|
|
lldb::SBCommand SBCommand::AddCommand(const char *name,
|
|
|
|
|
lldb::SBCommandPluginInterface *impl,
|
2016-07-29 07:46:32 +00:00
|
|
|
const char *help, const char *syntax) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBCommand, SBCommand, AddCommand,
|
|
|
|
|
(const char *, lldb::SBCommandPluginInterface *,
|
|
|
|
|
const char *, const char *),
|
|
|
|
|
name, impl, help, syntax);
|
2020-04-03 17:16:15 -07:00
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
|
AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/""))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::SBCommand SBCommand::AddCommand(const char *name,
|
|
|
|
|
lldb::SBCommandPluginInterface *impl,
|
|
|
|
|
const char *help, const char *syntax,
|
|
|
|
|
const char *auto_repeat_command) {
|
|
|
|
|
LLDB_RECORD_METHOD(lldb::SBCommand, SBCommand, AddCommand,
|
|
|
|
|
(const char *, lldb::SBCommandPluginInterface *,
|
|
|
|
|
const char *, const char *, const char *),
|
|
|
|
|
name, impl, help, syntax, auto_repeat_command);
|
2019-03-06 00:06:00 +00:00
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
if (!IsValid())
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(lldb::SBCommand());
|
2015-10-31 01:22:59 +00:00
|
|
|
if (!m_opaque_sp->IsMultiwordObject())
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(lldb::SBCommand());
|
2012-09-28 23:57:51 +00:00
|
|
|
lldb::CommandObjectSP new_command_sp;
|
2019-02-11 23:13:08 +00:00
|
|
|
new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
|
2020-04-03 17:16:15 -07:00
|
|
|
m_opaque_sp->GetCommandInterpreter(), name, impl, help, syntax,
|
|
|
|
|
/*flags=*/0, auto_repeat_command);
|
2012-09-28 23:57:51 +00:00
|
|
|
if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp))
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp));
|
|
|
|
|
return LLDB_RECORD_RESULT(lldb::SBCommand());
|
2016-07-29 07:46:32 +00:00
|
|
|
}
|
|
|
|
|
|
2015-05-27 05:04:35 +00:00
|
|
|
uint32_t SBCommand::GetFlags() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBCommand, GetFlags);
|
|
|
|
|
|
2015-10-31 01:22:59 +00:00
|
|
|
return (IsValid() ? m_opaque_sp->GetFlags().Get() : 0);
|
2015-05-27 05:04:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SBCommand::SetFlags(uint32_t flags) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommand, SetFlags, (uint32_t), flags);
|
|
|
|
|
|
2015-05-27 05:04:35 +00:00
|
|
|
if (IsValid())
|
|
|
|
|
m_opaque_sp->GetFlags().Set(flags);
|
|
|
|
|
}
|
2019-03-19 17:13:13 +00:00
|
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
|
namespace repro {
|
|
|
|
|
|
2020-04-30 13:28:42 -07:00
|
|
|
template <> void RegisterMethods<SBCommandInterpreter>(Registry &R) {
|
2019-03-19 17:13:13 +00:00
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreter,
|
|
|
|
|
(lldb_private::CommandInterpreter *));
|
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreter,
|
|
|
|
|
(const lldb::SBCommandInterpreter &));
|
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
|
const lldb::SBCommandInterpreter &,
|
|
|
|
|
SBCommandInterpreter, operator=,(const lldb::SBCommandInterpreter &));
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreter, IsValid, ());
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreter, operator bool, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, CommandExists,
|
|
|
|
|
(const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, AliasExists,
|
|
|
|
|
(const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, IsActive, ());
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreter, WasInterrupted, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBCommandInterpreter,
|
|
|
|
|
GetIOHandlerControlSequence, (char));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::ReturnStatus, SBCommandInterpreter,
|
|
|
|
|
HandleCommand,
|
|
|
|
|
(const char *, lldb::SBCommandReturnObject &, bool));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::ReturnStatus, SBCommandInterpreter,
|
|
|
|
|
HandleCommand,
|
|
|
|
|
(const char *, lldb::SBExecutionContext &,
|
|
|
|
|
lldb::SBCommandReturnObject &, bool));
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandInterpreter, HandleCommandsFromFile,
|
|
|
|
|
(lldb::SBFileSpec &, lldb::SBExecutionContext &,
|
|
|
|
|
lldb::SBCommandInterpreterRunOptions &,
|
|
|
|
|
lldb::SBCommandReturnObject));
|
|
|
|
|
LLDB_REGISTER_METHOD(int, SBCommandInterpreter, HandleCompletion,
|
|
|
|
|
(const char *, const char *, const char *, int, int,
|
|
|
|
|
lldb::SBStringList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(int, SBCommandInterpreter,
|
|
|
|
|
HandleCompletionWithDescriptions,
|
|
|
|
|
(const char *, const char *, const char *, int, int,
|
|
|
|
|
lldb::SBStringList &, lldb::SBStringList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(int, SBCommandInterpreter,
|
|
|
|
|
HandleCompletionWithDescriptions,
|
|
|
|
|
(const char *, uint32_t, int, int,
|
|
|
|
|
lldb::SBStringList &, lldb::SBStringList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
|
int, SBCommandInterpreter, HandleCompletion,
|
|
|
|
|
(const char *, uint32_t, int, int, lldb::SBStringList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasCommands, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasAliases, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasAliasOptions, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBProcess, SBCommandInterpreter, GetProcess, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBDebugger, SBCommandInterpreter, GetDebugger,
|
|
|
|
|
());
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, GetPromptOnQuit, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandInterpreter, SetPromptOnQuit, (bool));
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandInterpreter, AllowExitCodeOnQuit,
|
|
|
|
|
(bool));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasCustomQuitExitCode, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(int, SBCommandInterpreter, GetQuitStatus, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandInterpreter, ResolveCommand,
|
|
|
|
|
(const char *, lldb::SBCommandReturnObject &));
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
|
|
|
|
|
SourceInitFileInHomeDirectory,
|
|
|
|
|
(lldb::SBCommandReturnObject &));
|
2020-08-19 22:04:35 +02:00
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
|
|
|
|
|
SourceInitFileInHomeDirectory,
|
|
|
|
|
(lldb::SBCommandReturnObject &, bool));
|
2019-03-19 17:13:13 +00:00
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
|
|
|
|
|
SourceInitFileInCurrentWorkingDirectory,
|
|
|
|
|
(lldb::SBCommandReturnObject &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBroadcaster, SBCommandInterpreter,
|
|
|
|
|
GetBroadcaster, ());
|
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(const char *, SBCommandInterpreter,
|
|
|
|
|
GetBroadcasterClass, ());
|
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(const char *, SBCommandInterpreter,
|
|
|
|
|
GetArgumentTypeAsCString,
|
|
|
|
|
(const lldb::CommandArgumentType));
|
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(const char *, SBCommandInterpreter,
|
|
|
|
|
GetArgumentDescriptionAsCString,
|
|
|
|
|
(const lldb::CommandArgumentType));
|
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(bool, SBCommandInterpreter,
|
|
|
|
|
EventIsCommandInterpreterEvent,
|
|
|
|
|
(const lldb::SBEvent &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommandInterpreter,
|
|
|
|
|
AddMultiwordCommand, (const char *, const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
|
lldb::SBCommand, SBCommandInterpreter, AddCommand,
|
|
|
|
|
(const char *, lldb::SBCommandPluginInterface *, const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand,
|
|
|
|
|
(const char *, lldb::SBCommandPluginInterface *,
|
|
|
|
|
const char *, const char *));
|
2020-04-03 17:16:15 -07:00
|
|
|
LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand,
|
|
|
|
|
(const char *, lldb::SBCommandPluginInterface *,
|
|
|
|
|
const char *, const char *, const char *));
|
2019-03-19 17:13:13 +00:00
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBCommand, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBCommand, IsValid, ());
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBCommand, operator bool, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBCommand, GetName, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBCommand, GetHelp, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBCommand, GetHelpLong, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommand, SetHelp, (const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommand, SetHelpLong, (const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommand, AddMultiwordCommand,
|
|
|
|
|
(const char *, const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
|
lldb::SBCommand, SBCommand, AddCommand,
|
|
|
|
|
(const char *, lldb::SBCommandPluginInterface *, const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommand, AddCommand,
|
|
|
|
|
(const char *, lldb::SBCommandPluginInterface *,
|
|
|
|
|
const char *, const char *));
|
2020-04-03 17:16:15 -07:00
|
|
|
LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommand, AddCommand,
|
|
|
|
|
(const char *, lldb::SBCommandPluginInterface *,
|
|
|
|
|
const char *, const char *, const char *));
|
2019-03-19 17:13:13 +00:00
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBCommand, GetFlags, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommand, SetFlags, (uint32_t));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|