[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 15:23:27 +08:00
|
|
|
//===-- SBDebugger.cpp ----------------------------------------------------===//
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
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
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
#include "SBReproducerPrivate.h"
|
2018-05-26 04:28:16 +08:00
|
|
|
#include "SystemInitializerFull.h"
|
|
|
|
|
2010-06-09 15:37:52 +08:00
|
|
|
#include "lldb/API/SBDebugger.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-03-25 05:19:54 +08:00
|
|
|
#include "lldb/lldb-private.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-06-09 15:37:52 +08:00
|
|
|
#include "lldb/API/SBBroadcaster.h"
|
|
|
|
#include "lldb/API/SBCommandInterpreter.h"
|
2020-05-01 04:28:42 +08:00
|
|
|
#include "lldb/API/SBCommandInterpreterRunOptions.h"
|
2010-06-09 15:37:52 +08:00
|
|
|
#include "lldb/API/SBCommandReturnObject.h"
|
2011-04-30 09:09:13 +08:00
|
|
|
#include "lldb/API/SBError.h"
|
2010-06-09 15:37:52 +08:00
|
|
|
#include "lldb/API/SBEvent.h"
|
2019-10-03 12:04:48 +08:00
|
|
|
#include "lldb/API/SBFile.h"
|
2010-06-09 15:37:52 +08:00
|
|
|
#include "lldb/API/SBFrame.h"
|
|
|
|
#include "lldb/API/SBListener.h"
|
|
|
|
#include "lldb/API/SBProcess.h"
|
|
|
|
#include "lldb/API/SBSourceManager.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-09-04 08:03:46 +08:00
|
|
|
#include "lldb/API/SBStringList.h"
|
2017-08-09 17:20:40 +08:00
|
|
|
#include "lldb/API/SBStructuredData.h"
|
2010-09-04 08:03:46 +08:00
|
|
|
#include "lldb/API/SBTarget.h"
|
|
|
|
#include "lldb/API/SBThread.h"
|
2012-02-15 10:34:21 +08:00
|
|
|
#include "lldb/API/SBTypeCategory.h"
|
|
|
|
#include "lldb/API/SBTypeFilter.h"
|
|
|
|
#include "lldb/API/SBTypeFormat.h"
|
|
|
|
#include "lldb/API/SBTypeNameSpecifier.h"
|
|
|
|
#include "lldb/API/SBTypeSummary.h"
|
|
|
|
#include "lldb/API/SBTypeSynthetic.h"
|
|
|
|
|
2010-10-11 09:05:37 +08:00
|
|
|
#include "lldb/Core/Debugger.h"
|
2017-08-09 17:20:40 +08:00
|
|
|
#include "lldb/Core/PluginManager.h"
|
2021-03-02 07:26:35 +08:00
|
|
|
#include "lldb/Core/Progress.h"
|
2014-01-28 07:43:24 +08:00
|
|
|
#include "lldb/Core/StreamFile.h"
|
2017-08-09 17:20:40 +08:00
|
|
|
#include "lldb/Core/StructuredDataImpl.h"
|
2013-01-29 07:47:25 +08:00
|
|
|
#include "lldb/DataFormatters/DataVisualization.h"
|
2019-12-11 00:54:30 +08:00
|
|
|
#include "lldb/Host/Config.h"
|
2018-02-19 23:06:28 +08:00
|
|
|
#include "lldb/Host/XML.h"
|
2015-04-01 05:03:22 +08:00
|
|
|
#include "lldb/Initialization/SystemLifetimeManager.h"
|
2010-10-11 09:05:37 +08:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
2018-04-10 17:03:59 +08:00
|
|
|
#include "lldb/Interpreter/OptionArgParser.h"
|
2011-09-24 08:52:29 +08:00
|
|
|
#include "lldb/Interpreter/OptionGroupPlatform.h"
|
2010-10-11 09:05:37 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/TargetList.h"
|
2018-04-18 02:53:35 +08:00
|
|
|
#include "lldb/Utility/Args.h"
|
2018-08-07 19:07:21 +08:00
|
|
|
#include "lldb/Utility/State.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2015-10-20 12:50:09 +08:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2016-09-17 03:09:12 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2014-08-28 04:15:09 +08:00
|
|
|
#include "llvm/Support/DynamicLibrary.h"
|
2015-04-01 05:03:22 +08:00
|
|
|
#include "llvm/Support/ManagedStatic.h"
|
2014-08-28 04:15:09 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2013-12-03 03:35:49 +08:00
|
|
|
static llvm::sys::DynamicLibrary LoadPlugin(const lldb::DebuggerSP &debugger_sp,
|
|
|
|
const FileSpec &spec,
|
2017-05-12 12:51:55 +08:00
|
|
|
Status &error) {
|
2014-08-28 04:15:09 +08:00
|
|
|
llvm::sys::DynamicLibrary dynlib =
|
|
|
|
llvm::sys::DynamicLibrary::getPermanentLibrary(spec.GetPath().c_str());
|
|
|
|
if (dynlib.isValid()) {
|
2013-12-03 03:35:49 +08:00
|
|
|
typedef bool (*LLDBCommandPluginInit)(lldb::SBDebugger & debugger);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-12-03 03:35:49 +08:00
|
|
|
lldb::SBDebugger debugger_sb(debugger_sp);
|
|
|
|
// This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger)
|
|
|
|
// function.
|
|
|
|
// TODO: mangle this differently for your system - on OSX, the first
|
|
|
|
// underscore needs to be removed and the second one stays
|
2014-08-28 04:15:09 +08:00
|
|
|
LLDBCommandPluginInit init_func =
|
2017-10-25 07:46:00 +08:00
|
|
|
(LLDBCommandPluginInit)(uintptr_t)dynlib.getAddressOfSymbol(
|
2014-08-28 04:15:09 +08:00
|
|
|
"_ZN4lldb16PluginInitializeENS_10SBDebuggerE");
|
2013-12-03 03:35:49 +08:00
|
|
|
if (init_func) {
|
|
|
|
if (init_func(debugger_sb))
|
2014-08-28 04:15:09 +08:00
|
|
|
return dynlib;
|
2013-12-03 03:35:49 +08:00
|
|
|
else
|
|
|
|
error.SetErrorString("plug-in refused to load "
|
|
|
|
"(lldb::PluginInitialize(lldb::SBDebugger) "
|
|
|
|
"returned false)");
|
|
|
|
} else {
|
|
|
|
error.SetErrorString("plug-in is missing the required initialization: "
|
|
|
|
"lldb::PluginInitialize(lldb::SBDebugger)");
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2018-11-02 01:09:25 +08:00
|
|
|
if (FileSystem::Instance().Exists(spec))
|
2013-12-03 03:35:49 +08:00
|
|
|
error.SetErrorString("this file does not represent a loadable dylib");
|
|
|
|
else
|
|
|
|
error.SetErrorString("no such file");
|
|
|
|
}
|
2014-08-28 04:15:09 +08:00
|
|
|
return llvm::sys::DynamicLibrary();
|
2013-12-03 03:35:49 +08:00
|
|
|
}
|
|
|
|
|
2015-04-01 05:03:22 +08:00
|
|
|
static llvm::ManagedStatic<SystemLifetimeManager> g_debugger_lifetime;
|
|
|
|
|
|
|
|
SBError SBInputReader::Initialize(
|
|
|
|
lldb::SBDebugger &sb_debugger,
|
2019-03-09 03:09:27 +08:00
|
|
|
unsigned long (*callback)(void *, lldb::SBInputReader *,
|
|
|
|
lldb::InputReaderAction, char const *,
|
|
|
|
unsigned long),
|
|
|
|
void *a, lldb::InputReaderGranularity b, char const *c, char const *d,
|
|
|
|
bool e) {
|
2019-03-12 04:31:21 +08:00
|
|
|
LLDB_RECORD_DUMMY(
|
|
|
|
lldb::SBError, SBInputReader, Initialize,
|
|
|
|
(lldb::SBDebugger &,
|
|
|
|
unsigned long (*)(void *, lldb::SBInputReader *, lldb::InputReaderAction,
|
|
|
|
const char *, unsigned long),
|
|
|
|
void *, lldb::InputReaderGranularity, const char *, const char *, bool),
|
|
|
|
sb_debugger, callback, a, b, c, d, e);
|
2019-03-09 03:09:27 +08:00
|
|
|
|
2015-04-01 05:03:22 +08:00
|
|
|
return SBError();
|
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
void SBInputReader::SetIsDone(bool b) {
|
|
|
|
LLDB_RECORD_METHOD(void, SBInputReader, SetIsDone, (bool), b);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBInputReader::IsActive() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInputReader, IsActive);
|
2015-10-31 09:22:59 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
2015-04-01 05:03:22 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
SBDebugger::SBDebugger() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBDebugger); }
|
2015-10-31 09:22:59 +08:00
|
|
|
|
|
|
|
SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp)
|
2019-03-06 08:06:00 +08:00
|
|
|
: m_opaque_sp(debugger_sp) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &), debugger_sp);
|
|
|
|
}
|
2015-10-31 09:22:59 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
SBDebugger::SBDebugger(const SBDebugger &rhs) : m_opaque_sp(rhs.m_opaque_sp) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &), rhs);
|
|
|
|
}
|
2015-10-31 09:22:59 +08:00
|
|
|
|
|
|
|
SBDebugger::~SBDebugger() = default;
|
|
|
|
|
|
|
|
SBDebugger &SBDebugger::operator=(const SBDebugger &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBDebugger &,
|
|
|
|
SBDebugger, operator=,(const lldb::SBDebugger &), rhs);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
if (this != &rhs) {
|
|
|
|
m_opaque_sp = rhs.m_opaque_sp;
|
|
|
|
}
|
2019-04-04 05:31:22 +08:00
|
|
|
return LLDB_RECORD_RESULT(*this);
|
2015-10-31 09:22:59 +08:00
|
|
|
}
|
|
|
|
|
2021-03-02 07:26:35 +08:00
|
|
|
const char *SBDebugger::GetBroadcasterClass() {
|
|
|
|
LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBDebugger,
|
|
|
|
GetBroadcasterClass);
|
|
|
|
|
|
|
|
return Debugger::GetStaticBroadcasterClass().AsCString();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBDebugger::GetProgressFromEvent(const lldb::SBEvent &event,
|
|
|
|
uint64_t &progress_id,
|
|
|
|
uint64_t &completed,
|
|
|
|
uint64_t &total,
|
|
|
|
bool &is_debugger_specific) {
|
|
|
|
const Debugger::ProgressEventData *progress_data =
|
|
|
|
Debugger::ProgressEventData::GetEventDataFromEvent(event.get());
|
|
|
|
if (progress_data == nullptr)
|
|
|
|
return nullptr;
|
|
|
|
progress_id = progress_data->GetID();
|
|
|
|
completed = progress_data->GetCompleted();
|
|
|
|
total = progress_data->GetTotal();
|
|
|
|
is_debugger_specific = progress_data->IsDebuggerSpecific();
|
2021-05-30 22:14:17 +08:00
|
|
|
// We must record the static method _after_ the out parameters have been
|
2021-03-02 07:26:35 +08:00
|
|
|
// filled in.
|
|
|
|
LLDB_RECORD_STATIC_METHOD(
|
|
|
|
const char *, SBDebugger, GetProgressFromEvent,
|
|
|
|
(const lldb::SBEvent &, uint64_t &, uint64_t &, uint64_t &, bool &),
|
|
|
|
event, progress_id, completed, total, is_debugger_specific);
|
|
|
|
return LLDB_RECORD_RESULT(progress_data->GetMessage().c_str())
|
|
|
|
}
|
|
|
|
|
|
|
|
SBBroadcaster SBDebugger::GetBroadcaster() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBroadcaster, SBDebugger, GetBroadcaster);
|
|
|
|
SBBroadcaster broadcaster(&m_opaque_sp->GetBroadcaster(), false);
|
|
|
|
return LLDB_RECORD_RESULT(broadcaster);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void SBDebugger::Initialize() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, Initialize);
|
2019-02-22 06:26:16 +08:00
|
|
|
SBError ignored = SBDebugger::InitializeWithErrorHandling();
|
2018-12-04 01:28:29 +08:00
|
|
|
}
|
|
|
|
|
2019-02-22 06:26:16 +08:00
|
|
|
lldb::SBError SBDebugger::InitializeWithErrorHandling() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBError, SBDebugger,
|
|
|
|
InitializeWithErrorHandling);
|
|
|
|
|
2018-12-04 01:28:29 +08:00
|
|
|
SBError error;
|
|
|
|
if (auto e = g_debugger_lifetime->Initialize(
|
2019-08-15 06:19:23 +08:00
|
|
|
std::make_unique<SystemInitializerFull>(), LoadPlugin)) {
|
2018-12-04 01:28:29 +08:00
|
|
|
error.SetError(Status(std::move(e)));
|
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(error);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
void SBDebugger::Terminate() {
|
|
|
|
LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, Terminate);
|
|
|
|
|
|
|
|
g_debugger_lifetime->Terminate();
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-07-31 04:12:55 +08:00
|
|
|
void SBDebugger::Clear() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, Clear);
|
|
|
|
|
2010-12-21 02:35:50 +08:00
|
|
|
if (m_opaque_sp)
|
2014-01-28 07:43:24 +08:00
|
|
|
m_opaque_sp->ClearIOHandlers();
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-07-31 04:12:55 +08:00
|
|
|
m_opaque_sp.reset();
|
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBDebugger SBDebugger::Create() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBDebugger, SBDebugger, Create);
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(SBDebugger::Create(false, nullptr, nullptr));
|
2011-08-13 08:22:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBDebugger SBDebugger::Create(bool source_init_files) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, (bool),
|
|
|
|
source_init_files);
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
SBDebugger::Create(source_init_files, nullptr, nullptr));
|
2012-02-21 10:23:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBDebugger SBDebugger::Create(bool source_init_files,
|
|
|
|
lldb::LogOutputCallback callback, void *baton)
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2019-03-09 03:09:27 +08:00
|
|
|
LLDB_RECORD_DUMMY(lldb::SBDebugger, SBDebugger, Create,
|
2019-03-12 04:31:21 +08:00
|
|
|
(bool, lldb::LogOutputCallback, void *), source_init_files,
|
|
|
|
callback, baton);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2011-08-13 08:22:20 +08:00
|
|
|
SBDebugger debugger;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
// Currently we have issues if this function is called simultaneously on two
|
2018-05-01 00:49:04 +08:00
|
|
|
// different threads. The issues mainly revolve around the fact that the
|
|
|
|
// lldb_private::FormatManager uses global collections and having two threads
|
|
|
|
// parsing the .lldbinit files can cause mayhem. So to get around this for
|
|
|
|
// now we need to use a mutex to prevent bad things from happening.
|
2014-04-04 12:06:10 +08:00
|
|
|
static std::recursive_mutex g_mutex;
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(g_mutex);
|
|
|
|
|
2011-01-22 09:02:07 +08:00
|
|
|
debugger.reset(Debugger::CreateInstance(callback, baton));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-01-22 09:02:07 +08:00
|
|
|
SBCommandInterpreter interp = debugger.GetCommandInterpreter();
|
|
|
|
if (source_init_files) {
|
2011-08-13 08:22:20 +08:00
|
|
|
interp.get()->SkipLLDBInitFiles(false);
|
2011-01-22 09:02:07 +08:00
|
|
|
interp.get()->SkipAppInitFiles(false);
|
2011-08-13 08:22:20 +08:00
|
|
|
SBCommandReturnObject result;
|
2020-08-20 04:04:35 +08:00
|
|
|
interp.SourceInitFileInHomeDirectory(result, false);
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2011-01-22 09:02:07 +08:00
|
|
|
interp.get()->SkipLLDBInitFiles(true);
|
2011-08-13 08:22:20 +08:00
|
|
|
interp.get()->SkipAppInitFiles(true);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-23 09:19:29 +08:00
|
|
|
return debugger;
|
2011-01-22 09:02:07 +08:00
|
|
|
}
|
|
|
|
|
2011-12-15 12:38:41 +08:00
|
|
|
void SBDebugger::Destroy(SBDebugger &debugger) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD(void, SBDebugger, Destroy, (lldb::SBDebugger &),
|
|
|
|
debugger);
|
|
|
|
|
2012-04-10 04:22:01 +08:00
|
|
|
Debugger::Destroy(debugger.m_opaque_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-04-10 04:22:01 +08:00
|
|
|
if (debugger.m_opaque_sp.get() != nullptr)
|
|
|
|
debugger.m_opaque_sp.reset();
|
2011-12-15 12:38:41 +08:00
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
void SBDebugger::MemoryPressureDetected() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, MemoryPressureDetected);
|
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// Since this function can be call asynchronously, we allow it to be non-
|
|
|
|
// mandatory. We have seen deadlocks with this function when called so we
|
|
|
|
// need to safeguard against this until we can determine what is causing the
|
|
|
|
// deadlocks.
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
const bool mandatory = false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
ModuleList::RemoveOrphanSharedModules(mandatory);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
bool SBDebugger::IsValid() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, 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 21:58:46 +08:00
|
|
|
return this->operator bool();
|
|
|
|
}
|
|
|
|
SBDebugger::operator bool() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, operator bool);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
|
|
|
return m_opaque_sp.get() != nullptr;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
void SBDebugger::SetAsync(bool b) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, SetAsync, (bool), b);
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->SetAsyncExecution(b);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
bool SBDebugger::GetAsync() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBDebugger, GetAsync);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
return (m_opaque_sp ? m_opaque_sp->GetAsyncExecution() : false);
|
2011-09-14 07:25:31 +08:00
|
|
|
}
|
|
|
|
|
2010-10-11 09:05:37 +08:00
|
|
|
void SBDebugger::SkipLLDBInitFiles(bool b) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, SkipLLDBInitFiles, (bool), b);
|
|
|
|
|
2010-10-11 09:05:37 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles(b);
|
|
|
|
}
|
|
|
|
|
2011-08-13 07:34:31 +08:00
|
|
|
void SBDebugger::SkipAppInitFiles(bool b) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, SkipAppInitFiles, (bool), b);
|
|
|
|
|
2011-08-13 07:34:31 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles(b);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, SetInputFileHandle, (FILE *, bool), fh,
|
|
|
|
transfer_ownership);
|
2019-10-03 12:31:46 +08:00
|
|
|
SetInputFile((FileSP)std::make_shared<NativeFile>(fh, transfer_ownership));
|
2019-10-03 12:04:48 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2019-10-11 03:10:59 +08:00
|
|
|
SBError SBDebugger::SetInputFile(FileSP file_sp) {
|
|
|
|
LLDB_RECORD_METHOD(SBError, SBDebugger, SetInputFile, (FileSP), file_sp);
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(SetInputFile(SBFile(file_sp)));
|
2019-10-11 03:10:59 +08:00
|
|
|
}
|
|
|
|
|
2019-10-03 12:04:48 +08:00
|
|
|
// Shouldn't really be settable after initialization as this could cause lots
|
|
|
|
// of problems; don't want users trying to switch modes in the middle of a
|
|
|
|
// debugging session.
|
|
|
|
SBError SBDebugger::SetInputFile(SBFile file) {
|
|
|
|
LLDB_RECORD_METHOD(SBError, SBDebugger, SetInputFile, (SBFile), file);
|
|
|
|
|
|
|
|
SBError error;
|
|
|
|
if (!m_opaque_sp) {
|
|
|
|
error.ref().SetErrorString("invalid debugger");
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(error);
|
2019-10-03 12:04:48 +08:00
|
|
|
}
|
2019-03-02 08:20:26 +08:00
|
|
|
|
|
|
|
repro::DataRecorder *recorder = nullptr;
|
|
|
|
if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator())
|
2020-07-11 03:45:38 +08:00
|
|
|
recorder = g->GetOrCreate<repro::CommandProvider>().GetNewRecorder();
|
2019-03-02 08:20:26 +08:00
|
|
|
|
2019-10-03 12:04:48 +08:00
|
|
|
FileSP file_sp = file.m_opaque_sp;
|
|
|
|
|
2019-12-11 07:04:02 +08:00
|
|
|
static std::unique_ptr<repro::MultiLoader<repro::CommandProvider>> loader =
|
|
|
|
repro::MultiLoader<repro::CommandProvider>::Create(
|
|
|
|
repro::Reproducer::Instance().GetLoader());
|
2019-09-12 07:27:12 +08:00
|
|
|
if (loader) {
|
2019-10-03 12:04:48 +08:00
|
|
|
llvm::Optional<std::string> nextfile = loader->GetNextFile();
|
|
|
|
FILE *fh = nextfile ? FileSystem::Instance().Fopen(nextfile->c_str(), "r")
|
|
|
|
: nullptr;
|
|
|
|
// FIXME Jonas Devlieghere: shouldn't this error be propagated out to the
|
|
|
|
// reproducer somehow if fh is NULL?
|
|
|
|
if (fh) {
|
2019-10-03 12:31:46 +08:00
|
|
|
file_sp = std::make_shared<NativeFile>(fh, true);
|
2019-10-03 12:04:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!file_sp || !file_sp->IsValid()) {
|
|
|
|
error.ref().SetErrorString("invalid file");
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(error);
|
2019-09-12 07:27:12 +08:00
|
|
|
}
|
2019-03-02 08:20:26 +08:00
|
|
|
|
2019-10-03 12:04:48 +08:00
|
|
|
m_opaque_sp->SetInputFile(file_sp, recorder);
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(error);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-10-11 03:10:59 +08:00
|
|
|
SBError SBDebugger::SetOutputFile(FileSP file_sp) {
|
|
|
|
LLDB_RECORD_METHOD(SBError, SBDebugger, SetOutputFile, (FileSP), file_sp);
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(SetOutputFile(SBFile(file_sp)));
|
2019-10-11 03:10:59 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void SBDebugger::SetOutputFileHandle(FILE *fh, bool transfer_ownership) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, SetOutputFileHandle, (FILE *, bool), fh,
|
|
|
|
transfer_ownership);
|
2019-10-03 12:31:46 +08:00
|
|
|
SetOutputFile((FileSP)std::make_shared<NativeFile>(fh, transfer_ownership));
|
2019-10-03 12:04:48 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2019-10-03 12:04:48 +08:00
|
|
|
SBError SBDebugger::SetOutputFile(SBFile file) {
|
|
|
|
LLDB_RECORD_METHOD(SBError, SBDebugger, SetOutputFile, (SBFile file), file);
|
|
|
|
SBError error;
|
|
|
|
if (!m_opaque_sp) {
|
|
|
|
error.ref().SetErrorString("invalid debugger");
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(error);
|
2019-10-03 12:04:48 +08:00
|
|
|
}
|
|
|
|
if (!file) {
|
|
|
|
error.ref().SetErrorString("invalid file");
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(error);
|
2019-10-03 12:04:48 +08:00
|
|
|
}
|
|
|
|
m_opaque_sp->SetOutputFile(file.m_opaque_sp);
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(error);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBDebugger::SetErrorFileHandle(FILE *fh, bool transfer_ownership) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, SetErrorFileHandle, (FILE *, bool), fh,
|
|
|
|
transfer_ownership);
|
2019-10-03 12:31:46 +08:00
|
|
|
SetErrorFile((FileSP)std::make_shared<NativeFile>(fh, transfer_ownership));
|
2019-10-03 12:04:48 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2019-10-11 03:10:59 +08:00
|
|
|
SBError SBDebugger::SetErrorFile(FileSP file_sp) {
|
|
|
|
LLDB_RECORD_METHOD(SBError, SBDebugger, SetErrorFile, (FileSP), file_sp);
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(SetErrorFile(SBFile(file_sp)));
|
2019-10-11 03:10:59 +08:00
|
|
|
}
|
|
|
|
|
2019-10-03 12:04:48 +08:00
|
|
|
SBError SBDebugger::SetErrorFile(SBFile file) {
|
|
|
|
LLDB_RECORD_METHOD(SBError, SBDebugger, SetErrorFile, (SBFile file), file);
|
|
|
|
SBError error;
|
|
|
|
if (!m_opaque_sp) {
|
|
|
|
error.ref().SetErrorString("invalid debugger");
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(error);
|
2019-10-03 12:04:48 +08:00
|
|
|
}
|
|
|
|
if (!file) {
|
|
|
|
error.ref().SetErrorString("invalid file");
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(error);
|
2019-10-03 12:04:48 +08:00
|
|
|
}
|
|
|
|
m_opaque_sp->SetErrorFile(file.m_opaque_sp);
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(error);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
FILE *SBDebugger::GetInputFileHandle() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetInputFileHandle);
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp) {
|
remove File::SetStream(), make new files instead.
Summary:
This patch removes File::SetStream() and File::SetDescriptor(),
and replaces most direct uses of File with pointers to File.
Instead of calling SetStream() on a file, we make a new file and
replace it.
My ultimate goal here is to introduce a new API class SBFile, which
has full support for python io.IOStream file objects. These can
redirect read() and write() to python code, so lldb::Files will
need a way to dispatch those methods. Additionally it will need some
form of sharing and assigning files, as a SBFile will be passed in and
assigned to the main IO streams of the debugger.
In my prototype patch queue, I make File itself copyable and add a
secondary class FileOps to manage the sharing and dispatch. In that
case SBFile was a unique_ptr<File>.
(here: https://github.com/smoofra/llvm-project/tree/files)
However in review, Pavel Labath suggested that it be shared_ptr instead.
(here: https://reviews.llvm.org/D67793)
In order for SBFile to use shared_ptr<File>, everything else should
as well.
If this patch is accepted, I will make SBFile use a shared_ptr
I will remove FileOps from future patches and use subclasses of File
instead.
Reviewers: JDevlieghere, jasonmolenda, zturner, jingham, labath
Reviewed By: labath
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D67891
llvm-svn: 373090
2019-09-27 22:33:35 +08:00
|
|
|
File &file_sp = m_opaque_sp->GetInputFile();
|
|
|
|
return LLDB_RECORD_RESULT(file_sp.GetStream());
|
2014-01-28 07:43:24 +08:00
|
|
|
}
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(nullptr);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-10-03 12:04:48 +08:00
|
|
|
SBFile SBDebugger::GetInputFile() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(SBFile, SBDebugger, GetInputFile);
|
|
|
|
if (m_opaque_sp) {
|
|
|
|
return LLDB_RECORD_RESULT(SBFile(m_opaque_sp->GetInputFileSP()));
|
|
|
|
}
|
|
|
|
return LLDB_RECORD_RESULT(SBFile());
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
FILE *SBDebugger::GetOutputFileHandle() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetOutputFileHandle);
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp) {
|
remove File::SetStream(), make new files instead.
Summary:
This patch removes File::SetStream() and File::SetDescriptor(),
and replaces most direct uses of File with pointers to File.
Instead of calling SetStream() on a file, we make a new file and
replace it.
My ultimate goal here is to introduce a new API class SBFile, which
has full support for python io.IOStream file objects. These can
redirect read() and write() to python code, so lldb::Files will
need a way to dispatch those methods. Additionally it will need some
form of sharing and assigning files, as a SBFile will be passed in and
assigned to the main IO streams of the debugger.
In my prototype patch queue, I make File itself copyable and add a
secondary class FileOps to manage the sharing and dispatch. In that
case SBFile was a unique_ptr<File>.
(here: https://github.com/smoofra/llvm-project/tree/files)
However in review, Pavel Labath suggested that it be shared_ptr instead.
(here: https://reviews.llvm.org/D67793)
In order for SBFile to use shared_ptr<File>, everything else should
as well.
If this patch is accepted, I will make SBFile use a shared_ptr
I will remove FileOps from future patches and use subclasses of File
instead.
Reviewers: JDevlieghere, jasonmolenda, zturner, jingham, labath
Reviewed By: labath
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D67891
llvm-svn: 373090
2019-09-27 22:33:35 +08:00
|
|
|
StreamFile &stream_file = m_opaque_sp->GetOutputStream();
|
|
|
|
return LLDB_RECORD_RESULT(stream_file.GetFile().GetStream());
|
2014-01-28 07:43:24 +08:00
|
|
|
}
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(nullptr);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-10-03 12:04:48 +08:00
|
|
|
SBFile SBDebugger::GetOutputFile() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(SBFile, SBDebugger, GetOutputFile);
|
|
|
|
if (m_opaque_sp) {
|
|
|
|
SBFile file(m_opaque_sp->GetOutputStream().GetFileSP());
|
|
|
|
return LLDB_RECORD_RESULT(file);
|
|
|
|
}
|
|
|
|
return LLDB_RECORD_RESULT(SBFile());
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
FILE *SBDebugger::GetErrorFileHandle() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetErrorFileHandle);
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp) {
|
remove File::SetStream(), make new files instead.
Summary:
This patch removes File::SetStream() and File::SetDescriptor(),
and replaces most direct uses of File with pointers to File.
Instead of calling SetStream() on a file, we make a new file and
replace it.
My ultimate goal here is to introduce a new API class SBFile, which
has full support for python io.IOStream file objects. These can
redirect read() and write() to python code, so lldb::Files will
need a way to dispatch those methods. Additionally it will need some
form of sharing and assigning files, as a SBFile will be passed in and
assigned to the main IO streams of the debugger.
In my prototype patch queue, I make File itself copyable and add a
secondary class FileOps to manage the sharing and dispatch. In that
case SBFile was a unique_ptr<File>.
(here: https://github.com/smoofra/llvm-project/tree/files)
However in review, Pavel Labath suggested that it be shared_ptr instead.
(here: https://reviews.llvm.org/D67793)
In order for SBFile to use shared_ptr<File>, everything else should
as well.
If this patch is accepted, I will make SBFile use a shared_ptr
I will remove FileOps from future patches and use subclasses of File
instead.
Reviewers: JDevlieghere, jasonmolenda, zturner, jingham, labath
Reviewed By: labath
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D67891
llvm-svn: 373090
2019-09-27 22:33:35 +08:00
|
|
|
StreamFile &stream_file = m_opaque_sp->GetErrorStream();
|
|
|
|
return LLDB_RECORD_RESULT(stream_file.GetFile().GetStream());
|
2015-10-31 09:22:59 +08:00
|
|
|
}
|
2019-12-05 09:37:08 +08:00
|
|
|
return LLDB_RECORD_RESULT(nullptr);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-10-03 12:04:48 +08:00
|
|
|
SBFile SBDebugger::GetErrorFile() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(SBFile, SBDebugger, GetErrorFile);
|
|
|
|
SBFile file;
|
|
|
|
if (m_opaque_sp) {
|
|
|
|
SBFile file(m_opaque_sp->GetErrorStream().GetFileSP());
|
|
|
|
return LLDB_RECORD_RESULT(file);
|
|
|
|
}
|
|
|
|
return LLDB_RECORD_RESULT(SBFile());
|
|
|
|
}
|
|
|
|
|
2012-12-01 04:23:19 +08:00
|
|
|
void SBDebugger::SaveInputTerminalState() {
|
2019-10-09 03:17:42 +08:00
|
|
|
LLDB_RECORD_DUMMY_NO_ARGS(void, SBDebugger, SaveInputTerminalState);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2012-12-01 04:23:19 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->SaveInputTerminalState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBDebugger::RestoreInputTerminalState() {
|
2019-10-09 03:17:42 +08:00
|
|
|
LLDB_RECORD_DUMMY_NO_ARGS(void, SBDebugger, RestoreInputTerminalState);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2012-12-01 04:23:19 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->RestoreInputTerminalState();
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
SBCommandInterpreter SBDebugger::GetCommandInterpreter() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCommandInterpreter, SBDebugger,
|
|
|
|
GetCommandInterpreter);
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBCommandInterpreter sb_interpreter;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
sb_interpreter.reset(&m_opaque_sp->GetCommandInterpreter());
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_interpreter);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBDebugger::HandleCommand(const char *command) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, HandleCommand, (const char *), command);
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp) {
|
2010-12-21 04:49:23 +08:00
|
|
|
TargetSP target_sp(m_opaque_sp->GetSelectedTarget());
|
2015-10-31 09:22:59 +08:00
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
if (target_sp)
|
2016-03-08 05:50:25 +08:00
|
|
|
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
SBCommandInterpreter sb_interpreter(GetCommandInterpreter());
|
2013-03-28 07:08:40 +08:00
|
|
|
SBCommandReturnObject result;
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-03-08 05:50:25 +08:00
|
|
|
sb_interpreter.HandleCommand(command, result, false);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2019-10-10 05:50:52 +08:00
|
|
|
result.PutError(m_opaque_sp->GetErrorStream().GetFileSP());
|
|
|
|
result.PutOutput(m_opaque_sp->GetOutputStream().GetFileSP());
|
2010-10-27 07:49:36 +08:00
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
if (!m_opaque_sp->GetAsyncExecution()) {
|
2010-06-09 00:52:24 +08:00
|
|
|
SBProcess process(GetCommandInterpreter().GetProcess());
|
2012-01-30 15:41:31 +08:00
|
|
|
ProcessSP process_sp(process.GetSP());
|
|
|
|
if (process_sp) {
|
2010-06-23 09:19:29 +08:00
|
|
|
EventSP event_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
ListenerSP lldb_listener_sp = m_opaque_sp->GetListener();
|
2016-11-30 18:41:42 +08:00
|
|
|
while (lldb_listener_sp->GetEventForBroadcaster(
|
|
|
|
process_sp.get(), event_sp, std::chrono::seconds(0))) {
|
2010-06-23 09:19:29 +08:00
|
|
|
SBEvent event(event_sp);
|
2019-10-15 04:15:28 +08:00
|
|
|
HandleProcessEvent(process, event, GetOutputFile(), GetErrorFile());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBListener SBDebugger::GetListener() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBListener, SBDebugger, GetListener);
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBListener sb_listener;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
sb_listener.reset(m_opaque_sp->GetListener());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_listener);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-10-15 04:15:28 +08:00
|
|
|
void SBDebugger::HandleProcessEvent(const SBProcess &process,
|
|
|
|
const SBEvent &event, SBFile out,
|
|
|
|
SBFile err) {
|
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
void, SBDebugger, HandleProcessEvent,
|
|
|
|
(const lldb::SBProcess &, const lldb::SBEvent &, SBFile, SBFile), process,
|
|
|
|
event, out, err);
|
|
|
|
|
|
|
|
return HandleProcessEvent(process, event, out.m_opaque_sp, err.m_opaque_sp);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void SBDebugger::HandleProcessEvent(const SBProcess &process,
|
2011-09-13 08:29:56 +08:00
|
|
|
const SBEvent &event, FILE *out,
|
|
|
|
FILE *err) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
void, SBDebugger, HandleProcessEvent,
|
|
|
|
(const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *), process,
|
|
|
|
event, out, err);
|
|
|
|
|
2019-10-15 04:15:28 +08:00
|
|
|
FileSP outfile = std::make_shared<NativeFile>(out, false);
|
|
|
|
FileSP errfile = std::make_shared<NativeFile>(err, false);
|
|
|
|
return HandleProcessEvent(process, event, outfile, errfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBDebugger::HandleProcessEvent(const SBProcess &process,
|
|
|
|
const SBEvent &event, FileSP out_sp,
|
|
|
|
FileSP err_sp) {
|
|
|
|
|
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
void, SBDebugger, HandleProcessEvent,
|
|
|
|
(const lldb::SBProcess &, const lldb::SBEvent &, FileSP, FileSP), process,
|
|
|
|
event, out_sp, err_sp);
|
|
|
|
|
2011-09-13 08:29:56 +08:00
|
|
|
if (!process.IsValid())
|
|
|
|
return;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-04-19 07:15:17 +08:00
|
|
|
TargetSP target_sp(process.GetTarget().GetSP());
|
|
|
|
if (!target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
const uint32_t event_type = event.GetType();
|
|
|
|
char stdio_buffer[1024];
|
|
|
|
size_t len;
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-12-21 04:49:23 +08:00
|
|
|
if (event_type &
|
2010-06-09 00:52:24 +08:00
|
|
|
(Process::eBroadcastBitSTDOUT | Process::eBroadcastBitStateChanged)) {
|
|
|
|
// Drain stdout when we stop just in case we have any bytes
|
|
|
|
while ((len = process.GetSTDOUT(stdio_buffer, sizeof(stdio_buffer))) > 0)
|
2019-10-15 04:15:28 +08:00
|
|
|
if (out_sp)
|
|
|
|
out_sp->Write(stdio_buffer, len);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-04-19 07:15:17 +08:00
|
|
|
if (event_type &
|
|
|
|
(Process::eBroadcastBitSTDERR | Process::eBroadcastBitStateChanged)) {
|
|
|
|
// Drain stderr when we stop just in case we have any bytes
|
2011-04-26 06:05:51 +08:00
|
|
|
while ((len = process.GetSTDERR(stdio_buffer, sizeof(stdio_buffer))) > 0)
|
2019-10-15 04:15:28 +08:00
|
|
|
if (err_sp)
|
|
|
|
err_sp->Write(stdio_buffer, len);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-04-19 07:15:17 +08:00
|
|
|
if (event_type & Process::eBroadcastBitStateChanged) {
|
|
|
|
StateType event_state = SBProcess::GetStateFromEvent(event);
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2011-04-26 06:05:51 +08:00
|
|
|
if (event_state == eStateInvalid)
|
2011-04-19 07:15:17 +08:00
|
|
|
return;
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2010-12-21 04:49:23 +08:00
|
|
|
bool is_stopped = StateIsStoppedState(event_state);
|
|
|
|
if (!is_stopped)
|
2019-10-15 04:15:28 +08:00
|
|
|
process.ReportEventState(event, out_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-04-19 07:15:17 +08:00
|
|
|
SBSourceManager SBDebugger::GetSourceManager() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager, SBDebugger,
|
|
|
|
GetSourceManager);
|
|
|
|
|
2010-10-30 12:51:46 +08:00
|
|
|
SBSourceManager sb_source_manager(*this);
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_source_manager);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) {
|
[lldb/Reproducers] Fix passive replay for (char*, size_t) functions.
Several SB API functions return strings using (char*, size_t) output
arguments. During capture, we serialize an empty string for the char*
because the memory can be uninitialized.
During active replay, we have custom replay redirects that ensure that
we don't override the buffer from which we're reading, but rather write
to a buffer on the heap with the given length. This is sufficient for
the active reproducer use case, where we only care about the side
effects of the API calls, not the values actually returned.
This approach does not not work for passive replay because here we
ignore all the incoming arguments, and re-execute the current function
with the arguments deserialized from the reproducer. This means that
these function will update the deserialized copy of the arguments,
rather than whatever was passed in by the SWIG wrapper.
To solve this problem, this patch extends the reproducer instrumentation
to handle this special case for passive replay. We nog ignore the
replayer in the registry and the incoming char pointer, and instead
reinvoke the current method on the deserialized class, and populate the
output argument.
Differential revision: https://reviews.llvm.org/D77759
2020-04-21 04:20:24 +08:00
|
|
|
LLDB_RECORD_CHAR_PTR_STATIC_METHOD(bool, SBDebugger, GetDefaultArchitecture,
|
|
|
|
(char *, size_t), arch_name, "",
|
|
|
|
arch_name_len);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
if (arch_name && arch_name_len) {
|
|
|
|
ArchSpec default_arch = Target::GetDefaultArchitecture();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (default_arch.IsValid()) {
|
2011-09-24 08:52:29 +08:00
|
|
|
const std::string &triple_str = default_arch.GetTriple().str();
|
|
|
|
if (!triple_str.empty())
|
|
|
|
::snprintf(arch_name, arch_name_len, "%s", triple_str.c_str());
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2012-10-19 00:33:33 +08:00
|
|
|
::snprintf(arch_name, arch_name_len, "%s",
|
2012-01-30 15:41:31 +08:00
|
|
|
default_arch.GetArchitectureName());
|
|
|
|
return true;
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2011-09-24 08:52:29 +08:00
|
|
|
if (arch_name && arch_name_len)
|
2010-06-09 00:52:24 +08:00
|
|
|
arch_name[0] = '\0';
|
2011-09-24 08:52:29 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-10-31 05:32:03 +08:00
|
|
|
bool SBDebugger::SetDefaultArchitecture(const char *arch_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, SetDefaultArchitecture,
|
|
|
|
(const char *), arch_name);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (arch_name) {
|
2015-10-31 05:32:03 +08:00
|
|
|
ArchSpec arch(arch_name);
|
|
|
|
if (arch.IsValid()) {
|
2011-04-19 07:15:17 +08:00
|
|
|
Target::SetDefaultArchitecture(arch);
|
2015-10-31 05:32:03 +08:00
|
|
|
return true;
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2011-09-24 08:52:29 +08:00
|
|
|
return false;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
ScriptLanguage
|
|
|
|
SBDebugger::GetScriptingLanguage(const char *script_language_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::ScriptLanguage, SBDebugger, GetScriptingLanguage,
|
|
|
|
(const char *), script_language_name);
|
|
|
|
|
2019-09-12 07:27:09 +08:00
|
|
|
if (!script_language_name)
|
|
|
|
return eScriptLanguageDefault;
|
2018-04-10 17:03:59 +08:00
|
|
|
return OptionArgParser::ToScriptLanguage(
|
|
|
|
llvm::StringRef(script_language_name), eScriptLanguageDefault, nullptr);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 08:35:02 +08:00
|
|
|
const char *SBDebugger::GetVersionString() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBDebugger, GetVersionString);
|
|
|
|
|
2014-04-04 12:06:10 +08:00
|
|
|
return lldb_private::GetVersion();
|
2010-06-23 09:19:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBDebugger::StateAsCString(StateType state) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD(const char *, SBDebugger, StateAsCString,
|
|
|
|
(lldb::StateType), state);
|
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
return lldb_private::StateAsCString(state);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2018-02-19 23:06:28 +08:00
|
|
|
static void AddBoolConfigEntry(StructuredData::Dictionary &dict,
|
|
|
|
llvm::StringRef name, bool value,
|
|
|
|
llvm::StringRef description) {
|
2019-08-15 06:19:23 +08:00
|
|
|
auto entry_up = std::make_unique<StructuredData::Dictionary>();
|
2018-02-19 23:06:28 +08:00
|
|
|
entry_up->AddBooleanItem("value", value);
|
|
|
|
entry_up->AddStringItem("description", description);
|
|
|
|
dict.AddItem(name, std::move(entry_up));
|
|
|
|
}
|
|
|
|
|
2018-06-28 22:23:04 +08:00
|
|
|
static void AddLLVMTargets(StructuredData::Dictionary &dict) {
|
2019-08-15 06:19:23 +08:00
|
|
|
auto array_up = std::make_unique<StructuredData::Array>();
|
2018-06-28 22:23:04 +08:00
|
|
|
#define LLVM_TARGET(target) \
|
2019-08-15 06:19:23 +08:00
|
|
|
array_up->AddItem(std::make_unique<StructuredData::String>(#target));
|
2018-06-28 22:23:04 +08:00
|
|
|
#include "llvm/Config/Targets.def"
|
2019-08-15 06:19:23 +08:00
|
|
|
auto entry_up = std::make_unique<StructuredData::Dictionary>();
|
2018-06-28 22:23:04 +08:00
|
|
|
entry_up->AddItem("value", std::move(array_up));
|
|
|
|
entry_up->AddStringItem("description", "A list of configured LLVM targets.");
|
|
|
|
dict.AddItem("targets", std::move(entry_up));
|
|
|
|
}
|
|
|
|
|
2018-02-19 23:06:28 +08:00
|
|
|
SBStructuredData SBDebugger::GetBuildConfiguration() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBStructuredData, SBDebugger,
|
|
|
|
GetBuildConfiguration);
|
|
|
|
|
2019-08-15 06:19:23 +08:00
|
|
|
auto config_up = std::make_unique<StructuredData::Dictionary>();
|
2018-02-19 23:06:28 +08:00
|
|
|
AddBoolConfigEntry(
|
|
|
|
*config_up, "xml", XMLDocument::XMLEnabled(),
|
|
|
|
"A boolean value that indicates if XML support is enabled in LLDB");
|
2019-09-02 21:33:12 +08:00
|
|
|
AddBoolConfigEntry(
|
2019-12-13 01:13:04 +08:00
|
|
|
*config_up, "curses", LLDB_ENABLE_CURSES,
|
2019-09-02 21:33:12 +08:00
|
|
|
"A boolean value that indicates if curses support is enabled in LLDB");
|
2019-12-21 13:01:08 +08:00
|
|
|
AddBoolConfigEntry(
|
|
|
|
*config_up, "editline", LLDB_ENABLE_LIBEDIT,
|
|
|
|
"A boolean value that indicates if editline support is enabled in LLDB");
|
|
|
|
AddBoolConfigEntry(
|
|
|
|
*config_up, "lzma", LLDB_ENABLE_LZMA,
|
|
|
|
"A boolean value that indicates if lzma support is enabled in LLDB");
|
|
|
|
AddBoolConfigEntry(
|
|
|
|
*config_up, "python", LLDB_ENABLE_PYTHON,
|
|
|
|
"A boolean value that indicates if python support is enabled in LLDB");
|
|
|
|
AddBoolConfigEntry(
|
|
|
|
*config_up, "lua", LLDB_ENABLE_LUA,
|
|
|
|
"A boolean value that indicates if lua support is enabled in LLDB");
|
2018-06-28 22:23:04 +08:00
|
|
|
AddLLVMTargets(*config_up);
|
2018-02-19 23:06:28 +08:00
|
|
|
|
|
|
|
SBStructuredData data;
|
|
|
|
data.m_impl_up->SetObjectSP(std::move(config_up));
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(data);
|
2018-02-19 23:06:28 +08:00
|
|
|
}
|
|
|
|
|
2011-06-16 05:24:24 +08:00
|
|
|
bool SBDebugger::StateIsRunningState(StateType state) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, StateIsRunningState,
|
|
|
|
(lldb::StateType), state);
|
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
const bool result = lldb_private::StateIsRunningState(state);
|
2011-06-16 05:24:24 +08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2015-10-31 09:22:59 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool SBDebugger::StateIsStoppedState(StateType state) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, StateIsStoppedState,
|
|
|
|
(lldb::StateType), state);
|
|
|
|
|
2012-05-09 07:06:07 +08:00
|
|
|
const bool result = lldb_private::StateIsStoppedState(state, false);
|
|
|
|
|
|
|
|
return result;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-05-09 07:06:07 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
lldb::SBTarget SBDebugger::CreateTarget(const char *filename,
|
|
|
|
const char *target_triple,
|
2011-09-24 08:52:29 +08:00
|
|
|
const char *platform_name,
|
|
|
|
bool add_dependent_modules,
|
|
|
|
lldb::SBError &sb_error) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
lldb::SBTarget, SBDebugger, CreateTarget,
|
|
|
|
(const char *, const char *, const char *, bool, lldb::SBError &),
|
|
|
|
filename, target_triple, platform_name, add_dependent_modules, sb_error);
|
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
SBTarget sb_target;
|
2012-01-30 15:41:31 +08:00
|
|
|
TargetSP target_sp;
|
2012-05-09 07:06:07 +08:00
|
|
|
if (m_opaque_sp) {
|
2011-09-24 08:52:29 +08:00
|
|
|
sb_error.Clear();
|
|
|
|
OptionGroupPlatform platform_options(false);
|
2012-05-09 07:06:07 +08:00
|
|
|
platform_options.SetPlatformName(platform_name);
|
|
|
|
|
|
|
|
sb_error.ref() = m_opaque_sp->GetTargetList().CreateTarget(
|
2018-09-20 17:09:05 +08:00
|
|
|
*m_opaque_sp, filename, target_triple,
|
|
|
|
add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo,
|
2012-05-09 07:06:07 +08:00
|
|
|
&platform_options, target_sp);
|
|
|
|
|
2013-09-06 00:53:14 +08:00
|
|
|
if (sb_error.Success())
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_target.SetSP(target_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_error.SetErrorString("invalid debugger");
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
"SBDebugger(%p)::CreateTarget (filename=\"%s\", triple=%s, "
|
|
|
|
"platform_name=%s, add_dependent_modules=%u, error=%s) => "
|
|
|
|
"SBTarget(%p)",
|
|
|
|
static_cast<void *>(m_opaque_sp.get()), filename, target_triple,
|
|
|
|
platform_name, add_dependent_modules, sb_error.GetCString(),
|
|
|
|
static_cast<void *>(target_sp.get()));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_target);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBTarget
|
2011-04-19 07:15:17 +08:00
|
|
|
SBDebugger::CreateTargetWithFileAndTargetTriple(const char *filename,
|
2010-06-09 00:52:24 +08:00
|
|
|
const char *target_triple) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger,
|
|
|
|
CreateTargetWithFileAndTargetTriple,
|
|
|
|
(const char *, const char *), filename, target_triple);
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBTarget sb_target;
|
2012-01-30 15:41:31 +08:00
|
|
|
TargetSP target_sp;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp) {
|
2010-12-21 04:49:23 +08:00
|
|
|
const bool add_dependent_modules = true;
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error(m_opaque_sp->GetTargetList().CreateTarget(
|
2018-09-20 17:09:05 +08:00
|
|
|
*m_opaque_sp, filename, target_triple,
|
|
|
|
add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr,
|
2012-01-30 15:41:31 +08:00
|
|
|
target_sp));
|
|
|
|
sb_target.SetSP(target_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
"SBDebugger(%p)::CreateTargetWithFileAndTargetTriple "
|
|
|
|
"(filename=\"%s\", triple=%s) => SBTarget(%p)",
|
|
|
|
static_cast<void *>(m_opaque_sp.get()), filename, target_triple,
|
|
|
|
static_cast<void *>(target_sp.get()));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_target);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-02-23 08:35:02 +08:00
|
|
|
SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename,
|
2010-06-09 00:52:24 +08:00
|
|
|
const char *arch_cstr) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, CreateTargetWithFileAndArch,
|
|
|
|
(const char *, const char *), filename, arch_cstr);
|
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
SBTarget sb_target;
|
2012-01-30 15:41:31 +08:00
|
|
|
TargetSP target_sp;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp) {
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2021-01-27 04:15:09 +08:00
|
|
|
if (arch_cstr == nullptr) {
|
|
|
|
// The version of CreateTarget that takes an ArchSpec won't accept an
|
|
|
|
// empty ArchSpec, so when the arch hasn't been specified, we need to
|
|
|
|
// call the target triple version.
|
|
|
|
error = m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp, filename,
|
|
|
|
arch_cstr, eLoadDependentsYes, nullptr, target_sp);
|
|
|
|
} else {
|
|
|
|
PlatformSP platform_sp = m_opaque_sp->GetPlatformList()
|
|
|
|
.GetSelectedPlatform();
|
|
|
|
ArchSpec arch = Platform::GetAugmentedArchSpec(platform_sp.get(),
|
|
|
|
arch_cstr);
|
|
|
|
if (arch.IsValid())
|
|
|
|
error = m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp, filename,
|
|
|
|
arch, eLoadDependentsYes, platform_sp, target_sp);
|
|
|
|
else
|
|
|
|
error.SetErrorStringWithFormat("invalid arch_cstr: %s", arch_cstr);
|
|
|
|
}
|
2021-01-26 10:02:39 +08:00
|
|
|
if (error.Success())
|
|
|
|
sb_target.SetSP(target_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2021-03-02 07:26:35 +08:00
|
|
|
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
"SBDebugger(%p)::CreateTargetWithFileAndArch (filename=\"%s\", "
|
|
|
|
"arch=%s) => SBTarget(%p)",
|
2021-01-27 04:15:09 +08:00
|
|
|
static_cast<void *>(m_opaque_sp.get()),
|
|
|
|
filename ? filename : "<unspecified>",
|
|
|
|
arch_cstr ? arch_cstr : "<unspecified>",
|
2019-07-25 01:56:10 +08:00
|
|
|
static_cast<void *>(target_sp.get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_target);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-09-14 07:25:31 +08:00
|
|
|
SBTarget SBDebugger::CreateTarget(const char *filename) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, CreateTarget, (const char *),
|
|
|
|
filename);
|
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
SBTarget sb_target;
|
|
|
|
TargetSP target_sp;
|
2011-09-14 07:25:31 +08:00
|
|
|
if (m_opaque_sp) {
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2011-09-24 08:52:29 +08:00
|
|
|
const bool add_dependent_modules = true;
|
2015-10-31 09:22:59 +08:00
|
|
|
error = m_opaque_sp->GetTargetList().CreateTarget(
|
2018-09-20 17:09:05 +08:00
|
|
|
*m_opaque_sp, filename, "",
|
|
|
|
add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr,
|
|
|
|
target_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2020-12-11 16:09:39 +08:00
|
|
|
if (error.Success())
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_target.SetSP(target_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
"SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)",
|
|
|
|
static_cast<void *>(m_opaque_sp.get()), filename,
|
|
|
|
static_cast<void *>(target_sp.get()));
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_target);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
SBTarget SBDebugger::GetDummyTarget() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBDebugger, GetDummyTarget);
|
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
SBTarget sb_target;
|
|
|
|
if (m_opaque_sp) {
|
2020-11-10 07:25:59 +08:00
|
|
|
sb_target.SetSP(m_opaque_sp->GetDummyTarget().shared_from_this());
|
2017-09-15 04:22:49 +08:00
|
|
|
}
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "SBDebugger(%p)::GetDummyTarget() => SBTarget(%p)",
|
|
|
|
static_cast<void *>(m_opaque_sp.get()),
|
|
|
|
static_cast<void *>(sb_target.GetSP().get()));
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_target);
|
2017-09-15 04:22:49 +08:00
|
|
|
}
|
|
|
|
|
2014-04-04 12:06:10 +08:00
|
|
|
bool SBDebugger::DeleteTarget(lldb::SBTarget &target) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBDebugger, DeleteTarget, (lldb::SBTarget &),
|
|
|
|
target);
|
|
|
|
|
2011-06-16 05:24:24 +08:00
|
|
|
bool result = false;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp) {
|
2014-04-04 12:06:10 +08:00
|
|
|
TargetSP target_sp(target.GetSP());
|
2012-01-30 15:41:31 +08:00
|
|
|
if (target_sp) {
|
2014-04-04 12:06:10 +08:00
|
|
|
// No need to lock, the target list is thread safe
|
2010-08-27 05:32:51 +08:00
|
|
|
result = m_opaque_sp->GetTargetList().DeleteTarget(target_sp);
|
2012-01-30 15:41:31 +08:00
|
|
|
target_sp->Destroy();
|
|
|
|
target.Clear();
|
2011-09-14 07:25:31 +08:00
|
|
|
}
|
|
|
|
}
|
2013-11-21 05:07:01 +08:00
|
|
|
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "SBDebugger(%p)::DeleteTarget (SBTarget(%p)) => %i",
|
|
|
|
static_cast<void *>(m_opaque_sp.get()),
|
|
|
|
static_cast<void *>(target.m_opaque_sp.get()), result);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
return result;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
SBTarget SBDebugger::GetTargetAtIndex(uint32_t idx) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, GetTargetAtIndex, (uint32_t),
|
|
|
|
idx);
|
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
SBTarget sb_target;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp) {
|
2012-01-30 15:41:31 +08:00
|
|
|
// No need to lock, the target list is thread safe
|
2014-04-04 12:06:10 +08:00
|
|
|
sb_target.SetSP(m_opaque_sp->GetTargetList().GetTargetAtIndex(idx));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_target);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2014-04-04 12:06:10 +08:00
|
|
|
uint32_t SBDebugger::GetIndexOfTarget(lldb::SBTarget target) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(uint32_t, SBDebugger, GetIndexOfTarget, (lldb::SBTarget),
|
|
|
|
target);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-05-09 07:06:07 +08:00
|
|
|
lldb::TargetSP target_sp = target.GetSP();
|
|
|
|
if (!target_sp)
|
|
|
|
return UINT32_MAX;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (!m_opaque_sp)
|
2012-05-09 07:06:07 +08:00
|
|
|
return UINT32_MAX;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-08-27 05:32:51 +08:00
|
|
|
return m_opaque_sp->GetTargetList().GetIndexOfTarget(target.GetSP());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-09-06 00:53:14 +08:00
|
|
|
SBTarget SBDebugger::FindTargetWithProcessID(lldb::pid_t pid) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithProcessID,
|
|
|
|
(lldb::pid_t), pid);
|
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
SBTarget sb_target;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp) {
|
2012-01-30 15:41:31 +08:00
|
|
|
// No need to lock, the target list is thread safe
|
2014-04-04 12:06:10 +08:00
|
|
|
sb_target.SetSP(m_opaque_sp->GetTargetList().FindTargetWithProcessID(pid));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_target);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2014-04-04 12:06:10 +08:00
|
|
|
SBTarget SBDebugger::FindTargetWithFileAndArch(const char *filename,
|
2010-06-09 00:52:24 +08:00
|
|
|
const char *arch_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithFileAndArch,
|
|
|
|
(const char *, const char *), filename, arch_name);
|
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
SBTarget sb_target;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp && filename && filename[0]) {
|
2012-01-30 15:41:31 +08:00
|
|
|
// No need to lock, the target list is thread safe
|
2017-10-31 18:56:03 +08:00
|
|
|
ArchSpec arch = Platform::GetAugmentedArchSpec(
|
|
|
|
m_opaque_sp->GetPlatformList().GetSelectedPlatform().get(), arch_name);
|
2012-01-30 15:41:31 +08:00
|
|
|
TargetSP target_sp(
|
2014-04-04 12:06:10 +08:00
|
|
|
m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture(
|
2018-11-02 05:05:36 +08:00
|
|
|
FileSpec(filename), arch_name ? &arch : nullptr));
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_target.SetSP(target_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_target);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-04-19 07:15:17 +08:00
|
|
|
SBTarget SBDebugger::FindTargetWithLLDBProcess(const ProcessSP &process_sp) {
|
2012-01-30 15:41:31 +08:00
|
|
|
SBTarget sb_target;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp) {
|
2012-01-30 15:41:31 +08:00
|
|
|
// No need to lock, the target list is thread safe
|
|
|
|
sb_target.SetSP(
|
2010-08-27 05:32:51 +08:00
|
|
|
m_opaque_sp->GetTargetList().FindTargetWithProcess(process_sp.get()));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-11-21 05:07:01 +08:00
|
|
|
return sb_target;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
uint32_t SBDebugger::GetNumTargets() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumTargets);
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp) {
|
2012-01-30 15:41:31 +08:00
|
|
|
// No need to lock, the target list is thread safe
|
2010-08-27 05:32:51 +08:00
|
|
|
return m_opaque_sp->GetTargetList().GetNumTargets();
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
2010-06-23 09:19:29 +08:00
|
|
|
return 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-11-21 05:07:01 +08:00
|
|
|
|
|
|
|
SBTarget SBDebugger::GetSelectedTarget() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBDebugger, GetSelectedTarget);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
SBTarget sb_target;
|
2012-01-30 15:41:31 +08:00
|
|
|
TargetSP target_sp;
|
2013-11-21 05:07:01 +08:00
|
|
|
if (m_opaque_sp) {
|
2012-01-30 15:41:31 +08:00
|
|
|
// No need to lock, the target list is thread safe
|
2010-08-27 05:32:51 +08:00
|
|
|
target_sp = m_opaque_sp->GetTargetList().GetSelectedTarget();
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_target.SetSP(target_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
if (log) {
|
2010-10-26 11:11:13 +08:00
|
|
|
SBStream sstr;
|
2013-11-21 05:07:01 +08:00
|
|
|
sb_target.GetDescription(sstr, eDescriptionLevelBrief);
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "SBDebugger(%p)::GetSelectedTarget () => SBTarget(%p): %s",
|
|
|
|
static_cast<void *>(m_opaque_sp.get()),
|
|
|
|
static_cast<void *>(target_sp.get()), sstr.GetData());
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_target);
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
|
|
|
|
2012-09-07 06:02:28 +08:00
|
|
|
void SBDebugger::SetSelectedTarget(SBTarget &sb_target) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, SetSelectedTarget, (lldb::SBTarget &),
|
|
|
|
sb_target);
|
|
|
|
|
2012-09-07 06:02:28 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
TargetSP target_sp(sb_target.GetSP());
|
|
|
|
if (m_opaque_sp) {
|
2020-12-11 16:09:39 +08:00
|
|
|
m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
if (log) {
|
2010-10-26 11:11:13 +08:00
|
|
|
SBStream sstr;
|
2012-09-07 06:02:28 +08:00
|
|
|
sb_target.GetDescription(sstr, eDescriptionLevelBrief);
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "SBDebugger(%p)::SetSelectedTarget () => SBTarget(%p): %s",
|
|
|
|
static_cast<void *>(m_opaque_sp.get()),
|
|
|
|
static_cast<void *>(target_sp.get()), sstr.GetData());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-04 12:06:10 +08:00
|
|
|
SBPlatform SBDebugger::GetSelectedPlatform() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform, SBDebugger, GetSelectedPlatform);
|
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-09-07 06:02:28 +08:00
|
|
|
SBPlatform sb_platform;
|
|
|
|
DebuggerSP debugger_sp(m_opaque_sp);
|
2012-09-07 05:58:25 +08:00
|
|
|
if (debugger_sp) {
|
|
|
|
sb_platform.SetSP(debugger_sp->GetPlatformList().GetSelectedPlatform());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "SBDebugger(%p)::GetSelectedPlatform () => SBPlatform(%p): %s",
|
|
|
|
static_cast<void *>(m_opaque_sp.get()),
|
|
|
|
static_cast<void *>(sb_platform.GetSP().get()),
|
|
|
|
sb_platform.GetName());
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_platform);
|
2012-09-07 05:58:25 +08:00
|
|
|
}
|
|
|
|
|
2012-08-21 00:21:04 +08:00
|
|
|
void SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, SetSelectedPlatform,
|
|
|
|
(lldb::SBPlatform &), sb_platform);
|
|
|
|
|
2014-01-28 07:43:24 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-01-28 07:43:24 +08:00
|
|
|
DebuggerSP debugger_sp(m_opaque_sp);
|
|
|
|
if (debugger_sp) {
|
|
|
|
debugger_sp->GetPlatformList().SetSelectedPlatform(sb_platform.GetSP());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "SBDebugger(%p)::SetSelectedPlatform (SBPlatform(%p) %s)",
|
|
|
|
static_cast<void *>(m_opaque_sp.get()),
|
|
|
|
static_cast<void *>(sb_platform.GetSP().get()),
|
|
|
|
sb_platform.GetName());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2017-08-09 17:20:40 +08:00
|
|
|
uint32_t SBDebugger::GetNumPlatforms() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumPlatforms);
|
|
|
|
|
2017-08-09 17:20:40 +08:00
|
|
|
if (m_opaque_sp) {
|
|
|
|
// No need to lock, the platform list is thread safe
|
|
|
|
return m_opaque_sp->GetPlatformList().GetSize();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBPlatform SBDebugger::GetPlatformAtIndex(uint32_t idx) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBPlatform, SBDebugger, GetPlatformAtIndex,
|
|
|
|
(uint32_t), idx);
|
|
|
|
|
2017-08-09 17:20:40 +08:00
|
|
|
SBPlatform sb_platform;
|
|
|
|
if (m_opaque_sp) {
|
|
|
|
// No need to lock, the platform list is thread safe
|
|
|
|
sb_platform.SetSP(m_opaque_sp->GetPlatformList().GetAtIndex(idx));
|
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_platform);
|
2017-08-09 17:20:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBDebugger::GetNumAvailablePlatforms() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumAvailablePlatforms);
|
|
|
|
|
2017-08-09 17:20:40 +08:00
|
|
|
uint32_t idx = 0;
|
|
|
|
while (true) {
|
|
|
|
if (!PluginManager::GetPlatformPluginNameAtIndex(idx)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++idx;
|
|
|
|
}
|
|
|
|
// +1 for the host platform, which should always appear first in the list.
|
|
|
|
return idx + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBStructuredData SBDebugger::GetAvailablePlatformInfoAtIndex(uint32_t idx) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBStructuredData, SBDebugger,
|
|
|
|
GetAvailablePlatformInfoAtIndex, (uint32_t), idx);
|
|
|
|
|
2017-08-09 17:20:40 +08:00
|
|
|
SBStructuredData data;
|
2019-08-15 06:19:23 +08:00
|
|
|
auto platform_dict = std::make_unique<StructuredData::Dictionary>();
|
2017-08-09 17:20:40 +08:00
|
|
|
llvm::StringRef name_str("name"), desc_str("description");
|
|
|
|
|
|
|
|
if (idx == 0) {
|
|
|
|
PlatformSP host_platform_sp(Platform::GetHostPlatform());
|
2021-10-15 19:07:39 +08:00
|
|
|
platform_dict->AddStringItem(name_str, host_platform_sp->GetPluginName());
|
2017-08-09 17:20:40 +08:00
|
|
|
platform_dict->AddStringItem(
|
|
|
|
desc_str, llvm::StringRef(host_platform_sp->GetDescription()));
|
|
|
|
} else if (idx > 0) {
|
|
|
|
const char *plugin_name =
|
|
|
|
PluginManager::GetPlatformPluginNameAtIndex(idx - 1);
|
|
|
|
if (!plugin_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(data);
|
2017-08-09 17:20:40 +08:00
|
|
|
}
|
|
|
|
platform_dict->AddStringItem(name_str, llvm::StringRef(plugin_name));
|
|
|
|
|
|
|
|
const char *plugin_desc =
|
|
|
|
PluginManager::GetPlatformPluginDescriptionAtIndex(idx - 1);
|
|
|
|
if (!plugin_desc) {
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(data);
|
2017-08-09 17:20:40 +08:00
|
|
|
}
|
|
|
|
platform_dict->AddStringItem(desc_str, llvm::StringRef(plugin_desc));
|
|
|
|
}
|
|
|
|
|
|
|
|
data.m_impl_up->SetObjectSP(
|
|
|
|
StructuredData::ObjectSP(platform_dict.release()));
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(data);
|
2017-08-09 17:20:40 +08:00
|
|
|
}
|
|
|
|
|
2010-11-20 04:47:54 +08:00
|
|
|
void SBDebugger::DispatchInput(void *baton, const void *data, size_t data_len) {
|
2019-03-09 03:09:27 +08:00
|
|
|
LLDB_RECORD_DUMMY(void, SBDebugger, DispatchInput,
|
|
|
|
(void *, const void *, size_t), baton, data, data_len);
|
|
|
|
|
2012-08-21 00:21:04 +08:00
|
|
|
DispatchInput(data, data_len);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-11-20 04:47:54 +08:00
|
|
|
void SBDebugger::DispatchInput(const void *data, size_t data_len) {
|
2019-03-09 03:09:27 +08:00
|
|
|
LLDB_RECORD_DUMMY(void, SBDebugger, DispatchInput, (const void *, size_t),
|
|
|
|
data, data_len);
|
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
// Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2016-09-07 04:57:50 +08:00
|
|
|
//
|
2014-01-28 07:43:24 +08:00
|
|
|
// if (log)
|
2019-07-25 01:56:10 +08:00
|
|
|
// LLDB_LOGF(log, "SBDebugger(%p)::DispatchInput (data=\"%.*s\",
|
2014-01-28 07:43:24 +08:00
|
|
|
// size_t=%" PRIu64 ")",
|
|
|
|
// m_opaque_sp.get(),
|
|
|
|
// (int) data_len,
|
|
|
|
// (const char *) data,
|
|
|
|
// (uint64_t)data_len);
|
2016-09-07 04:57:50 +08:00
|
|
|
//
|
2010-11-20 04:47:54 +08:00
|
|
|
// if (m_opaque_sp)
|
|
|
|
// m_opaque_sp->DispatchInput ((const char *) data, data_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBDebugger::DispatchInputInterrupt() {
|
2019-10-09 03:17:42 +08:00
|
|
|
LLDB_RECORD_DUMMY_NO_ARGS(void, SBDebugger, DispatchInputInterrupt);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2010-11-20 04:47:54 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->DispatchInputInterrupt();
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void SBDebugger::DispatchInputEndOfFile() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, DispatchInputEndOfFile);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->DispatchInputEndOfFile();
|
|
|
|
}
|
2010-06-23 09:19:29 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
void SBDebugger::PushInputReader(SBInputReader &reader) {
|
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, PushInputReader, (lldb::SBInputReader &),
|
|
|
|
reader);
|
|
|
|
}
|
2014-10-11 08:38:27 +08:00
|
|
|
|
|
|
|
void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
|
2014-01-28 07:43:24 +08:00
|
|
|
bool spawn_thread) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, RunCommandInterpreter, (bool, bool),
|
|
|
|
auto_handle_events, spawn_thread);
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp) {
|
2014-10-11 08:38:27 +08:00
|
|
|
CommandInterpreterRunOptions options;
|
2020-05-01 04:17:48 +08:00
|
|
|
options.SetAutoHandleEvents(auto_handle_events);
|
|
|
|
options.SetSpawnThread(spawn_thread);
|
|
|
|
m_opaque_sp->GetCommandInterpreter().RunCommandInterpreter(options);
|
2014-10-11 08:38:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
|
|
|
|
bool spawn_thread,
|
|
|
|
SBCommandInterpreterRunOptions &options,
|
2014-10-14 09:20:07 +08:00
|
|
|
int &num_errors, bool &quit_requested,
|
|
|
|
bool &stopped_for_crash)
|
2014-10-11 08:38:27 +08:00
|
|
|
|
|
|
|
{
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, RunCommandInterpreter,
|
|
|
|
(bool, bool, lldb::SBCommandInterpreterRunOptions &, int &,
|
|
|
|
bool &, bool &),
|
|
|
|
auto_handle_events, spawn_thread, options, num_errors,
|
|
|
|
quit_requested, stopped_for_crash);
|
|
|
|
|
2014-10-11 08:38:27 +08:00
|
|
|
if (m_opaque_sp) {
|
2020-05-01 04:17:48 +08:00
|
|
|
options.SetAutoHandleEvents(auto_handle_events);
|
|
|
|
options.SetSpawnThread(spawn_thread);
|
2014-10-11 08:38:27 +08:00
|
|
|
CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter();
|
2020-05-02 02:29:07 +08:00
|
|
|
CommandInterpreterRunResult result =
|
|
|
|
interp.RunCommandInterpreter(options.ref());
|
|
|
|
num_errors = result.GetNumErrors();
|
|
|
|
quit_requested =
|
|
|
|
result.IsResult(lldb::eCommandInterpreterResultQuitRequested);
|
|
|
|
stopped_for_crash =
|
|
|
|
result.IsResult(lldb::eCommandInterpreterResultInferiorCrash);
|
2014-10-11 08:38:27 +08:00
|
|
|
}
|
This patch captures and serializes all output being written by the
command line driver, including the lldb prompt being output by
editline, the asynchronous process output & error messages, and
asynchronous messages written by target stop-hooks.
As part of this it introduces a new Stream class,
StreamAsynchronousIO. A StreamAsynchronousIO object is created with a
broadcaster, who will eventually broadcast the stream's data for a
listener to handle, and an event type indicating what type of event
the broadcaster will broadcast. When the Write method is called on a
StreamAsynchronousIO object, the data is appended to an internal
string. When the Flush method is called on a StreamAsynchronousIO
object, it broadcasts it's data string and clears the string.
Anything in lldb-core that needs to generate asynchronous output for
the end-user should use the StreamAsynchronousIO objects.
I have also added a new notification type for InputReaders, to let
them know that a asynchronous output has been written. This is to
allow the input readers to, for example, refresh their prompts and
lines, if desired. I added the case statements to all the input
readers to catch this notification, but I haven't added any code for
handling them yet (except to the IOChannel input reader).
llvm-svn: 130721
2011-05-03 04:41:46 +08:00
|
|
|
}
|
|
|
|
|
2020-05-02 04:23:51 +08:00
|
|
|
SBCommandInterpreterRunResult SBDebugger::RunCommandInterpreter(
|
|
|
|
const SBCommandInterpreterRunOptions &options) {
|
|
|
|
LLDB_RECORD_METHOD(lldb::SBCommandInterpreterRunResult, SBDebugger,
|
|
|
|
RunCommandInterpreter,
|
|
|
|
(const lldb::SBCommandInterpreterRunOptions &), options);
|
|
|
|
|
|
|
|
if (!m_opaque_sp)
|
|
|
|
return LLDB_RECORD_RESULT(SBCommandInterpreterRunResult());
|
|
|
|
|
|
|
|
CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter();
|
|
|
|
CommandInterpreterRunResult result =
|
|
|
|
interp.RunCommandInterpreter(options.ref());
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(SBCommandInterpreterRunResult(result));
|
|
|
|
}
|
|
|
|
|
2015-10-20 08:23:46 +08:00
|
|
|
SBError SBDebugger::RunREPL(lldb::LanguageType language,
|
|
|
|
const char *repl_options) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, RunREPL,
|
|
|
|
(lldb::LanguageType, const char *), language,
|
|
|
|
repl_options);
|
|
|
|
|
2015-10-20 08:23:46 +08:00
|
|
|
SBError error;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
error.ref() = m_opaque_sp->RunREPL(language, repl_options);
|
|
|
|
else
|
|
|
|
error.SetErrorString("invalid debugger");
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(error);
|
2015-10-20 08:23:46 +08:00
|
|
|
}
|
|
|
|
|
2011-04-19 07:15:17 +08:00
|
|
|
void SBDebugger::reset(const DebuggerSP &debugger_sp) {
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp = debugger_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
Debugger *SBDebugger::get() const { return m_opaque_sp.get(); }
|
|
|
|
|
|
|
|
Debugger &SBDebugger::ref() const {
|
|
|
|
assert(m_opaque_sp.get());
|
|
|
|
return *m_opaque_sp;
|
|
|
|
}
|
|
|
|
|
2011-10-01 10:59:24 +08:00
|
|
|
const lldb::DebuggerSP &SBDebugger::get_sp() const { return m_opaque_sp; }
|
2010-06-23 09:19:29 +08:00
|
|
|
|
2010-07-01 00:22:25 +08:00
|
|
|
SBDebugger SBDebugger::FindDebuggerWithID(int id) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD(lldb::SBDebugger, SBDebugger, FindDebuggerWithID,
|
|
|
|
(int), id);
|
|
|
|
|
2010-12-21 04:49:23 +08:00
|
|
|
// No need to lock, the debugger list is thread safe
|
2010-07-01 00:22:25 +08:00
|
|
|
SBDebugger sb_debugger;
|
2011-04-19 07:15:17 +08:00
|
|
|
DebuggerSP debugger_sp = Debugger::FindDebuggerWithID(id);
|
2010-07-01 00:22:25 +08:00
|
|
|
if (debugger_sp)
|
|
|
|
sb_debugger.reset(debugger_sp);
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_debugger);
|
2010-07-01 00:22:25 +08:00
|
|
|
}
|
2010-08-31 03:44:40 +08:00
|
|
|
|
2010-09-10 01:45:09 +08:00
|
|
|
const char *SBDebugger::GetInstanceName() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBDebugger, GetInstanceName);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
return (m_opaque_sp ? m_opaque_sp->GetInstanceName().AsCString() : nullptr);
|
2010-09-10 01:45:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBError SBDebugger::SetInternalVariable(const char *var_name, const char *value,
|
|
|
|
const char *debugger_instance_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD(lldb::SBError, SBDebugger, SetInternalVariable,
|
|
|
|
(const char *, const char *, const char *),
|
|
|
|
var_name, value, debugger_instance_name);
|
|
|
|
|
2012-08-23 02:39:03 +08:00
|
|
|
SBError sb_error;
|
|
|
|
DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName(
|
|
|
|
ConstString(debugger_instance_name)));
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2012-08-23 02:39:03 +08:00
|
|
|
if (debugger_sp) {
|
2021-02-02 21:41:41 +08:00
|
|
|
ExecutionContext exe_ctx(
|
|
|
|
debugger_sp->GetCommandInterpreter().GetExecutionContext());
|
2012-08-23 02:39:03 +08:00
|
|
|
error = debugger_sp->SetPropertyValue(&exe_ctx, eVarSetOperationAssign,
|
|
|
|
var_name, value);
|
|
|
|
} else {
|
|
|
|
error.SetErrorStringWithFormat("invalid debugger instance name '%s'",
|
|
|
|
debugger_instance_name);
|
|
|
|
}
|
|
|
|
if (error.Fail())
|
|
|
|
sb_error.SetError(error);
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_error);
|
2010-09-04 08:03:46 +08:00
|
|
|
}
|
|
|
|
|
2011-04-19 07:15:17 +08:00
|
|
|
SBStringList
|
2010-09-10 01:45:09 +08:00
|
|
|
SBDebugger::GetInternalVariableValue(const char *var_name,
|
|
|
|
const char *debugger_instance_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD(
|
|
|
|
lldb::SBStringList, SBDebugger, GetInternalVariableValue,
|
|
|
|
(const char *, const char *), var_name, debugger_instance_name);
|
|
|
|
|
2012-08-23 02:39:03 +08:00
|
|
|
DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName(
|
|
|
|
ConstString(debugger_instance_name)));
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2012-08-23 02:39:03 +08:00
|
|
|
if (debugger_sp) {
|
2021-02-02 21:41:41 +08:00
|
|
|
ExecutionContext exe_ctx(
|
|
|
|
debugger_sp->GetCommandInterpreter().GetExecutionContext());
|
2012-08-23 02:39:03 +08:00
|
|
|
lldb::OptionValueSP value_sp(
|
|
|
|
debugger_sp->GetPropertyValue(&exe_ctx, var_name, false, error));
|
|
|
|
if (value_sp) {
|
|
|
|
StreamString value_strm;
|
|
|
|
value_sp->DumpValue(&exe_ctx, value_strm, OptionValue::eDumpOptionValue);
|
2020-01-29 03:23:46 +08:00
|
|
|
const std::string &value_str = std::string(value_strm.GetString());
|
2012-08-23 02:39:03 +08:00
|
|
|
if (!value_str.empty()) {
|
|
|
|
StringList string_list;
|
2014-01-28 07:43:24 +08:00
|
|
|
string_list.SplitIntoLines(value_str);
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(SBStringList(&string_list));
|
2012-08-23 02:39:03 +08:00
|
|
|
}
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(SBStringList());
|
2010-09-04 08:03:46 +08:00
|
|
|
}
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
uint32_t SBDebugger::GetTerminalWidth() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDebugger, GetTerminalWidth);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0);
|
2010-09-18 09:14:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBDebugger::SetTerminalWidth(uint32_t term_width) {
|
2019-10-09 03:17:42 +08:00
|
|
|
LLDB_RECORD_DUMMY(void, SBDebugger, SetTerminalWidth, (uint32_t), term_width);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2010-09-18 09:14:36 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->SetTerminalWidth(term_width);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBDebugger::GetPrompt() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBDebugger, GetPrompt);
|
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "SBDebugger(%p)::GetPrompt () => \"%s\"",
|
|
|
|
static_cast<void *>(m_opaque_sp.get()),
|
|
|
|
(m_opaque_sp ? m_opaque_sp->GetPrompt().str().c_str() : ""));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-24 02:06:53 +08:00
|
|
|
return (m_opaque_sp ? ConstString(m_opaque_sp->GetPrompt()).GetCString()
|
|
|
|
: nullptr);
|
2010-09-18 09:14:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBDebugger::SetPrompt(const char *prompt) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, SetPrompt, (const char *), prompt);
|
|
|
|
|
2010-09-18 09:14:36 +08:00
|
|
|
if (m_opaque_sp)
|
2021-05-18 15:03:28 +08:00
|
|
|
m_opaque_sp->SetPrompt(llvm::StringRef(prompt));
|
2010-09-18 09:14:36 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-11-14 03:18:16 +08:00
|
|
|
const char *SBDebugger::GetReproducerPath() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBDebugger, GetReproducerPath);
|
|
|
|
|
2018-11-14 03:18:16 +08:00
|
|
|
return (m_opaque_sp
|
|
|
|
? ConstString(m_opaque_sp->GetReproducerPath()).GetCString()
|
|
|
|
: nullptr);
|
|
|
|
}
|
|
|
|
|
2010-09-18 09:14:36 +08:00
|
|
|
ScriptLanguage SBDebugger::GetScriptLanguage() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ScriptLanguage, SBDebugger,
|
|
|
|
GetScriptLanguage);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
return (m_opaque_sp ? m_opaque_sp->GetScriptLanguage() : eScriptLanguageNone);
|
2010-09-18 09:14:36 +08:00
|
|
|
}
|
|
|
|
|
2011-04-19 07:15:17 +08:00
|
|
|
void SBDebugger::SetScriptLanguage(ScriptLanguage script_lang) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, SetScriptLanguage,
|
|
|
|
(lldb::ScriptLanguage), script_lang);
|
|
|
|
|
2010-09-18 09:14:36 +08:00
|
|
|
if (m_opaque_sp) {
|
|
|
|
m_opaque_sp->SetScriptLanguage(script_lang);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-09-18 09:14:36 +08:00
|
|
|
}
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
bool SBDebugger::SetUseExternalEditor(bool value) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBDebugger, SetUseExternalEditor, (bool), value);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
return (m_opaque_sp ? m_opaque_sp->SetUseExternalEditor(value) : false);
|
2010-08-31 03:44:40 +08:00
|
|
|
}
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
bool SBDebugger::GetUseExternalEditor() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBDebugger, GetUseExternalEditor);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
return (m_opaque_sp ? m_opaque_sp->GetUseExternalEditor() : false);
|
2010-08-31 03:44:40 +08:00
|
|
|
}
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
bool SBDebugger::SetUseColor(bool value) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBDebugger, SetUseColor, (bool), value);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
return (m_opaque_sp ? m_opaque_sp->SetUseColor(value) : false);
|
2013-05-24 04:47:45 +08:00
|
|
|
}
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
bool SBDebugger::GetUseColor() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetUseColor);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false);
|
2013-05-24 04:47:45 +08:00
|
|
|
}
|
|
|
|
|
2020-04-20 22:17:17 +08:00
|
|
|
bool SBDebugger::SetUseSourceCache(bool value) {
|
|
|
|
LLDB_RECORD_METHOD(bool, SBDebugger, SetUseSourceCache, (bool), value);
|
|
|
|
|
|
|
|
return (m_opaque_sp ? m_opaque_sp->SetUseSourceCache(value) : false);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBDebugger::GetUseSourceCache() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetUseSourceCache);
|
|
|
|
|
|
|
|
return (m_opaque_sp ? m_opaque_sp->GetUseSourceCache() : false);
|
|
|
|
}
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
bool SBDebugger::GetDescription(SBStream &description) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &),
|
|
|
|
description);
|
|
|
|
|
2011-11-13 14:57:31 +08:00
|
|
|
Stream &strm = description.ref();
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
if (m_opaque_sp) {
|
|
|
|
const char *name = m_opaque_sp->GetInstanceName().AsCString();
|
2011-04-19 07:15:17 +08:00
|
|
|
user_id_t id = m_opaque_sp->GetID();
|
2012-11-30 05:49:15 +08:00
|
|
|
strm.Printf("Debugger (instance: \"%s\", id: %" PRIu64 ")", name, id);
|
2010-09-20 13:20:02 +08:00
|
|
|
} else
|
2011-11-13 14:57:31 +08:00
|
|
|
strm.PutCString("No value");
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
return true;
|
|
|
|
}
|
2010-11-20 04:47:54 +08:00
|
|
|
|
|
|
|
user_id_t SBDebugger::GetID() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::user_id_t, SBDebugger, GetID);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
return (m_opaque_sp ? m_opaque_sp->GetID() : LLDB_INVALID_UID);
|
2010-11-20 04:47:54 +08:00
|
|
|
}
|
2011-04-30 09:09:13 +08:00
|
|
|
|
2014-09-20 04:11:50 +08:00
|
|
|
SBError SBDebugger::SetCurrentPlatform(const char *platform_name_cstr) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, SetCurrentPlatform,
|
|
|
|
(const char *), platform_name_cstr);
|
|
|
|
|
2011-04-30 09:09:13 +08:00
|
|
|
SBError sb_error;
|
|
|
|
if (m_opaque_sp) {
|
2014-09-20 04:11:50 +08:00
|
|
|
if (platform_name_cstr && platform_name_cstr[0]) {
|
|
|
|
ConstString platform_name(platform_name_cstr);
|
|
|
|
PlatformSP platform_sp(Platform::Find(platform_name));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-09-20 04:11:50 +08:00
|
|
|
if (platform_sp) {
|
|
|
|
// Already have a platform with this name, just select it
|
|
|
|
m_opaque_sp->GetPlatformList().SetSelectedPlatform(platform_sp);
|
|
|
|
} else {
|
|
|
|
// We don't have a platform by this name yet, create one
|
|
|
|
platform_sp = Platform::Create(platform_name, sb_error.ref());
|
|
|
|
if (platform_sp) {
|
|
|
|
// We created the platform, now append and select it
|
|
|
|
bool make_selected = true;
|
|
|
|
m_opaque_sp->GetPlatformList().Append(platform_sp, make_selected);
|
2011-04-30 09:09:13 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
} else {
|
2014-09-20 04:11:50 +08:00
|
|
|
sb_error.ref().SetErrorString("invalid platform name");
|
2011-04-30 09:09:13 +08:00
|
|
|
}
|
2014-09-20 04:11:50 +08:00
|
|
|
} else {
|
|
|
|
sb_error.ref().SetErrorString("invalid debugger");
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_error);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-06-17 11:31:01 +08:00
|
|
|
bool SBDebugger::SetCurrentPlatformSDKRoot(const char *sysroot) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBDebugger, SetCurrentPlatformSDKRoot,
|
|
|
|
(const char *), sysroot);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
This patch captures and serializes all output being written by the
command line driver, including the lldb prompt being output by
editline, the asynchronous process output & error messages, and
asynchronous messages written by target stop-hooks.
As part of this it introduces a new Stream class,
StreamAsynchronousIO. A StreamAsynchronousIO object is created with a
broadcaster, who will eventually broadcast the stream's data for a
listener to handle, and an event type indicating what type of event
the broadcaster will broadcast. When the Write method is called on a
StreamAsynchronousIO object, the data is appended to an internal
string. When the Flush method is called on a StreamAsynchronousIO
object, it broadcasts it's data string and clears the string.
Anything in lldb-core that needs to generate asynchronous output for
the end-user should use the StreamAsynchronousIO objects.
I have also added a new notification type for InputReaders, to let
them know that a asynchronous output has been written. This is to
allow the input readers to, for example, refresh their prompts and
lines, if desired. I added the case statements to all the input
readers to catch this notification, but I haven't added any code for
handling them yet (except to the IOChannel input reader).
llvm-svn: 130721
2011-05-03 04:41:46 +08:00
|
|
|
if (m_opaque_sp) {
|
2011-06-17 11:31:01 +08:00
|
|
|
PlatformSP platform_sp(
|
|
|
|
m_opaque_sp->GetPlatformList().GetSelectedPlatform());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-06-17 11:31:01 +08:00
|
|
|
if (platform_sp) {
|
2016-08-24 13:25:32 +08:00
|
|
|
if (log && sysroot)
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "SBDebugger::SetCurrentPlatformSDKRoot (\"%s\")",
|
|
|
|
sysroot);
|
2011-06-17 11:31:01 +08:00
|
|
|
platform_sp->SetSDKRootDirectory(ConstString(sysroot));
|
|
|
|
return true;
|
2014-09-20 04:11:50 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2011-04-30 09:09:13 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-06-17 11:31:01 +08:00
|
|
|
bool SBDebugger::GetCloseInputOnEOF() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetCloseInputOnEOF);
|
|
|
|
|
2011-06-17 11:31:01 +08:00
|
|
|
return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false);
|
|
|
|
}
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
void SBDebugger::SetCloseInputOnEOF(bool b) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDebugger, SetCloseInputOnEOF, (bool), b);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->SetCloseInputOnEOF(b);
|
2011-05-29 12:06:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBTypeCategory SBDebugger::GetCategory(const char *category_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory,
|
|
|
|
(const char *), category_name);
|
|
|
|
|
2011-05-29 12:06:55 +08:00
|
|
|
if (!category_name || *category_name == 0)
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(SBTypeCategory());
|
2012-02-15 10:34:21 +08:00
|
|
|
|
|
|
|
TypeCategoryImplSP category_sp;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
if (DataVisualization::Categories::GetCategory(ConstString(category_name),
|
2019-03-06 08:06:00 +08:00
|
|
|
category_sp, false)) {
|
|
|
|
return LLDB_RECORD_RESULT(SBTypeCategory(category_sp));
|
|
|
|
} else {
|
|
|
|
return LLDB_RECORD_RESULT(SBTypeCategory());
|
|
|
|
}
|
2012-02-15 10:34:21 +08:00
|
|
|
}
|
|
|
|
|
2015-12-19 05:25:24 +08:00
|
|
|
SBTypeCategory SBDebugger::GetCategory(lldb::LanguageType lang_type) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory,
|
|
|
|
(lldb::LanguageType), lang_type);
|
|
|
|
|
2015-12-19 05:25:24 +08:00
|
|
|
TypeCategoryImplSP category_sp;
|
2019-03-06 08:06:00 +08:00
|
|
|
if (DataVisualization::Categories::GetCategory(lang_type, category_sp)) {
|
|
|
|
return LLDB_RECORD_RESULT(SBTypeCategory(category_sp));
|
|
|
|
} else {
|
|
|
|
return LLDB_RECORD_RESULT(SBTypeCategory());
|
|
|
|
}
|
2015-12-19 05:25:24 +08:00
|
|
|
}
|
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
SBTypeCategory SBDebugger::CreateCategory(const char *category_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, CreateCategory,
|
|
|
|
(const char *), category_name);
|
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
if (!category_name || *category_name == 0)
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(SBTypeCategory());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
TypeCategoryImplSP category_sp;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
if (DataVisualization::Categories::GetCategory(ConstString(category_name),
|
2019-03-06 08:06:00 +08:00
|
|
|
category_sp, true)) {
|
|
|
|
return LLDB_RECORD_RESULT(SBTypeCategory(category_sp));
|
|
|
|
} else {
|
|
|
|
return LLDB_RECORD_RESULT(SBTypeCategory());
|
|
|
|
}
|
2012-02-15 10:34:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SBDebugger::DeleteCategory(const char *category_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBDebugger, DeleteCategory, (const char *),
|
|
|
|
category_name);
|
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
if (!category_name || *category_name == 0)
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
return DataVisualization::Categories::Delete(ConstString(category_name));
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBDebugger::GetNumCategories() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumCategories);
|
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
return DataVisualization::Categories::GetCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
SBTypeCategory SBDebugger::GetCategoryAtIndex(uint32_t index) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategoryAtIndex,
|
|
|
|
(uint32_t), index);
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
SBTypeCategory(DataVisualization::Categories::GetCategoryAtIndex(index)));
|
2012-02-15 10:34:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBTypeCategory SBDebugger::GetDefaultCategory() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeCategory, SBDebugger,
|
|
|
|
GetDefaultCategory);
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(GetCategory("default"));
|
2012-02-15 10:34:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBTypeFormat SBDebugger::GetFormatForType(SBTypeNameSpecifier type_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTypeFormat, SBDebugger, GetFormatForType,
|
|
|
|
(lldb::SBTypeNameSpecifier), type_name);
|
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
SBTypeCategory default_category_sb = GetDefaultCategory();
|
|
|
|
if (default_category_sb.GetEnabled())
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(default_category_sb.GetFormatForType(type_name));
|
|
|
|
return LLDB_RECORD_RESULT(SBTypeFormat());
|
2012-02-15 10:34:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBTypeSummary SBDebugger::GetSummaryForType(SBTypeNameSpecifier type_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBDebugger, GetSummaryForType,
|
|
|
|
(lldb::SBTypeNameSpecifier), type_name);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
if (!type_name.IsValid())
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(SBTypeSummary());
|
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP())));
|
2012-02-15 10:34:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBTypeFilter SBDebugger::GetFilterForType(SBTypeNameSpecifier type_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBDebugger, GetFilterForType,
|
|
|
|
(lldb::SBTypeNameSpecifier), type_name);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
if (!type_name.IsValid())
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(SBTypeFilter());
|
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP())));
|
2012-02-15 10:34:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBTypeSynthetic SBDebugger::GetSyntheticForType(SBTypeNameSpecifier type_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBDebugger, GetSyntheticForType,
|
|
|
|
(lldb::SBTypeNameSpecifier), type_name);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
if (!type_name.IsValid())
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(SBTypeSynthetic());
|
|
|
|
return LLDB_RECORD_RESULT(SBTypeSynthetic(
|
|
|
|
DataVisualization::GetSyntheticForType(type_name.GetSP())));
|
2012-02-15 10:34:21 +08:00
|
|
|
}
|
|
|
|
|
2017-03-01 18:08:40 +08:00
|
|
|
static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) {
|
|
|
|
if (categories == nullptr)
|
|
|
|
return {};
|
|
|
|
size_t len = 0;
|
|
|
|
while (categories[len] != nullptr)
|
|
|
|
++len;
|
|
|
|
return llvm::makeArrayRef(categories, len);
|
|
|
|
}
|
|
|
|
|
2012-02-21 10:23:08 +08:00
|
|
|
bool SBDebugger::EnableLog(const char *channel, const char **categories) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBDebugger, EnableLog, (const char *, const char **),
|
|
|
|
channel, categories);
|
|
|
|
|
2012-02-21 10:23:08 +08:00
|
|
|
if (m_opaque_sp) {
|
|
|
|
uint32_t log_options =
|
|
|
|
LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
|
2017-03-15 17:06:58 +08:00
|
|
|
std::string error;
|
|
|
|
llvm::raw_string_ostream error_stream(error);
|
2017-03-01 18:08:40 +08:00
|
|
|
return m_opaque_sp->EnableLog(channel, GetCategoryArray(categories), "",
|
2017-03-15 17:06:58 +08:00
|
|
|
log_options, error_stream);
|
2012-02-21 10:23:08 +08:00
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2012-02-23 06:49:20 +08:00
|
|
|
|
|
|
|
void SBDebugger::SetLoggingCallback(lldb::LogOutputCallback log_callback,
|
|
|
|
void *baton) {
|
2019-03-12 04:31:21 +08:00
|
|
|
LLDB_RECORD_DUMMY(void, SBDebugger, SetLoggingCallback,
|
|
|
|
(lldb::LogOutputCallback, void *), log_callback, baton);
|
2019-03-09 03:09:27 +08:00
|
|
|
|
2012-02-23 06:49:20 +08:00
|
|
|
if (m_opaque_sp) {
|
|
|
|
return m_opaque_sp->SetLoggingCallback(log_callback, baton);
|
|
|
|
}
|
|
|
|
}
|
2019-03-20 01:13:13 +08:00
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace repro {
|
|
|
|
|
2019-09-12 07:27:09 +08:00
|
|
|
template <> void RegisterMethods<SBInputReader>(Registry &R) {
|
2019-03-20 01:13:13 +08:00
|
|
|
LLDB_REGISTER_METHOD(void, SBInputReader, SetIsDone, (bool));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBInputReader, IsActive, ());
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SetFileHandleRedirect(SBDebugger *, FILE *, bool) {
|
|
|
|
// Do nothing.
|
|
|
|
}
|
|
|
|
|
2019-10-03 12:04:48 +08:00
|
|
|
static SBError SetFileRedirect(SBDebugger *, SBFile file) { return SBError(); }
|
|
|
|
|
2019-10-11 03:10:59 +08:00
|
|
|
static SBError SetFileRedirect(SBDebugger *, FileSP file) { return SBError(); }
|
|
|
|
|
2019-09-12 07:27:09 +08:00
|
|
|
template <> void RegisterMethods<SBDebugger>(Registry &R) {
|
2019-03-20 01:13:13 +08:00
|
|
|
// Custom implementation.
|
2020-04-21 00:37:07 +08:00
|
|
|
R.Register(&invoke<void (SBDebugger::*)(FILE *, bool)>::method<
|
|
|
|
&SBDebugger::SetErrorFileHandle>::record,
|
2019-03-20 01:13:13 +08:00
|
|
|
&SetFileHandleRedirect);
|
2020-04-21 00:37:07 +08:00
|
|
|
R.Register(&invoke<void (SBDebugger::*)(FILE *, bool)>::method<
|
|
|
|
&SBDebugger::SetOutputFileHandle>::record,
|
2019-03-20 01:13:13 +08:00
|
|
|
&SetFileHandleRedirect);
|
|
|
|
|
2019-10-03 12:04:48 +08:00
|
|
|
R.Register(&invoke<SBError (SBDebugger::*)(
|
2020-04-21 00:37:07 +08:00
|
|
|
SBFile)>::method<&SBDebugger::SetInputFile>::record,
|
2019-10-03 12:04:48 +08:00
|
|
|
&SetFileRedirect);
|
|
|
|
R.Register(&invoke<SBError (SBDebugger::*)(
|
2020-04-21 00:37:07 +08:00
|
|
|
SBFile)>::method<&SBDebugger::SetOutputFile>::record,
|
2019-10-03 12:04:48 +08:00
|
|
|
&SetFileRedirect);
|
|
|
|
R.Register(&invoke<SBError (SBDebugger::*)(
|
2020-04-21 00:37:07 +08:00
|
|
|
SBFile)>::method<&SBDebugger::SetErrorFile>::record,
|
2019-10-03 12:04:48 +08:00
|
|
|
&SetFileRedirect);
|
|
|
|
|
2019-10-11 03:10:59 +08:00
|
|
|
R.Register(&invoke<SBError (SBDebugger::*)(
|
2020-04-21 00:37:07 +08:00
|
|
|
FileSP)>::method<&SBDebugger::SetInputFile>::record,
|
2019-10-11 03:10:59 +08:00
|
|
|
&SetFileRedirect);
|
|
|
|
R.Register(&invoke<SBError (SBDebugger::*)(
|
2020-04-21 00:37:07 +08:00
|
|
|
FileSP)>::method<&SBDebugger::SetOutputFile>::record,
|
2019-10-11 03:10:59 +08:00
|
|
|
&SetFileRedirect);
|
|
|
|
R.Register(&invoke<SBError (SBDebugger::*)(
|
2020-04-21 00:37:07 +08:00
|
|
|
FileSP)>::method<&SBDebugger::SetErrorFile>::record,
|
2019-10-11 03:10:59 +08:00
|
|
|
&SetFileRedirect);
|
|
|
|
|
[lldb/Reproducers] Fix passive replay for (char*, size_t) functions.
Several SB API functions return strings using (char*, size_t) output
arguments. During capture, we serialize an empty string for the char*
because the memory can be uninitialized.
During active replay, we have custom replay redirects that ensure that
we don't override the buffer from which we're reading, but rather write
to a buffer on the heap with the given length. This is sufficient for
the active reproducer use case, where we only care about the side
effects of the API calls, not the values actually returned.
This approach does not not work for passive replay because here we
ignore all the incoming arguments, and re-execute the current function
with the arguments deserialized from the reproducer. This means that
these function will update the deserialized copy of the arguments,
rather than whatever was passed in by the SWIG wrapper.
To solve this problem, this patch extends the reproducer instrumentation
to handle this special case for passive replay. We nog ignore the
replayer in the registry and the incoming char pointer, and instead
reinvoke the current method on the deserialized class, and populate the
output argument.
Differential revision: https://reviews.llvm.org/D77759
2020-04-21 04:20:24 +08:00
|
|
|
LLDB_REGISTER_CHAR_PTR_METHOD_STATIC(bool, SBDebugger,
|
|
|
|
GetDefaultArchitecture);
|
2020-02-06 11:41:09 +08:00
|
|
|
|
2019-03-20 01:13:13 +08:00
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBDebugger, ());
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &));
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBDebugger &,
|
|
|
|
SBDebugger, operator=,(const lldb::SBDebugger &));
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Initialize, ());
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(lldb::SBError, SBDebugger,
|
|
|
|
InitializeWithErrorHandling, ());
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Terminate, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, Clear, ());
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, ());
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, (bool));
|
2021-03-02 07:26:35 +08:00
|
|
|
LLDB_REGISTER_STATIC_METHOD(
|
|
|
|
const char *, SBDebugger, GetProgressFromEvent,
|
|
|
|
(const lldb::SBEvent &, uint64_t &, uint64_t &, uint64_t &, bool &));
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, GetBroadcasterClass,
|
|
|
|
());
|
|
|
|
LLDB_REGISTER_METHOD(SBBroadcaster, SBDebugger, GetBroadcaster, ());
|
2019-09-12 07:27:09 +08:00
|
|
|
LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Destroy, (lldb::SBDebugger &));
|
2019-03-20 01:13:13 +08:00
|
|
|
LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, MemoryPressureDetected, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, IsValid, ());
|
2019-09-12 07:27:09 +08:00
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, operator bool,());
|
2019-03-20 01:13:13 +08:00
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, SetAsync, (bool));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBDebugger, GetAsync, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, SkipLLDBInitFiles, (bool));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, SkipAppInitFiles, (bool));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, SetInputFileHandle, (FILE *, bool));
|
|
|
|
LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetInputFileHandle, ());
|
|
|
|
LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetOutputFileHandle, ());
|
|
|
|
LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetErrorFileHandle, ());
|
2019-10-03 12:04:48 +08:00
|
|
|
LLDB_REGISTER_METHOD(SBFile, SBDebugger, GetInputFile, ());
|
|
|
|
LLDB_REGISTER_METHOD(SBFile, SBDebugger, GetOutputFile, ());
|
|
|
|
LLDB_REGISTER_METHOD(SBFile, SBDebugger, GetErrorFile, ());
|
2019-03-20 01:13:13 +08:00
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, SaveInputTerminalState, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, RestoreInputTerminalState, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBCommandInterpreter, SBDebugger,
|
|
|
|
GetCommandInterpreter, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, HandleCommand, (const char *));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBListener, SBDebugger, GetListener, ());
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
void, SBDebugger, HandleProcessEvent,
|
|
|
|
(const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *));
|
2019-10-15 04:15:28 +08:00
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
void, SBDebugger, HandleProcessEvent,
|
|
|
|
(const lldb::SBProcess &, const lldb::SBEvent &, SBFile, SBFile));
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
void, SBDebugger, HandleProcessEvent,
|
|
|
|
(const lldb::SBProcess &, const lldb::SBEvent &, FileSP, FileSP));
|
2019-09-12 07:27:09 +08:00
|
|
|
LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBDebugger, GetSourceManager, ());
|
2019-03-20 01:13:13 +08:00
|
|
|
LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, SetDefaultArchitecture,
|
|
|
|
(const char *));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::ScriptLanguage, SBDebugger, GetScriptingLanguage,
|
|
|
|
(const char *));
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, GetVersionString, ());
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, StateAsCString,
|
|
|
|
(lldb::StateType));
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(lldb::SBStructuredData, SBDebugger,
|
|
|
|
GetBuildConfiguration, ());
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, StateIsRunningState,
|
|
|
|
(lldb::StateType));
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, StateIsStoppedState,
|
|
|
|
(lldb::StateType));
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
lldb::SBTarget, SBDebugger, CreateTarget,
|
|
|
|
(const char *, const char *, const char *, bool, lldb::SBError &));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger,
|
|
|
|
CreateTargetWithFileAndTargetTriple,
|
|
|
|
(const char *, const char *));
|
2019-09-12 07:27:09 +08:00
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, CreateTargetWithFileAndArch,
|
2019-03-20 01:13:13 +08:00
|
|
|
(const char *, const char *));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, CreateTarget,
|
|
|
|
(const char *));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetDummyTarget, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBDebugger, DeleteTarget, (lldb::SBTarget &));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetTargetAtIndex,
|
|
|
|
(uint32_t));
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetIndexOfTarget,
|
|
|
|
(lldb::SBTarget));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithProcessID,
|
|
|
|
(lldb::pid_t));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithFileAndArch,
|
|
|
|
(const char *, const char *));
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumTargets, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetSelectedTarget, ());
|
2019-09-12 07:27:09 +08:00
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedTarget, (lldb::SBTarget &));
|
2019-03-20 01:13:13 +08:00
|
|
|
LLDB_REGISTER_METHOD(lldb::SBPlatform, SBDebugger, GetSelectedPlatform, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedPlatform,
|
|
|
|
(lldb::SBPlatform &));
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumPlatforms, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBPlatform, SBDebugger, GetPlatformAtIndex,
|
|
|
|
(uint32_t));
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumAvailablePlatforms, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBDebugger,
|
|
|
|
GetAvailablePlatformInfoAtIndex, (uint32_t));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, DispatchInputInterrupt, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, DispatchInputEndOfFile, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, PushInputReader,
|
|
|
|
(lldb::SBInputReader &));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, RunCommandInterpreter, (bool, bool));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, RunCommandInterpreter,
|
|
|
|
(bool, bool, lldb::SBCommandInterpreterRunOptions &,
|
|
|
|
int &, bool &, bool &));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBDebugger, RunREPL,
|
|
|
|
(lldb::LanguageType, const char *));
|
2019-09-12 07:27:09 +08:00
|
|
|
LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, FindDebuggerWithID,
|
|
|
|
(int));
|
2019-03-20 01:13:13 +08:00
|
|
|
LLDB_REGISTER_METHOD(const char *, SBDebugger, GetInstanceName, ());
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(lldb::SBError, SBDebugger, SetInternalVariable,
|
|
|
|
(const char *, const char *, const char *));
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(lldb::SBStringList, SBDebugger,
|
|
|
|
GetInternalVariableValue,
|
|
|
|
(const char *, const char *));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(uint32_t, SBDebugger, GetTerminalWidth, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, SetTerminalWidth, (uint32_t));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(const char *, SBDebugger, GetPrompt, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, SetPrompt, (const char *));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(const char *, SBDebugger, GetReproducerPath, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::ScriptLanguage, SBDebugger,
|
|
|
|
GetScriptLanguage, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, SetScriptLanguage,
|
|
|
|
(lldb::ScriptLanguage));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBDebugger, SetUseExternalEditor, (bool));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBDebugger, GetUseExternalEditor, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBDebugger, SetUseColor, (bool));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, GetUseColor, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::user_id_t, SBDebugger, GetID, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBDebugger, SetCurrentPlatform,
|
|
|
|
(const char *));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBDebugger, SetCurrentPlatformSDKRoot,
|
|
|
|
(const char *));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, GetCloseInputOnEOF, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBDebugger, SetCloseInputOnEOF, (bool));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory,
|
|
|
|
(const char *));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory,
|
|
|
|
(lldb::LanguageType));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, CreateCategory,
|
|
|
|
(const char *));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBDebugger, DeleteCategory, (const char *));
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumCategories, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategoryAtIndex,
|
|
|
|
(uint32_t));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetDefaultCategory,
|
|
|
|
());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBDebugger, GetFormatForType,
|
|
|
|
(lldb::SBTypeNameSpecifier));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBDebugger, GetSummaryForType,
|
|
|
|
(lldb::SBTypeNameSpecifier));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBDebugger, GetSyntheticForType,
|
|
|
|
(lldb::SBTypeNameSpecifier));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBDebugger, GetFilterForType,
|
|
|
|
(lldb::SBTypeNameSpecifier));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBDebugger, EnableLog,
|
|
|
|
(const char *, const char **));
|
2020-05-02 04:23:51 +08:00
|
|
|
LLDB_REGISTER_METHOD(lldb::SBCommandInterpreterRunResult, SBDebugger,
|
|
|
|
RunCommandInterpreter,
|
|
|
|
(const lldb::SBCommandInterpreterRunOptions &));
|
2019-03-20 01:13:13 +08:00
|
|
|
}
|
|
|
|
|
2019-09-12 07:27:09 +08:00
|
|
|
} // namespace repro
|
|
|
|
} // namespace lldb_private
|