aboutsummaryrefslogtreecommitdiffstats
path: root/source/API
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-10-23 17:53:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-10-23 17:53:01 +0000
commitead246455adf1a215ec2715dad6533073a6beb4e (patch)
treef3f97a47d77053bf96fe74cdbd6fae74380e8a92 /source/API
parentfdb00c4408990a0a63ef7f496d809ce59f263bc5 (diff)
downloadsrc-vendor/lldb.tar.gz
src-vendor/lldb.zip
Vendor import of stripped lldb trunk r375505, the last commit before thevendor/lldb/lldb-trunk-r375505vendor/lldb
upstream Subversion repository was made read-only, and the LLVM project migrated to GitHub: https://llvm.org/svn/llvm-project/lldb/trunk@375505
Notes
Notes: svn path=/vendor/lldb/dist/; revision=353952 svn path=/vendor/lldb/lldb-r375505/; revision=353953; tag=vendor/lldb/lldb-trunk-r375505
Diffstat (limited to 'source/API')
-rw-r--r--source/API/SBAddress.cpp8
-rw-r--r--source/API/SBBreakpointOptionCommon.cpp2
-rw-r--r--source/API/SBCommandInterpreter.cpp57
-rw-r--r--source/API/SBCommandReturnObject.cpp304
-rw-r--r--source/API/SBCompileUnit.cpp9
-rw-r--r--source/API/SBDebugger.cpp432
-rw-r--r--source/API/SBDeclaration.cpp2
-rw-r--r--source/API/SBFile.cpp129
-rw-r--r--source/API/SBFrame.cpp10
-rw-r--r--source/API/SBInstruction.cpp22
-rw-r--r--source/API/SBInstructionList.cpp32
-rw-r--r--source/API/SBLineEntry.cpp4
-rw-r--r--source/API/SBModule.cpp101
-rw-r--r--source/API/SBProcess.cpp34
-rw-r--r--source/API/SBReproducer.cpp1
-rw-r--r--source/API/SBReproducerPrivate.h2
-rw-r--r--source/API/SBStream.cpp73
-rw-r--r--source/API/SBStringList.cpp2
-rw-r--r--source/API/SBSymbolContext.cpp4
-rw-r--r--source/API/SBTarget.cpp103
-rw-r--r--source/API/SBThread.cpp25
-rw-r--r--source/API/SBThreadPlan.cpp51
-rw-r--r--source/API/SBType.cpp2
-rw-r--r--source/API/SBTypeCategory.cpp16
-rw-r--r--source/API/SystemInitializerFull.cpp67
-rw-r--r--source/API/Utils.h2
26 files changed, 952 insertions, 542 deletions
diff --git a/source/API/SBAddress.cpp b/source/API/SBAddress.cpp
index 358cb400a76c..dcde25b77917 100644
--- a/source/API/SBAddress.cpp
+++ b/source/API/SBAddress.cpp
@@ -28,7 +28,7 @@ SBAddress::SBAddress() : m_opaque_up(new Address()) {
SBAddress::SBAddress(const Address *lldb_object_ptr)
: m_opaque_up(new Address()) {
if (lldb_object_ptr)
- m_opaque_up = llvm::make_unique<Address>(*lldb_object_ptr);
+ m_opaque_up = std::make_unique<Address>(*lldb_object_ptr);
}
SBAddress::SBAddress(const SBAddress &rhs) : m_opaque_up(new Address()) {
@@ -210,12 +210,6 @@ bool SBAddress::GetDescription(SBStream &description) {
if (m_opaque_up->IsValid()) {
m_opaque_up->Dump(&strm, nullptr, Address::DumpStyleResolvedDescription,
Address::DumpStyleModuleWithFileAddress, 4);
- StreamString sstrm;
- // m_opaque_up->Dump (&sstrm, NULL,
- // Address::DumpStyleResolvedDescription, Address::DumpStyleInvalid,
- // 4);
- // if (sstrm.GetData())
- // strm.Printf (" (%s)", sstrm.GetData());
} else
strm.PutCString("No value");
diff --git a/source/API/SBBreakpointOptionCommon.cpp b/source/API/SBBreakpointOptionCommon.cpp
index 058b3e0398cd..870b4b941ada 100644
--- a/source/API/SBBreakpointOptionCommon.cpp
+++ b/source/API/SBBreakpointOptionCommon.cpp
@@ -41,7 +41,7 @@ using namespace lldb_private;
SBBreakpointCallbackBaton::SBBreakpointCallbackBaton(SBBreakpointHitCallback
callback,
void *baton)
- : TypedBaton(llvm::make_unique<CallbackData>()) {
+ : TypedBaton(std::make_unique<CallbackData>()) {
getItem()->callback = callback;
getItem()->callback_baton = baton;
}
diff --git a/source/API/SBCommandInterpreter.cpp b/source/API/SBCommandInterpreter.cpp
index c07dffce0baa..6e5ebe6a7ded 100644
--- a/source/API/SBCommandInterpreter.cpp
+++ b/source/API/SBCommandInterpreter.cpp
@@ -162,12 +162,11 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- SBCommandReturnObject sb_return(&result);
+ SBCommandReturnObject sb_return(result);
SBCommandInterpreter sb_interpreter(&m_interpreter);
SBDebugger debugger_sb(m_interpreter.GetDebugger().shared_from_this());
bool ret = m_backend->DoExecute(
debugger_sb, (char **)command.GetArgumentVector(), sb_return);
- sb_return.Release();
return ret;
}
std::shared_ptr<lldb::SBCommandPluginInterface> m_backend;
@@ -353,8 +352,6 @@ int SBCommandInterpreter::HandleCompletionWithDescriptions(
current_line, cursor, last_char, match_start_point,
max_return_elements, matches, descriptions);
- int num_completions = 0;
-
// Sanity check the arguments that are passed in: cursor & last_char have to
// be within the current_line.
if (current_line == nullptr || cursor == nullptr || last_char == nullptr)
@@ -368,20 +365,50 @@ int SBCommandInterpreter::HandleCompletionWithDescriptions(
last_char - current_line > static_cast<ptrdiff_t>(current_line_size))
return 0;
+ if (!IsValid())
+ return 0;
- if (IsValid()) {
- lldb_private::StringList lldb_matches, lldb_descriptions;
- num_completions = m_opaque_ptr->HandleCompletion(
- current_line, cursor, last_char, match_start_point, max_return_elements,
- lldb_matches, lldb_descriptions);
-
- SBStringList temp_matches_list(&lldb_matches);
- matches.AppendList(temp_matches_list);
- SBStringList temp_descriptions_list(&lldb_descriptions);
- descriptions.AppendList(temp_descriptions_list);
+ lldb_private::StringList lldb_matches, lldb_descriptions;
+ CompletionResult result;
+ CompletionRequest request(current_line, cursor - current_line, result);
+ m_opaque_ptr->HandleCompletion(request);
+ result.GetMatches(lldb_matches);
+ result.GetDescriptions(lldb_descriptions);
+
+ // Make the result array indexed from 1 again by adding the 'common prefix'
+ // of all completions as element 0. This is done to emulate the old API.
+ if (request.GetParsedLine().GetArgumentCount() == 0) {
+ // If we got an empty string, insert nothing.
+ lldb_matches.InsertStringAtIndex(0, "");
+ lldb_descriptions.InsertStringAtIndex(0, "");
+ } else {
+ // Now figure out if there is a common substring, and if so put that in
+ // element 0, otherwise put an empty string in element 0.
+ std::string command_partial_str = request.GetCursorArgumentPrefix().str();
+
+ std::string common_prefix = lldb_matches.LongestCommonPrefix();
+ const size_t partial_name_len = command_partial_str.size();
+ common_prefix.erase(0, partial_name_len);
+
+ // If we matched a unique single command, add a space... Only do this if
+ // the completer told us this was a complete word, however...
+ if (lldb_matches.GetSize() == 1) {
+ char quote_char = request.GetParsedArg().GetQuoteChar();
+ common_prefix =
+ Args::EscapeLLDBCommandArgument(common_prefix, quote_char);
+ if (request.GetParsedArg().IsQuoted())
+ common_prefix.push_back(quote_char);
+ common_prefix.push_back(' ');
+ }
+ lldb_matches.InsertStringAtIndex(0, common_prefix.c_str());
+ lldb_descriptions.InsertStringAtIndex(0, "");
}
- return num_completions;
+ SBStringList temp_matches_list(&lldb_matches);
+ matches.AppendList(temp_matches_list);
+ SBStringList temp_descriptions_list(&lldb_descriptions);
+ descriptions.AppendList(temp_descriptions_list);
+ return result.GetNumberOfResults();
}
int SBCommandInterpreter::HandleCompletionWithDescriptions(
diff --git a/source/API/SBCommandReturnObject.cpp b/source/API/SBCommandReturnObject.cpp
index 94e89916f7f6..eec1383df875 100644
--- a/source/API/SBCommandReturnObject.cpp
+++ b/source/API/SBCommandReturnObject.cpp
@@ -10,6 +10,7 @@
#include "SBReproducerPrivate.h"
#include "Utils.h"
#include "lldb/API/SBError.h"
+#include "lldb/API/SBFile.h"
#include "lldb/API/SBStream.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Utility/ConstString.h"
@@ -18,11 +19,43 @@
using namespace lldb;
using namespace lldb_private;
+class lldb_private::SBCommandReturnObjectImpl {
+public:
+ SBCommandReturnObjectImpl()
+ : m_ptr(new CommandReturnObject()), m_owned(true) {}
+ SBCommandReturnObjectImpl(CommandReturnObject &ref)
+ : m_ptr(&ref), m_owned(false) {}
+ SBCommandReturnObjectImpl(const SBCommandReturnObjectImpl &rhs)
+ : m_ptr(new CommandReturnObject(*rhs.m_ptr)), m_owned(rhs.m_owned) {}
+ SBCommandReturnObjectImpl &operator=(const SBCommandReturnObjectImpl &rhs) {
+ SBCommandReturnObjectImpl copy(rhs);
+ std::swap(*this, copy);
+ return *this;
+ }
+ // rvalue ctor+assignment are not used by SBCommandReturnObject.
+ ~SBCommandReturnObjectImpl() {
+ if (m_owned)
+ delete m_ptr;
+ }
+
+ CommandReturnObject &operator*() const { return *m_ptr; }
+
+private:
+ CommandReturnObject *m_ptr;
+ bool m_owned;
+};
+
SBCommandReturnObject::SBCommandReturnObject()
- : m_opaque_up(new CommandReturnObject()) {
+ : m_opaque_up(new SBCommandReturnObjectImpl()) {
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandReturnObject);
}
+SBCommandReturnObject::SBCommandReturnObject(CommandReturnObject &ref)
+ : m_opaque_up(new SBCommandReturnObjectImpl(ref)) {
+ LLDB_RECORD_CONSTRUCTOR(SBCommandReturnObject,
+ (lldb_private::CommandReturnObject &), ref);
+}
+
SBCommandReturnObject::SBCommandReturnObject(const SBCommandReturnObject &rhs)
: m_opaque_up() {
LLDB_RECORD_CONSTRUCTOR(SBCommandReturnObject,
@@ -31,25 +64,10 @@ SBCommandReturnObject::SBCommandReturnObject(const SBCommandReturnObject &rhs)
m_opaque_up = clone(rhs.m_opaque_up);
}
-SBCommandReturnObject::SBCommandReturnObject(CommandReturnObject *ptr)
- : m_opaque_up(ptr) {
- LLDB_RECORD_CONSTRUCTOR(SBCommandReturnObject,
- (lldb_private::CommandReturnObject *), ptr);
-}
-
-SBCommandReturnObject::~SBCommandReturnObject() = default;
-
-CommandReturnObject *SBCommandReturnObject::Release() {
- LLDB_RECORD_METHOD_NO_ARGS(lldb_private::CommandReturnObject *,
- SBCommandReturnObject, Release);
-
- return LLDB_RECORD_RESULT(m_opaque_up.release());
-}
-
-const SBCommandReturnObject &SBCommandReturnObject::
+SBCommandReturnObject &SBCommandReturnObject::
operator=(const SBCommandReturnObject &rhs) {
LLDB_RECORD_METHOD(
- const lldb::SBCommandReturnObject &,
+ lldb::SBCommandReturnObject &,
SBCommandReturnObject, operator=,(const lldb::SBCommandReturnObject &),
rhs);
@@ -58,6 +76,8 @@ operator=(const SBCommandReturnObject &rhs) {
return LLDB_RECORD_RESULT(*this);
}
+SBCommandReturnObject::~SBCommandReturnObject() = default;
+
bool SBCommandReturnObject::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandReturnObject, IsValid);
return this->operator bool();
@@ -65,49 +85,38 @@ bool SBCommandReturnObject::IsValid() const {
SBCommandReturnObject::operator bool() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandReturnObject, operator bool);
- return m_opaque_up != nullptr;
+ // This method is not useful but it needs to stay to keep SB API stable.
+ return true;
}
const char *SBCommandReturnObject::GetOutput() {
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommandReturnObject, GetOutput);
- if (m_opaque_up) {
- llvm::StringRef output = m_opaque_up->GetOutputData();
- ConstString result(output.empty() ? llvm::StringRef("") : output);
-
- return result.AsCString();
- }
-
- return nullptr;
+ ConstString output(ref().GetOutputData());
+ return output.AsCString(/*value_if_empty*/ "");
}
const char *SBCommandReturnObject::GetError() {
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommandReturnObject, GetError);
- if (m_opaque_up) {
- llvm::StringRef output = m_opaque_up->GetErrorData();
- ConstString result(output.empty() ? llvm::StringRef("") : output);
- return result.AsCString();
- }
-
- return nullptr;
+ ConstString output(ref().GetErrorData());
+ return output.AsCString(/*value_if_empty*/ "");
}
size_t SBCommandReturnObject::GetOutputSize() {
LLDB_RECORD_METHOD_NO_ARGS(size_t, SBCommandReturnObject, GetOutputSize);
- return (m_opaque_up ? m_opaque_up->GetOutputData().size() : 0);
+ return ref().GetOutputData().size();
}
size_t SBCommandReturnObject::GetErrorSize() {
LLDB_RECORD_METHOD_NO_ARGS(size_t, SBCommandReturnObject, GetErrorSize);
- return (m_opaque_up ? m_opaque_up->GetErrorData().size() : 0);
+ return ref().GetErrorData().size();
}
size_t SBCommandReturnObject::PutOutput(FILE *fh) {
- LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutOutput, (FILE *), fh);
-
+ LLDB_RECORD_DUMMY(size_t, SBCommandReturnObject, PutOutput, (FILE *), fh);
if (fh) {
size_t num_bytes = GetOutputSize();
if (num_bytes)
@@ -116,9 +125,23 @@ size_t SBCommandReturnObject::PutOutput(FILE *fh) {
return 0;
}
-size_t SBCommandReturnObject::PutError(FILE *fh) {
- LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutError, (FILE *), fh);
+size_t SBCommandReturnObject::PutOutput(FileSP file_sp) {
+ LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutOutput, (FileSP),
+ file_sp);
+ if (!file_sp)
+ return 0;
+ return file_sp->Printf("%s", GetOutput());
+}
+
+size_t SBCommandReturnObject::PutOutput(SBFile file) {
+ LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutOutput, (SBFile), file);
+ if (!file.m_opaque_sp)
+ return 0;
+ return file.m_opaque_sp->Printf("%s", GetOutput());
+}
+size_t SBCommandReturnObject::PutError(FILE *fh) {
+ LLDB_RECORD_DUMMY(size_t, SBCommandReturnObject, PutError, (FILE *), fh);
if (fh) {
size_t num_bytes = GetErrorSize();
if (num_bytes)
@@ -127,77 +150,81 @@ size_t SBCommandReturnObject::PutError(FILE *fh) {
return 0;
}
+size_t SBCommandReturnObject::PutError(FileSP file_sp) {
+ LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutError, (FileSP),
+ file_sp);
+ if (!file_sp)
+ return 0;
+ return file_sp->Printf("%s", GetError());
+}
+
+size_t SBCommandReturnObject::PutError(SBFile file) {
+ LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutError, (SBFile), file);
+ if (!file.m_opaque_sp)
+ return 0;
+ return file.m_opaque_sp->Printf("%s", GetError());
+}
+
void SBCommandReturnObject::Clear() {
LLDB_RECORD_METHOD_NO_ARGS(void, SBCommandReturnObject, Clear);
- if (m_opaque_up)
- m_opaque_up->Clear();
+ ref().Clear();
}
lldb::ReturnStatus SBCommandReturnObject::GetStatus() {
LLDB_RECORD_METHOD_NO_ARGS(lldb::ReturnStatus, SBCommandReturnObject,
GetStatus);
- return (m_opaque_up ? m_opaque_up->GetStatus() : lldb::eReturnStatusInvalid);
+ return ref().GetStatus();
}
void SBCommandReturnObject::SetStatus(lldb::ReturnStatus status) {
LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetStatus,
(lldb::ReturnStatus), status);
- if (m_opaque_up)
- m_opaque_up->SetStatus(status);
+ ref().SetStatus(status);
}
bool SBCommandReturnObject::Succeeded() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandReturnObject, Succeeded);
- return (m_opaque_up ? m_opaque_up->Succeeded() : false);
+ return ref().Succeeded();
}
bool SBCommandReturnObject::HasResult() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandReturnObject, HasResult);
- return (m_opaque_up ? m_opaque_up->HasResult() : false);
+ return ref().HasResult();
}
void SBCommandReturnObject::AppendMessage(const char *message) {
LLDB_RECORD_METHOD(void, SBCommandReturnObject, AppendMessage, (const char *),
message);
- if (m_opaque_up)
- m_opaque_up->AppendMessage(message);
+ ref().AppendMessage(message);
}
void SBCommandReturnObject::AppendWarning(const char *message) {
LLDB_RECORD_METHOD(void, SBCommandReturnObject, AppendWarning, (const char *),
message);
- if (m_opaque_up)
- m_opaque_up->AppendWarning(message);
+ ref().AppendWarning(message);
}
CommandReturnObject *SBCommandReturnObject::operator->() const {
- return m_opaque_up.get();
+ return &**m_opaque_up;
}
CommandReturnObject *SBCommandReturnObject::get() const {
- return m_opaque_up.get();
+ return &**m_opaque_up;
}
CommandReturnObject &SBCommandReturnObject::operator*() const {
- assert(m_opaque_up.get());
- return *(m_opaque_up.get());
+ return **m_opaque_up;
}
CommandReturnObject &SBCommandReturnObject::ref() const {
- assert(m_opaque_up.get());
- return *(m_opaque_up.get());
-}
-
-void SBCommandReturnObject::SetLLDBObjectPtr(CommandReturnObject *ptr) {
- if (m_opaque_up)
- m_opaque_up.reset(ptr);
+ return **m_opaque_up;
}
bool SBCommandReturnObject::GetDescription(SBStream &description) {
@@ -206,84 +233,99 @@ bool SBCommandReturnObject::GetDescription(SBStream &description) {
Stream &strm = description.ref();
- if (m_opaque_up) {
- description.Printf("Error: ");
- lldb::ReturnStatus status = m_opaque_up->GetStatus();
- if (status == lldb::eReturnStatusStarted)
- strm.PutCString("Started");
- else if (status == lldb::eReturnStatusInvalid)
- strm.PutCString("Invalid");
- else if (m_opaque_up->Succeeded())
- strm.PutCString("Success");
- else
- strm.PutCString("Fail");
-
- if (GetOutputSize() > 0)
- strm.Printf("\nOutput Message:\n%s", GetOutput());
-
- if (GetErrorSize() > 0)
- strm.Printf("\nError Message:\n%s", GetError());
- } else
- strm.PutCString("No value");
+ description.Printf("Error: ");
+ lldb::ReturnStatus status = ref().GetStatus();
+ if (status == lldb::eReturnStatusStarted)
+ strm.PutCString("Started");
+ else if (status == lldb::eReturnStatusInvalid)
+ strm.PutCString("Invalid");
+ else if (ref().Succeeded())
+ strm.PutCString("Success");
+ else
+ strm.PutCString("Fail");
+
+ if (GetOutputSize() > 0)
+ strm.Printf("\nOutput Message:\n%s", GetOutput());
+
+ if (GetErrorSize() > 0)
+ strm.Printf("\nError Message:\n%s", GetError());
return true;
}
void SBCommandReturnObject::SetImmediateOutputFile(FILE *fh) {
- LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
- (FILE *), fh);
+ LLDB_RECORD_DUMMY(void, SBCommandReturnObject, SetImmediateOutputFile,
+ (FILE *), fh);
SetImmediateOutputFile(fh, false);
}
void SBCommandReturnObject::SetImmediateErrorFile(FILE *fh) {
- LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
- (FILE *), fh);
+ LLDB_RECORD_DUMMY(void, SBCommandReturnObject, SetImmediateErrorFile,
+ (FILE *), fh);
SetImmediateErrorFile(fh, false);
}
void SBCommandReturnObject::SetImmediateOutputFile(FILE *fh,
bool transfer_ownership) {
- LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
- (FILE *, bool), fh, transfer_ownership);
-
- if (m_opaque_up)
- m_opaque_up->SetImmediateOutputFile(fh, transfer_ownership);
+ LLDB_RECORD_DUMMY(void, SBCommandReturnObject, SetImmediateOutputFile,
+ (FILE *, bool), fh, transfer_ownership);
+ FileSP file = std::make_shared<NativeFile>(fh, transfer_ownership);
+ ref().SetImmediateOutputFile(file);
}
void SBCommandReturnObject::SetImmediateErrorFile(FILE *fh,
bool transfer_ownership) {
+ LLDB_RECORD_DUMMY(void, SBCommandReturnObject, SetImmediateErrorFile,
+ (FILE *, bool), fh, transfer_ownership);
+ FileSP file = std::make_shared<NativeFile>(fh, transfer_ownership);
+ ref().SetImmediateErrorFile(file);
+}
+
+void SBCommandReturnObject::SetImmediateOutputFile(SBFile file) {
+ LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
+ (SBFile), file);
+ ref().SetImmediateOutputFile(file.m_opaque_sp);
+}
+
+void SBCommandReturnObject::SetImmediateErrorFile(SBFile file) {
LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
- (FILE *, bool), fh, transfer_ownership);
+ (SBFile), file);
+ ref().SetImmediateErrorFile(file.m_opaque_sp);
+}
- if (m_opaque_up)
- m_opaque_up->SetImmediateErrorFile(fh, transfer_ownership);
+void SBCommandReturnObject::SetImmediateOutputFile(FileSP file_sp) {
+ LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
+ (FileSP), file_sp);
+ SetImmediateOutputFile(SBFile(file_sp));
+}
+
+void SBCommandReturnObject::SetImmediateErrorFile(FileSP file_sp) {
+ LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
+ (FileSP), file_sp);
+ SetImmediateErrorFile(SBFile(file_sp));
}
void SBCommandReturnObject::PutCString(const char *string, int len) {
LLDB_RECORD_METHOD(void, SBCommandReturnObject, PutCString,
(const char *, int), string, len);
- if (m_opaque_up) {
- if (len == 0 || string == nullptr || *string == 0) {
- return;
- } else if (len > 0) {
- std::string buffer(string, len);
- m_opaque_up->AppendMessage(buffer.c_str());
- } else
- m_opaque_up->AppendMessage(string);
- }
+ if (len == 0 || string == nullptr || *string == 0) {
+ return;
+ } else if (len > 0) {
+ std::string buffer(string, len);
+ ref().AppendMessage(buffer.c_str());
+ } else
+ ref().AppendMessage(string);
}
const char *SBCommandReturnObject::GetOutput(bool only_if_no_immediate) {
LLDB_RECORD_METHOD(const char *, SBCommandReturnObject, GetOutput, (bool),
only_if_no_immediate);
- if (!m_opaque_up)
- return nullptr;
if (!only_if_no_immediate ||
- m_opaque_up->GetImmediateOutputStream().get() == nullptr)
+ ref().GetImmediateOutputStream().get() == nullptr)
return GetOutput();
return nullptr;
}
@@ -292,23 +334,17 @@ const char *SBCommandReturnObject::GetError(bool only_if_no_immediate) {
LLDB_RECORD_METHOD(const char *, SBCommandReturnObject, GetError, (bool),
only_if_no_immediate);
- if (!m_opaque_up)
- return nullptr;
- if (!only_if_no_immediate ||
- m_opaque_up->GetImmediateErrorStream().get() == nullptr)
+ if (!only_if_no_immediate || ref().GetImmediateErrorStream().get() == nullptr)
return GetError();
return nullptr;
}
size_t SBCommandReturnObject::Printf(const char *format, ...) {
- if (m_opaque_up) {
- va_list args;
- va_start(args, format);
- size_t result = m_opaque_up->GetOutputStream().PrintfVarArg(format, args);
- va_end(args);
- return result;
- }
- return 0;
+ va_list args;
+ va_start(args, format);
+ size_t result = ref().GetOutputStream().PrintfVarArg(format, args);
+ va_end(args);
+ return result;
}
void SBCommandReturnObject::SetError(lldb::SBError &error,
@@ -317,20 +353,18 @@ void SBCommandReturnObject::SetError(lldb::SBError &error,
(lldb::SBError &, const char *), error,
fallback_error_cstr);
- if (m_opaque_up) {
- if (error.IsValid())
- m_opaque_up->SetError(error.ref(), fallback_error_cstr);
- else if (fallback_error_cstr)
- m_opaque_up->SetError(Status(), fallback_error_cstr);
- }
+ if (error.IsValid())
+ ref().SetError(error.ref(), fallback_error_cstr);
+ else if (fallback_error_cstr)
+ ref().SetError(Status(), fallback_error_cstr);
}
void SBCommandReturnObject::SetError(const char *error_cstr) {
LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetError, (const char *),
error_cstr);
- if (m_opaque_up && error_cstr)
- m_opaque_up->SetError(error_cstr);
+ if (error_cstr)
+ ref().SetError(error_cstr);
}
namespace lldb_private {
@@ -340,13 +374,11 @@ template <>
void RegisterMethods<SBCommandReturnObject>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject, ());
LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject,
- (const lldb::SBCommandReturnObject &));
+ (lldb_private::CommandReturnObject &));
LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject,
- (lldb_private::CommandReturnObject *));
- LLDB_REGISTER_METHOD(lldb_private::CommandReturnObject *,
- SBCommandReturnObject, Release, ());
+ (const lldb::SBCommandReturnObject &));
LLDB_REGISTER_METHOD(
- const lldb::SBCommandReturnObject &,
+ lldb::SBCommandReturnObject &,
SBCommandReturnObject, operator=,(const lldb::SBCommandReturnObject &));
LLDB_REGISTER_METHOD_CONST(bool, SBCommandReturnObject, IsValid, ());
LLDB_REGISTER_METHOD_CONST(bool, SBCommandReturnObject, operator bool, ());
@@ -356,6 +388,10 @@ void RegisterMethods<SBCommandReturnObject>(Registry &R) {
LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, GetErrorSize, ());
LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutOutput, (FILE *));
LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutError, (FILE *));
+ LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutOutput, (SBFile));
+ LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutError, (SBFile));
+ LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutOutput, (FileSP));
+ LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutError, (FileSP));
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, Clear, ());
LLDB_REGISTER_METHOD(lldb::ReturnStatus, SBCommandReturnObject, GetStatus,
());
@@ -374,6 +410,14 @@ void RegisterMethods<SBCommandReturnObject>(Registry &R) {
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
(FILE *));
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
+ (SBFile));
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
+ (SBFile));
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
+ (FileSP));
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
+ (FileSP));
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
(FILE *, bool));
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
(FILE *, bool));
diff --git a/source/API/SBCompileUnit.cpp b/source/API/SBCompileUnit.cpp
index c9ca70645d95..581bda363507 100644
--- a/source/API/SBCompileUnit.cpp
+++ b/source/API/SBCompileUnit.cpp
@@ -14,8 +14,9 @@
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Symbol/LineTable.h"
-#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeList.h"
using namespace lldb;
using namespace lldb_private;
@@ -137,13 +138,13 @@ lldb::SBTypeList SBCompileUnit::GetTypes(uint32_t type_mask) {
if (!module_sp)
return LLDB_RECORD_RESULT(sb_type_list);
- SymbolVendor *vendor = module_sp->GetSymbolVendor();
- if (!vendor)
+ SymbolFile *symfile = module_sp->GetSymbolFile();
+ if (!symfile)
return LLDB_RECORD_RESULT(sb_type_list);
TypeClass type_class = static_cast<TypeClass>(type_mask);
TypeList type_list;
- vendor->GetTypes(m_opaque_ptr, type_class, type_list);
+ symfile->GetTypes(m_opaque_ptr, type_class, type_list);
sb_type_list.m_opaque_up->Append(type_list);
return LLDB_RECORD_RESULT(sb_type_list);
}
diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp
index 634c4a929595..82dc60489008 100644
--- a/source/API/SBDebugger.cpp
+++ b/source/API/SBDebugger.cpp
@@ -18,6 +18,7 @@
#include "lldb/API/SBCommandReturnObject.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBEvent.h"
+#include "lldb/API/SBFile.h"
#include "lldb/API/SBFrame.h"
#include "lldb/API/SBListener.h"
#include "lldb/API/SBProcess.h"
@@ -57,51 +58,6 @@
using namespace lldb;
using namespace lldb_private;
-/// Helper class for replaying commands through the reproducer.
-class CommandLoader {
-public:
- CommandLoader(std::vector<std::string> files) : m_files(files) {}
-
- static std::unique_ptr<CommandLoader> Create() {
- repro::Loader *loader = repro::Reproducer::Instance().GetLoader();
- if (!loader)
- return {};
-
- FileSpec file = loader->GetFile<repro::CommandProvider::Info>();
- if (!file)
- return {};
-
- auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath());
- if (auto err = error_or_file.getError())
- return {};
-
- std::vector<std::string> files;
- llvm::yaml::Input yin((*error_or_file)->getBuffer());
- yin >> files;
-
- if (auto err = yin.error())
- return {};
-
- for (auto &file : files) {
- FileSpec absolute_path =
- loader->GetRoot().CopyByAppendingPathComponent(file);
- file = absolute_path.GetPath();
- }
-
- return llvm::make_unique<CommandLoader>(std::move(files));
- }
-
- FILE *GetNextFile() {
- if (m_index >= m_files.size())
- return nullptr;
- return FileSystem::Instance().Fopen(m_files[m_index++].c_str(), "r");
- }
-
-private:
- std::vector<std::string> m_files;
- unsigned m_index = 0;
-};
-
static llvm::sys::DynamicLibrary LoadPlugin(const lldb::DebuggerSP &debugger_sp,
const FileSpec &spec,
Status &error) {
@@ -200,11 +156,9 @@ lldb::SBError SBDebugger::InitializeWithErrorHandling() {
LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBError, SBDebugger,
InitializeWithErrorHandling);
-
-
SBError error;
if (auto e = g_debugger_lifetime->Initialize(
- llvm::make_unique<SystemInitializerFull>(), LoadPlugin)) {
+ std::make_unique<SystemInitializerFull>(), LoadPlugin)) {
error.SetError(Status(std::move(e)));
}
return LLDB_RECORD_RESULT(error);
@@ -219,7 +173,6 @@ void SBDebugger::Terminate() {
void SBDebugger::Clear() {
LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, Clear);
-
if (m_opaque_sp)
m_opaque_sp->ClearIOHandlers();
@@ -260,7 +213,6 @@ SBDebugger SBDebugger::Create(bool source_init_files,
debugger.reset(Debugger::CreateInstance(callback, baton));
-
SBCommandInterpreter interp = debugger.GetCommandInterpreter();
if (source_init_files) {
interp.get()->SkipLLDBInitFiles(false);
@@ -278,7 +230,6 @@ void SBDebugger::Destroy(SBDebugger &debugger) {
LLDB_RECORD_STATIC_METHOD(void, SBDebugger, Destroy, (lldb::SBDebugger &),
debugger);
-
Debugger::Destroy(debugger.m_opaque_sp);
if (debugger.m_opaque_sp.get() != nullptr)
@@ -335,86 +286,173 @@ void SBDebugger::SkipAppInitFiles(bool b) {
m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles(b);
}
-// 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.
void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) {
LLDB_RECORD_METHOD(void, SBDebugger, SetInputFileHandle, (FILE *, bool), fh,
transfer_ownership);
+ SetInputFile((FileSP)std::make_shared<NativeFile>(fh, transfer_ownership));
+}
- if (!m_opaque_sp)
- return;
+SBError SBDebugger::SetInputFile(FileSP file_sp) {
+ LLDB_RECORD_METHOD(SBError, SBDebugger, SetInputFile, (FileSP), file_sp);
+ return SetInputFile(SBFile(file_sp));
+}
+
+// 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");
+ return error;
+ }
repro::DataRecorder *recorder = nullptr;
if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator())
recorder = g->GetOrCreate<repro::CommandProvider>().GetNewDataRecorder();
- static std::unique_ptr<CommandLoader> loader = CommandLoader::Create();
- if (loader)
- fh = loader->GetNextFile();
+ FileSP file_sp = file.m_opaque_sp;
+
+ static std::unique_ptr<repro::CommandLoader> loader =
+ repro::CommandLoader::Create(repro::Reproducer::Instance().GetLoader());
+ if (loader) {
+ 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) {
+ file_sp = std::make_shared<NativeFile>(fh, true);
+ }
+ }
+
+ if (!file_sp || !file_sp->IsValid()) {
+ error.ref().SetErrorString("invalid file");
+ return error;
+ }
+
+ m_opaque_sp->SetInputFile(file_sp, recorder);
+ return error;
+}
- m_opaque_sp->SetInputFileHandle(fh, transfer_ownership, recorder);
+SBError SBDebugger::SetOutputFile(FileSP file_sp) {
+ LLDB_RECORD_METHOD(SBError, SBDebugger, SetOutputFile, (FileSP), file_sp);
+ return SetOutputFile(SBFile(file_sp));
}
void SBDebugger::SetOutputFileHandle(FILE *fh, bool transfer_ownership) {
LLDB_RECORD_METHOD(void, SBDebugger, SetOutputFileHandle, (FILE *, bool), fh,
transfer_ownership);
+ SetOutputFile((FileSP)std::make_shared<NativeFile>(fh, transfer_ownership));
+}
- if (m_opaque_sp)
- m_opaque_sp->SetOutputFileHandle(fh, transfer_ownership);
+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");
+ return error;
+ }
+ if (!file) {
+ error.ref().SetErrorString("invalid file");
+ return error;
+ }
+ m_opaque_sp->SetOutputFile(file.m_opaque_sp);
+ return error;
}
void SBDebugger::SetErrorFileHandle(FILE *fh, bool transfer_ownership) {
LLDB_RECORD_METHOD(void, SBDebugger, SetErrorFileHandle, (FILE *, bool), fh,
transfer_ownership);
+ SetErrorFile((FileSP)std::make_shared<NativeFile>(fh, transfer_ownership));
+}
+SBError SBDebugger::SetErrorFile(FileSP file_sp) {
+ LLDB_RECORD_METHOD(SBError, SBDebugger, SetErrorFile, (FileSP), file_sp);
+ return SetErrorFile(SBFile(file_sp));
+}
- if (m_opaque_sp)
- m_opaque_sp->SetErrorFileHandle(fh, transfer_ownership);
+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");
+ return error;
+ }
+ if (!file) {
+ error.ref().SetErrorString("invalid file");
+ return error;
+ }
+ m_opaque_sp->SetErrorFile(file.m_opaque_sp);
+ return error;
}
FILE *SBDebugger::GetInputFileHandle() {
LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetInputFileHandle);
-
if (m_opaque_sp) {
- StreamFileSP stream_file_sp(m_opaque_sp->GetInputFile());
- if (stream_file_sp)
- return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream());
+ File &file_sp = m_opaque_sp->GetInputFile();
+ return LLDB_RECORD_RESULT(file_sp.GetStream());
}
return nullptr;
}
+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());
+}
+
FILE *SBDebugger::GetOutputFileHandle() {
LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetOutputFileHandle);
-
if (m_opaque_sp) {
- StreamFileSP stream_file_sp(m_opaque_sp->GetOutputFile());
- if (stream_file_sp)
- return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream());
+ StreamFile &stream_file = m_opaque_sp->GetOutputStream();
+ return LLDB_RECORD_RESULT(stream_file.GetFile().GetStream());
}
return nullptr;
}
+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());
+}
+
FILE *SBDebugger::GetErrorFileHandle() {
LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetErrorFileHandle);
if (m_opaque_sp) {
- StreamFileSP stream_file_sp(m_opaque_sp->GetErrorFile());
- if (stream_file_sp)
- return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream());
+ StreamFile &stream_file = m_opaque_sp->GetErrorStream();
+ return LLDB_RECORD_RESULT(stream_file.GetFile().GetStream());
}
return nullptr;
}
+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());
+}
+
void SBDebugger::SaveInputTerminalState() {
- LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, SaveInputTerminalState);
+ LLDB_RECORD_DUMMY_NO_ARGS(void, SBDebugger, SaveInputTerminalState);
if (m_opaque_sp)
m_opaque_sp->SaveInputTerminalState();
}
void SBDebugger::RestoreInputTerminalState() {
- LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, RestoreInputTerminalState);
+ LLDB_RECORD_DUMMY_NO_ARGS(void, SBDebugger, RestoreInputTerminalState);
if (m_opaque_sp)
m_opaque_sp->RestoreInputTerminalState();
@@ -423,12 +461,10 @@ SBCommandInterpreter SBDebugger::GetCommandInterpreter() {
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCommandInterpreter, SBDebugger,
GetCommandInterpreter);
-
SBCommandInterpreter sb_interpreter;
if (m_opaque_sp)
sb_interpreter.reset(&m_opaque_sp->GetCommandInterpreter());
-
return LLDB_RECORD_RESULT(sb_interpreter);
}
@@ -446,10 +482,8 @@ void SBDebugger::HandleCommand(const char *command) {
sb_interpreter.HandleCommand(command, result, false);
- if (GetErrorFileHandle() != nullptr)
- result.PutError(GetErrorFileHandle());
- if (GetOutputFileHandle() != nullptr)
- result.PutOutput(GetOutputFileHandle());
+ result.PutError(m_opaque_sp->GetErrorStream().GetFileSP());
+ result.PutOutput(m_opaque_sp->GetOutputStream().GetFileSP());
if (!m_opaque_sp->GetAsyncExecution()) {
SBProcess process(GetCommandInterpreter().GetProcess());
@@ -460,8 +494,7 @@ void SBDebugger::HandleCommand(const char *command) {
while (lldb_listener_sp->GetEventForBroadcaster(
process_sp.get(), event_sp, std::chrono::seconds(0))) {
SBEvent event(event_sp);
- HandleProcessEvent(process, event, GetOutputFileHandle(),
- GetErrorFileHandle());
+ HandleProcessEvent(process, event, GetOutputFile(), GetErrorFile());
}
}
}
@@ -471,16 +504,25 @@ void SBDebugger::HandleCommand(const char *command) {
SBListener SBDebugger::GetListener() {
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBListener, SBDebugger, GetListener);
-
SBListener sb_listener;
if (m_opaque_sp)
sb_listener.reset(m_opaque_sp->GetListener());
-
return LLDB_RECORD_RESULT(sb_listener);
}
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);
+}
+
+void SBDebugger::HandleProcessEvent(const SBProcess &process,
const SBEvent &event, FILE *out,
FILE *err) {
LLDB_RECORD_METHOD(
@@ -488,6 +530,20 @@ void SBDebugger::HandleProcessEvent(const SBProcess &process,
(const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *), process,
event, out, err);
+ 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);
+
if (!process.IsValid())
return;
@@ -505,16 +561,16 @@ void SBDebugger::HandleProcessEvent(const SBProcess &process,
(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)
- if (out != nullptr)
- ::fwrite(stdio_buffer, 1, len, out);
+ if (out_sp)
+ out_sp->Write(stdio_buffer, len);
}
if (event_type &
(Process::eBroadcastBitSTDERR | Process::eBroadcastBitStateChanged)) {
// Drain stderr when we stop just in case we have any bytes
while ((len = process.GetSTDERR(stdio_buffer, sizeof(stdio_buffer))) > 0)
- if (err != nullptr)
- ::fwrite(stdio_buffer, 1, len, err);
+ if (err_sp)
+ err_sp->Write(stdio_buffer, len);
}
if (event_type & Process::eBroadcastBitStateChanged) {
@@ -525,7 +581,7 @@ void SBDebugger::HandleProcessEvent(const SBProcess &process,
bool is_stopped = StateIsStoppedState(event_state);
if (!is_stopped)
- process.ReportEventState(event, out);
+ process.ReportEventState(event, out_sp);
}
}
@@ -578,7 +634,8 @@ SBDebugger::GetScriptingLanguage(const char *script_language_name) {
LLDB_RECORD_METHOD(lldb::ScriptLanguage, SBDebugger, GetScriptingLanguage,
(const char *), script_language_name);
- if (!script_language_name) return eScriptLanguageDefault;
+ if (!script_language_name)
+ return eScriptLanguageDefault;
return OptionArgParser::ToScriptLanguage(
llvm::StringRef(script_language_name), eScriptLanguageDefault, nullptr);
}
@@ -599,18 +656,18 @@ const char *SBDebugger::StateAsCString(StateType state) {
static void AddBoolConfigEntry(StructuredData::Dictionary &dict,
llvm::StringRef name, bool value,
llvm::StringRef description) {
- auto entry_up = llvm::make_unique<StructuredData::Dictionary>();
+ auto entry_up = std::make_unique<StructuredData::Dictionary>();
entry_up->AddBooleanItem("value", value);
entry_up->AddStringItem("description", description);
dict.AddItem(name, std::move(entry_up));
}
static void AddLLVMTargets(StructuredData::Dictionary &dict) {
- auto array_up = llvm::make_unique<StructuredData::Array>();
+ auto array_up = std::make_unique<StructuredData::Array>();
#define LLVM_TARGET(target) \
- array_up->AddItem(llvm::make_unique<StructuredData::String>(#target));
+ array_up->AddItem(std::make_unique<StructuredData::String>(#target));
#include "llvm/Config/Targets.def"
- auto entry_up = llvm::make_unique<StructuredData::Dictionary>();
+ auto entry_up = std::make_unique<StructuredData::Dictionary>();
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));
@@ -620,10 +677,17 @@ SBStructuredData SBDebugger::GetBuildConfiguration() {
LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBStructuredData, SBDebugger,
GetBuildConfiguration);
- auto config_up = llvm::make_unique<StructuredData::Dictionary>();
+ auto config_up = std::make_unique<StructuredData::Dictionary>();
AddBoolConfigEntry(
*config_up, "xml", XMLDocument::XMLEnabled(),
"A boolean value that indicates if XML support is enabled in LLDB");
+ bool have_curses = true;
+#ifdef LLDB_DISABLE_CURSES
+ have_curses = false;
+#endif
+ AddBoolConfigEntry(
+ *config_up, "curses", have_curses,
+ "A boolean value that indicates if curses support is enabled in LLDB");
AddLLVMTargets(*config_up);
SBStructuredData data;
@@ -635,7 +699,6 @@ bool SBDebugger::StateIsRunningState(StateType state) {
LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, StateIsRunningState,
(lldb::StateType), state);
-
const bool result = lldb_private::StateIsRunningState(state);
return result;
@@ -645,7 +708,6 @@ bool SBDebugger::StateIsStoppedState(StateType state) {
LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, StateIsStoppedState,
(lldb::StateType), state);
-
const bool result = lldb_private::StateIsStoppedState(state, false);
return result;
@@ -680,13 +742,13 @@ lldb::SBTarget SBDebugger::CreateTarget(const char *filename,
}
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("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()));
+ 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()));
return LLDB_RECORD_RESULT(sb_target);
}
@@ -710,11 +772,11 @@ SBDebugger::CreateTargetWithFileAndTargetTriple(const char *filename,
}
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("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()));
+ 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()));
return LLDB_RECORD_RESULT(sb_target);
}
@@ -743,11 +805,11 @@ SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename,
}
}
- if (log)
- log->Printf("SBDebugger(%p)::CreateTargetWithFileAndArch (filename=\"%s\", "
- "arch=%s) => SBTarget(%p)",
- static_cast<void *>(m_opaque_sp.get()), filename, arch_cstr,
- static_cast<void *>(target_sp.get()));
+ LLDB_LOGF(log,
+ "SBDebugger(%p)::CreateTargetWithFileAndArch (filename=\"%s\", "
+ "arch=%s) => SBTarget(%p)",
+ static_cast<void *>(m_opaque_sp.get()), filename, arch_cstr,
+ static_cast<void *>(target_sp.get()));
return LLDB_RECORD_RESULT(sb_target);
}
@@ -772,11 +834,10 @@ SBTarget SBDebugger::CreateTarget(const char *filename) {
}
}
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf(
- "SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)",
- static_cast<void *>(m_opaque_sp.get()), filename,
- static_cast<void *>(target_sp.get()));
+ LLDB_LOGF(log,
+ "SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)",
+ static_cast<void *>(m_opaque_sp.get()), filename,
+ static_cast<void *>(target_sp.get()));
return LLDB_RECORD_RESULT(sb_target);
}
@@ -785,14 +846,12 @@ SBTarget SBDebugger::GetDummyTarget() {
SBTarget sb_target;
if (m_opaque_sp) {
- sb_target.SetSP(m_opaque_sp->GetDummyTarget()->shared_from_this());
+ sb_target.SetSP(m_opaque_sp->GetDummyTarget()->shared_from_this());
}
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf(
- "SBDebugger(%p)::GetDummyTarget() => SBTarget(%p)",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(sb_target.GetSP().get()));
+ LLDB_LOGF(log, "SBDebugger(%p)::GetDummyTarget() => SBTarget(%p)",
+ static_cast<void *>(m_opaque_sp.get()),
+ static_cast<void *>(sb_target.GetSP().get()));
return LLDB_RECORD_RESULT(sb_target);
}
@@ -814,10 +873,9 @@ bool SBDebugger::DeleteTarget(lldb::SBTarget &target) {
}
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBDebugger(%p)::DeleteTarget (SBTarget(%p)) => %i",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(target.m_opaque_sp.get()), result);
+ 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);
return result;
}
@@ -914,9 +972,9 @@ SBTarget SBDebugger::GetSelectedTarget() {
if (log) {
SBStream sstr;
sb_target.GetDescription(sstr, eDescriptionLevelBrief);
- log->Printf("SBDebugger(%p)::GetSelectedTarget () => SBTarget(%p): %s",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(target_sp.get()), sstr.GetData());
+ LLDB_LOGF(log, "SBDebugger(%p)::GetSelectedTarget () => SBTarget(%p): %s",
+ static_cast<void *>(m_opaque_sp.get()),
+ static_cast<void *>(target_sp.get()), sstr.GetData());
}
return LLDB_RECORD_RESULT(sb_target);
@@ -935,9 +993,9 @@ void SBDebugger::SetSelectedTarget(SBTarget &sb_target) {
if (log) {
SBStream sstr;
sb_target.GetDescription(sstr, eDescriptionLevelBrief);
- log->Printf("SBDebugger(%p)::SetSelectedTarget () => SBTarget(%p): %s",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(target_sp.get()), sstr.GetData());
+ LLDB_LOGF(log, "SBDebugger(%p)::SetSelectedTarget () => SBTarget(%p): %s",
+ static_cast<void *>(m_opaque_sp.get()),
+ static_cast<void *>(target_sp.get()), sstr.GetData());
}
}
@@ -951,11 +1009,10 @@ SBPlatform SBDebugger::GetSelectedPlatform() {
if (debugger_sp) {
sb_platform.SetSP(debugger_sp->GetPlatformList().GetSelectedPlatform());
}
- if (log)
- log->Printf("SBDebugger(%p)::GetSelectedPlatform () => SBPlatform(%p): %s",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(sb_platform.GetSP().get()),
- sb_platform.GetName());
+ 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());
return LLDB_RECORD_RESULT(sb_platform);
}
@@ -970,11 +1027,10 @@ void SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform) {
debugger_sp->GetPlatformList().SetSelectedPlatform(sb_platform.GetSP());
}
- if (log)
- log->Printf("SBDebugger(%p)::SetSelectedPlatform (SBPlatform(%p) %s)",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(sb_platform.GetSP().get()),
- sb_platform.GetName());
+ 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());
}
uint32_t SBDebugger::GetNumPlatforms() {
@@ -1018,7 +1074,7 @@ SBStructuredData SBDebugger::GetAvailablePlatformInfoAtIndex(uint32_t idx) {
GetAvailablePlatformInfoAtIndex, (uint32_t), idx);
SBStructuredData data;
- auto platform_dict = llvm::make_unique<StructuredData::Dictionary>();
+ auto platform_dict = std::make_unique<StructuredData::Dictionary>();
llvm::StringRef name_str("name"), desc_str("description");
if (idx == 0) {
@@ -1062,7 +1118,7 @@ void SBDebugger::DispatchInput(const void *data, size_t data_len) {
// Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
//
// if (log)
- // log->Printf ("SBDebugger(%p)::DispatchInput (data=\"%.*s\",
+ // LLDB_LOGF(log, "SBDebugger(%p)::DispatchInput (data=\"%.*s\",
// size_t=%" PRIu64 ")",
// m_opaque_sp.get(),
// (int) data_len,
@@ -1074,7 +1130,7 @@ void SBDebugger::DispatchInput(const void *data, size_t data_len) {
}
void SBDebugger::DispatchInputInterrupt() {
- LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, DispatchInputInterrupt);
+ LLDB_RECORD_DUMMY_NO_ARGS(void, SBDebugger, DispatchInputInterrupt);
if (m_opaque_sp)
m_opaque_sp->DispatchInputInterrupt();
@@ -1234,8 +1290,7 @@ uint32_t SBDebugger::GetTerminalWidth() const {
}
void SBDebugger::SetTerminalWidth(uint32_t term_width) {
- LLDB_RECORD_METHOD(void, SBDebugger, SetTerminalWidth, (uint32_t),
- term_width);
+ LLDB_RECORD_DUMMY(void, SBDebugger, SetTerminalWidth, (uint32_t), term_width);
if (m_opaque_sp)
m_opaque_sp->SetTerminalWidth(term_width);
@@ -1246,10 +1301,9 @@ const char *SBDebugger::GetPrompt() const {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBDebugger(%p)::GetPrompt () => \"%s\"",
- static_cast<void *>(m_opaque_sp.get()),
- (m_opaque_sp ? m_opaque_sp->GetPrompt().str().c_str() : ""));
+ LLDB_LOGF(log, "SBDebugger(%p)::GetPrompt () => \"%s\"",
+ static_cast<void *>(m_opaque_sp.get()),
+ (m_opaque_sp ? m_opaque_sp->GetPrompt().str().c_str() : ""));
return (m_opaque_sp ? ConstString(m_opaque_sp->GetPrompt()).GetCString()
: nullptr);
@@ -1374,7 +1428,8 @@ bool SBDebugger::SetCurrentPlatformSDKRoot(const char *sysroot) {
if (platform_sp) {
if (log && sysroot)
- log->Printf("SBDebugger::SetCurrentPlatformSDKRoot (\"%s\")", sysroot);
+ LLDB_LOGF(log, "SBDebugger::SetCurrentPlatformSDKRoot (\"%s\")",
+ sysroot);
platform_sp->SetSDKRootDirectory(ConstString(sysroot));
return true;
}
@@ -1549,8 +1604,7 @@ void SBDebugger::SetLoggingCallback(lldb::LogOutputCallback log_callback,
namespace lldb_private {
namespace repro {
-template <>
-void RegisterMethods<SBInputReader>(Registry &R) {
+template <> void RegisterMethods<SBInputReader>(Registry &R) {
LLDB_REGISTER_METHOD(void, SBInputReader, SetIsDone, (bool));
LLDB_REGISTER_METHOD_CONST(bool, SBInputReader, IsActive, ());
}
@@ -1559,6 +1613,10 @@ static void SetFileHandleRedirect(SBDebugger *, FILE *, bool) {
// Do nothing.
}
+static SBError SetFileRedirect(SBDebugger *, SBFile file) { return SBError(); }
+
+static SBError SetFileRedirect(SBDebugger *, FileSP file) { return SBError(); }
+
static bool GetDefaultArchitectureRedirect(char *arch_name,
size_t arch_name_len) {
// The function is writing to its argument. Without the redirect it would
@@ -1567,8 +1625,7 @@ static bool GetDefaultArchitectureRedirect(char *arch_name,
return SBDebugger::GetDefaultArchitecture(buffer, arch_name_len);
}
-template <>
-void RegisterMethods<SBDebugger>(Registry &R) {
+template <> void RegisterMethods<SBDebugger>(Registry &R) {
// Custom implementation.
R.Register(&invoke<void (SBDebugger::*)(
FILE *, bool)>::method<&SBDebugger::SetErrorFileHandle>::doit,
@@ -1580,6 +1637,26 @@ void RegisterMethods<SBDebugger>(Registry &R) {
&SBDebugger::GetDefaultArchitecture),
&GetDefaultArchitectureRedirect);
+ R.Register(&invoke<SBError (SBDebugger::*)(
+ SBFile)>::method<&SBDebugger::SetInputFile>::doit,
+ &SetFileRedirect);
+ R.Register(&invoke<SBError (SBDebugger::*)(
+ SBFile)>::method<&SBDebugger::SetOutputFile>::doit,
+ &SetFileRedirect);
+ R.Register(&invoke<SBError (SBDebugger::*)(
+ SBFile)>::method<&SBDebugger::SetErrorFile>::doit,
+ &SetFileRedirect);
+
+ R.Register(&invoke<SBError (SBDebugger::*)(
+ FileSP)>::method<&SBDebugger::SetInputFile>::doit,
+ &SetFileRedirect);
+ R.Register(&invoke<SBError (SBDebugger::*)(
+ FileSP)>::method<&SBDebugger::SetOutputFile>::doit,
+ &SetFileRedirect);
+ R.Register(&invoke<SBError (SBDebugger::*)(
+ FileSP)>::method<&SBDebugger::SetErrorFile>::doit,
+ &SetFileRedirect);
+
LLDB_REGISTER_CONSTRUCTOR(SBDebugger, ());
LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &));
LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &));
@@ -1592,11 +1669,10 @@ void RegisterMethods<SBDebugger>(Registry &R) {
LLDB_REGISTER_METHOD(void, SBDebugger, Clear, ());
LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, ());
LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, (bool));
- LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Destroy,
- (lldb::SBDebugger &));
+ LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Destroy, (lldb::SBDebugger &));
LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, MemoryPressureDetected, ());
LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, IsValid, ());
- LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, operator bool, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, operator bool,());
LLDB_REGISTER_METHOD(void, SBDebugger, SetAsync, (bool));
LLDB_REGISTER_METHOD(bool, SBDebugger, GetAsync, ());
LLDB_REGISTER_METHOD(void, SBDebugger, SkipLLDBInitFiles, (bool));
@@ -1605,6 +1681,9 @@ void RegisterMethods<SBDebugger>(Registry &R) {
LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetInputFileHandle, ());
LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetOutputFileHandle, ());
LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetErrorFileHandle, ());
+ LLDB_REGISTER_METHOD(SBFile, SBDebugger, GetInputFile, ());
+ LLDB_REGISTER_METHOD(SBFile, SBDebugger, GetOutputFile, ());
+ LLDB_REGISTER_METHOD(SBFile, SBDebugger, GetErrorFile, ());
LLDB_REGISTER_METHOD(void, SBDebugger, SaveInputTerminalState, ());
LLDB_REGISTER_METHOD(void, SBDebugger, RestoreInputTerminalState, ());
LLDB_REGISTER_METHOD(lldb::SBCommandInterpreter, SBDebugger,
@@ -1614,8 +1693,13 @@ void RegisterMethods<SBDebugger>(Registry &R) {
LLDB_REGISTER_METHOD(
void, SBDebugger, HandleProcessEvent,
(const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *));
- LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBDebugger, GetSourceManager,
- ());
+ 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));
+ LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBDebugger, GetSourceManager, ());
LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, SetDefaultArchitecture,
(const char *));
LLDB_REGISTER_METHOD(lldb::ScriptLanguage, SBDebugger, GetScriptingLanguage,
@@ -1635,8 +1719,7 @@ void RegisterMethods<SBDebugger>(Registry &R) {
LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger,
CreateTargetWithFileAndTargetTriple,
(const char *, const char *));
- LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger,
- CreateTargetWithFileAndArch,
+ LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, CreateTargetWithFileAndArch,
(const char *, const char *));
LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, CreateTarget,
(const char *));
@@ -1652,8 +1735,7 @@ void RegisterMethods<SBDebugger>(Registry &R) {
(const char *, const char *));
LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumTargets, ());
LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetSelectedTarget, ());
- LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedTarget,
- (lldb::SBTarget &));
+ LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedTarget, (lldb::SBTarget &));
LLDB_REGISTER_METHOD(lldb::SBPlatform, SBDebugger, GetSelectedPlatform, ());
LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedPlatform,
(lldb::SBPlatform &));
@@ -1673,8 +1755,8 @@ void RegisterMethods<SBDebugger>(Registry &R) {
int &, bool &, bool &));
LLDB_REGISTER_METHOD(lldb::SBError, SBDebugger, RunREPL,
(lldb::LanguageType, const char *));
- LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger,
- FindDebuggerWithID, (int));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, FindDebuggerWithID,
+ (int));
LLDB_REGISTER_METHOD(const char *, SBDebugger, GetInstanceName, ());
LLDB_REGISTER_STATIC_METHOD(lldb::SBError, SBDebugger, SetInternalVariable,
(const char *, const char *, const char *));
@@ -1726,5 +1808,5 @@ void RegisterMethods<SBDebugger>(Registry &R) {
(const char *, const char **));
}
-}
-}
+} // namespace repro
+} // namespace lldb_private
diff --git a/source/API/SBDeclaration.cpp b/source/API/SBDeclaration.cpp
index a7790b293981..50db1770c612 100644
--- a/source/API/SBDeclaration.cpp
+++ b/source/API/SBDeclaration.cpp
@@ -32,7 +32,7 @@ SBDeclaration::SBDeclaration(const SBDeclaration &rhs) : m_opaque_up() {
SBDeclaration::SBDeclaration(const lldb_private::Declaration *lldb_object_ptr)
: m_opaque_up() {
if (lldb_object_ptr)
- m_opaque_up = llvm::make_unique<Declaration>(*lldb_object_ptr);
+ m_opaque_up = std::make_unique<Declaration>(*lldb_object_ptr);
}
const SBDeclaration &SBDeclaration::operator=(const SBDeclaration &rhs) {
diff --git a/source/API/SBFile.cpp b/source/API/SBFile.cpp
new file mode 100644
index 000000000000..f5a38efe4a77
--- /dev/null
+++ b/source/API/SBFile.cpp
@@ -0,0 +1,129 @@
+//===-- SBFile.cpp ------------------------------------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/API/SBFile.h"
+#include "SBReproducerPrivate.h"
+#include "lldb/API/SBError.h"
+#include "lldb/Host/File.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+SBFile::~SBFile() {}
+
+SBFile::SBFile(FileSP file_sp) : m_opaque_sp(file_sp) {
+ LLDB_RECORD_DUMMY(void, SBfile, SBFile, (FileSP), file_sp);
+}
+
+SBFile::SBFile() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFile); }
+
+SBFile::SBFile(FILE *file, bool transfer_ownership) {
+ LLDB_RECORD_DUMMY(void, SBFile, (FILE *, bool), file, transfer_ownership);
+ m_opaque_sp = std::make_shared<NativeFile>(file, transfer_ownership);
+}
+
+SBFile::SBFile(int fd, const char *mode, bool transfer_owndership) {
+ LLDB_RECORD_DUMMY(void, SBFile, (int, const char *, bool), fd, mode,
+ transfer_owndership);
+ auto options = File::GetOptionsFromMode(mode);
+ if (!options) {
+ llvm::consumeError(options.takeError());
+ return;
+ }
+ m_opaque_sp =
+ std::make_shared<NativeFile>(fd, options.get(), transfer_owndership);
+}
+
+SBError SBFile::Read(uint8_t *buf, size_t num_bytes, size_t *bytes_read) {
+ LLDB_RECORD_DUMMY(lldb::SBError, SBFile, Read, (uint8_t *, size_t, size_t *),
+ buf, num_bytes, bytes_read);
+ SBError error;
+ if (!m_opaque_sp) {
+ error.SetErrorString("invalid SBFile");
+ *bytes_read = 0;
+ } else {
+ Status status = m_opaque_sp->Read(buf, num_bytes);
+ error.SetError(status);
+ *bytes_read = num_bytes;
+ }
+ return LLDB_RECORD_RESULT(error);
+}
+
+SBError SBFile::Write(const uint8_t *buf, size_t num_bytes,
+ size_t *bytes_written) {
+ LLDB_RECORD_DUMMY(lldb::SBError, SBFile, Write,
+ (const uint8_t *, size_t, size_t *), buf, num_bytes,
+ bytes_written);
+ SBError error;
+ if (!m_opaque_sp) {
+ error.SetErrorString("invalid SBFile");
+ *bytes_written = 0;
+ } else {
+ Status status = m_opaque_sp->Write(buf, num_bytes);
+ error.SetError(status);
+ *bytes_written = num_bytes;
+ }
+ return LLDB_RECORD_RESULT(error);
+}
+
+SBError SBFile::Flush() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBFile, Flush);
+ SBError error;
+ if (!m_opaque_sp) {
+ error.SetErrorString("invalid SBFile");
+ } else {
+ Status status = m_opaque_sp->Flush();
+ error.SetError(status);
+ }
+ return LLDB_RECORD_RESULT(error);
+}
+
+bool SBFile::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFile, IsValid);
+ return m_opaque_sp && m_opaque_sp->IsValid();
+}
+
+SBError SBFile::Close() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBFile, Close);
+ SBError error;
+ if (m_opaque_sp) {
+ Status status = m_opaque_sp->Close();
+ error.SetError(status);
+ }
+ return LLDB_RECORD_RESULT(error);
+}
+
+SBFile::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFile, operator bool);
+ return LLDB_RECORD_RESULT(IsValid());
+}
+
+bool SBFile::operator!() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFile, operator!);
+ return LLDB_RECORD_RESULT(!IsValid());
+}
+
+FileSP SBFile::GetFile() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(FileSP, SBFile, GetFile);
+ return m_opaque_sp;
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <> void RegisterMethods<SBFile>(Registry &R) {
+
+ LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Flush, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBFile, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBFile, operator bool,());
+ LLDB_REGISTER_METHOD_CONST(bool, SBFile, operator!,());
+ LLDB_REGISTER_METHOD_CONST(FileSP, SBFile, GetFile, ());
+ LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Close, ());
+}
+} // namespace repro
+} // namespace lldb_private
diff --git a/source/API/SBFrame.cpp b/source/API/SBFrame.cpp
index 9268f0f9bdbf..c0e272e1bcd4 100644
--- a/source/API/SBFrame.cpp
+++ b/source/API/SBFrame.cpp
@@ -1107,7 +1107,7 @@ lldb::SBValue SBFrame::EvaluateExpression(const char *expr,
if (target->GetDisplayExpressionsInCrashlogs()) {
StreamString frame_description;
frame->DumpUsingSettingsFormat(&frame_description);
- stack_trace = llvm::make_unique<llvm::PrettyStackTraceFormat>(
+ stack_trace = std::make_unique<llvm::PrettyStackTraceFormat>(
"SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value "
"= %u) %s",
expr, options.GetFetchDynamicValue(),
@@ -1120,10 +1120,10 @@ lldb::SBValue SBFrame::EvaluateExpression(const char *expr,
}
}
- if (expr_log)
- expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is "
- "%s, summary %s **",
- expr_result.GetValue(), expr_result.GetSummary());
+ LLDB_LOGF(expr_log,
+ "** [SBFrame::EvaluateExpression] Expression result is "
+ "%s, summary %s **",
+ expr_result.GetValue(), expr_result.GetSummary());
return LLDB_RECORD_RESULT(expr_result);
}
diff --git a/source/API/SBInstruction.cpp b/source/API/SBInstruction.cpp
index fcf66fd25824..a9ef9fb59d24 100644
--- a/source/API/SBInstruction.cpp
+++ b/source/API/SBInstruction.cpp
@@ -11,6 +11,7 @@
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBFrame.h"
+#include "lldb/API/SBFile.h"
#include "lldb/API/SBInstruction.h"
#include "lldb/API/SBStream.h"
@@ -255,10 +256,21 @@ bool SBInstruction::GetDescription(lldb::SBStream &s) {
return false;
}
-void SBInstruction::Print(FILE *out) {
- LLDB_RECORD_METHOD(void, SBInstruction, Print, (FILE *), out);
+void SBInstruction::Print(FILE *outp) {
+ LLDB_RECORD_METHOD(void, SBInstruction, Print, (FILE *), outp);
+ FileSP out = std::make_shared<NativeFile>(outp, /*take_ownership=*/false);
+ Print(out);
+}
+
+void SBInstruction::Print(SBFile out) {
+ LLDB_RECORD_METHOD(void, SBInstruction, Print, (SBFile), out);
+ Print(out.m_opaque_sp);
+}
+
+void SBInstruction::Print(FileSP out_sp) {
+ LLDB_RECORD_METHOD(void, SBInstruction, Print, (FileSP), out_sp);
- if (out == nullptr)
+ if (!out_sp || !out_sp->IsValid())
return;
lldb::InstructionSP inst_sp(GetOpaque());
@@ -269,7 +281,7 @@ void SBInstruction::Print(FILE *out) {
if (module_sp)
module_sp->ResolveSymbolContextForAddress(addr, eSymbolContextEverything,
sc);
- StreamFile out_stream(out, false);
+ StreamFile out_stream(out_sp);
FormatEntity::Entry format;
FormatEntity::Parse("${addr}: ", format);
inst_sp->Dump(&out_stream, 0, true, false, nullptr, &sc, nullptr, &format,
@@ -358,6 +370,8 @@ void RegisterMethods<SBInstruction>(Registry &R) {
LLDB_REGISTER_METHOD(bool, SBInstruction, GetDescription,
(lldb::SBStream &));
LLDB_REGISTER_METHOD(void, SBInstruction, Print, (FILE *));
+ LLDB_REGISTER_METHOD(void, SBInstruction, Print, (SBFile));
+ LLDB_REGISTER_METHOD(void, SBInstruction, Print, (FileSP));
LLDB_REGISTER_METHOD(bool, SBInstruction, EmulateWithFrame,
(lldb::SBFrame &, uint32_t));
LLDB_REGISTER_METHOD(bool, SBInstruction, DumpEmulation, (const char *));
diff --git a/source/API/SBInstructionList.cpp b/source/API/SBInstructionList.cpp
index cce923bf04a4..8b3855c0883b 100644
--- a/source/API/SBInstructionList.cpp
+++ b/source/API/SBInstructionList.cpp
@@ -11,8 +11,10 @@
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBInstruction.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBFile.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/StreamFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Utility/Stream.h"
@@ -118,21 +120,41 @@ void SBInstructionList::SetDisassembler(const lldb::DisassemblerSP &opaque_sp) {
void SBInstructionList::Print(FILE *out) {
LLDB_RECORD_METHOD(void, SBInstructionList, Print, (FILE *), out);
-
if (out == nullptr)
return;
+ StreamFile stream(out, false);
+ GetDescription(stream);
}
-bool SBInstructionList::GetDescription(lldb::SBStream &description) {
+void SBInstructionList::Print(SBFile out) {
+ LLDB_RECORD_METHOD(void, SBInstructionList, Print, (SBFile), out);
+ if (!out.IsValid())
+ return;
+ StreamFile stream(out.m_opaque_sp);
+ GetDescription(stream);
+}
+
+void SBInstructionList::Print(FileSP out_sp) {
+ LLDB_RECORD_METHOD(void, SBInstructionList, Print, (FileSP), out_sp);
+ if (!out_sp || !out_sp->IsValid())
+ return;
+ StreamFile stream(out_sp);
+ GetDescription(stream);
+}
+
+bool SBInstructionList::GetDescription(lldb::SBStream &stream) {
LLDB_RECORD_METHOD(bool, SBInstructionList, GetDescription,
- (lldb::SBStream &), description);
+ (lldb::SBStream &), stream);
+ return GetDescription(stream.ref());
+}
+
+bool SBInstructionList::GetDescription(Stream &sref) {
if (m_opaque_sp) {
size_t num_instructions = GetSize();
if (num_instructions) {
// Call the ref() to make sure a stream is created if one deesn't exist
// already inside description...
- Stream &sref = description.ref();
const uint32_t max_opcode_byte_size =
m_opaque_sp->GetInstructionList().GetMaxOpcocdeByteSize();
FormatEntity::Entry format;
@@ -200,6 +222,8 @@ void RegisterMethods<SBInstructionList>(Registry &R) {
LLDB_REGISTER_METHOD(void, SBInstructionList, AppendInstruction,
(lldb::SBInstruction));
LLDB_REGISTER_METHOD(void, SBInstructionList, Print, (FILE *));
+ LLDB_REGISTER_METHOD(void, SBInstructionList, Print, (SBFile));
+ LLDB_REGISTER_METHOD(void, SBInstructionList, Print, (FileSP));
LLDB_REGISTER_METHOD(bool, SBInstructionList, GetDescription,
(lldb::SBStream &));
LLDB_REGISTER_METHOD(bool, SBInstructionList,
diff --git a/source/API/SBLineEntry.cpp b/source/API/SBLineEntry.cpp
index 010a6057cd31..66884f763398 100644
--- a/source/API/SBLineEntry.cpp
+++ b/source/API/SBLineEntry.cpp
@@ -32,7 +32,7 @@ SBLineEntry::SBLineEntry(const SBLineEntry &rhs) : m_opaque_up() {
SBLineEntry::SBLineEntry(const lldb_private::LineEntry *lldb_object_ptr)
: m_opaque_up() {
if (lldb_object_ptr)
- m_opaque_up = llvm::make_unique<LineEntry>(*lldb_object_ptr);
+ m_opaque_up = std::make_unique<LineEntry>(*lldb_object_ptr);
}
const SBLineEntry &SBLineEntry::operator=(const SBLineEntry &rhs) {
@@ -45,7 +45,7 @@ const SBLineEntry &SBLineEntry::operator=(const SBLineEntry &rhs) {
}
void SBLineEntry::SetLineEntry(const lldb_private::LineEntry &lldb_object_ref) {
- m_opaque_up = llvm::make_unique<LineEntry>(lldb_object_ref);
+ m_opaque_up = std::make_unique<LineEntry>(lldb_object_ref);
}
SBLineEntry::~SBLineEntry() {}
diff --git a/source/API/SBModule.cpp b/source/API/SBModule.cpp
index 4bd32bce1c53..6cc6d2628ace 100644
--- a/source/API/SBModule.cpp
+++ b/source/API/SBModule.cpp
@@ -20,7 +20,6 @@
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolFile.h"
-#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/Symtab.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Symbol/VariableList.h"
@@ -283,18 +282,14 @@ SBSymbolContextList SBModule::FindCompileUnits(const SBFileSpec &sb_file_spec) {
SBSymbolContextList sb_sc_list;
const ModuleSP module_sp(GetSP());
if (sb_file_spec.IsValid() && module_sp) {
- const bool append = true;
- module_sp->FindCompileUnits(*sb_file_spec, append, *sb_sc_list);
+ module_sp->FindCompileUnits(*sb_file_spec, *sb_sc_list);
}
return LLDB_RECORD_RESULT(sb_sc_list);
}
static Symtab *GetUnifiedSymbolTable(const lldb::ModuleSP &module_sp) {
- if (module_sp) {
- SymbolVendor *symbols = module_sp->GetSymbolVendor();
- if (symbols)
- return symbols->GetSymtab();
- }
+ if (module_sp)
+ return module_sp->GetSymtab();
return nullptr;
}
@@ -302,11 +297,8 @@ size_t SBModule::GetNumSymbols() {
LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModule, GetNumSymbols);
ModuleSP module_sp(GetSP());
- if (module_sp) {
- Symtab *symtab = GetUnifiedSymbolTable(module_sp);
- if (symtab)
- return symtab->GetNumSymbols();
- }
+ if (Symtab *symtab = GetUnifiedSymbolTable(module_sp))
+ return symtab->GetNumSymbols();
return 0;
}
@@ -349,8 +341,9 @@ lldb::SBSymbolContextList SBModule::FindSymbols(const char *name,
Symtab *symtab = GetUnifiedSymbolTable(module_sp);
if (symtab) {
std::vector<uint32_t> matching_symbol_indexes;
- const size_t num_matches = symtab->FindAllSymbolsWithNameAndType(
- ConstString(name), symbol_type, matching_symbol_indexes);
+ symtab->FindAllSymbolsWithNameAndType(ConstString(name), symbol_type,
+ matching_symbol_indexes);
+ const size_t num_matches = matching_symbol_indexes.size();
if (num_matches) {
SymbolContext sc;
sc.module_sp = module_sp;
@@ -372,7 +365,7 @@ size_t SBModule::GetNumSections() {
ModuleSP module_sp(GetSP());
if (module_sp) {
// Give the symbol vendor a chance to add to the unified section list.
- module_sp->GetSymbolVendor();
+ module_sp->GetSymbolFile();
SectionList *section_list = module_sp->GetSectionList();
if (section_list)
return section_list->GetSize();
@@ -388,7 +381,7 @@ SBSection SBModule::GetSectionAtIndex(size_t idx) {
ModuleSP module_sp(GetSP());
if (module_sp) {
// Give the symbol vendor a chance to add to the unified section list.
- module_sp->GetSymbolVendor();
+ module_sp->GetSymbolFile();
SectionList *section_list = module_sp->GetSectionList();
if (section_list)
@@ -405,12 +398,11 @@ lldb::SBSymbolContextList SBModule::FindFunctions(const char *name,
lldb::SBSymbolContextList sb_sc_list;
ModuleSP module_sp(GetSP());
if (name && module_sp) {
- const bool append = true;
const bool symbols_ok = true;
const bool inlines_ok = true;
FunctionNameType type = static_cast<FunctionNameType>(name_type_mask);
module_sp->FindFunctions(ConstString(name), nullptr, type, symbols_ok,
- inlines_ok, append, *sb_sc_list);
+ inlines_ok, *sb_sc_list);
}
return LLDB_RECORD_RESULT(sb_sc_list);
}
@@ -425,9 +417,9 @@ SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name,
ModuleSP module_sp(GetSP());
if (name && module_sp) {
VariableList variable_list;
- const uint32_t match_count = module_sp->FindGlobalVariables(
- ConstString(name), nullptr, max_matches, variable_list);
-
+ module_sp->FindGlobalVariables(ConstString(name), nullptr, max_matches,
+ variable_list);
+ const uint32_t match_count = variable_list.GetSize();
if (match_count > 0) {
for (uint32_t i = 0; i < match_count; ++i) {
lldb::ValueObjectSP valobj_sp;
@@ -468,10 +460,13 @@ lldb::SBType SBModule::FindFirstType(const char *name_cstr) {
sb_type = SBType(module_sp->FindFirstType(sc, name, exact_match));
if (!sb_type.IsValid()) {
- TypeSystem *type_system =
+ auto type_system_or_err =
module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
- if (type_system)
- sb_type = SBType(type_system->GetBuiltinTypeByName(name));
+ if (auto err = type_system_or_err.takeError()) {
+ llvm::consumeError(std::move(err));
+ return LLDB_RECORD_RESULT(SBType());
+ }
+ sb_type = SBType(type_system_or_err->GetBuiltinTypeByName(name));
}
}
return LLDB_RECORD_RESULT(sb_type);
@@ -483,10 +478,14 @@ lldb::SBType SBModule::GetBasicType(lldb::BasicType type) {
ModuleSP module_sp(GetSP());
if (module_sp) {
- TypeSystem *type_system =
+ auto type_system_or_err =
module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
- if (type_system)
- return LLDB_RECORD_RESULT(SBType(type_system->GetBasicTypeFromAST(type)));
+ if (auto err = type_system_or_err.takeError()) {
+ llvm::consumeError(std::move(err));
+ } else {
+ return LLDB_RECORD_RESULT(
+ SBType(type_system_or_err->GetBasicTypeFromAST(type)));
+ }
}
return LLDB_RECORD_RESULT(SBType());
}
@@ -503,26 +502,28 @@ lldb::SBTypeList SBModule::FindTypes(const char *type) {
const bool exact_match = false;
ConstString name(type);
llvm::DenseSet<SymbolFile *> searched_symbol_files;
- const uint32_t num_matches = module_sp->FindTypes(
- name, exact_match, UINT32_MAX, searched_symbol_files, type_list);
+ module_sp->FindTypes(name, exact_match, UINT32_MAX, searched_symbol_files,
+ type_list);
- if (num_matches > 0) {
- for (size_t idx = 0; idx < num_matches; idx++) {
- TypeSP type_sp(type_list.GetTypeAtIndex(idx));
- if (type_sp)
- retval.Append(SBType(type_sp));
- }
- } else {
- TypeSystem *type_system =
+ if (type_list.Empty()) {
+ auto type_system_or_err =
module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
- if (type_system) {
- CompilerType compiler_type = type_system->GetBuiltinTypeByName(name);
+ if (auto err = type_system_or_err.takeError()) {
+ llvm::consumeError(std::move(err));
+ } else {
+ CompilerType compiler_type =
+ type_system_or_err->GetBuiltinTypeByName(name);
if (compiler_type)
retval.Append(SBType(compiler_type));
}
+ } else {
+ for (size_t idx = 0; idx < type_list.GetSize(); idx++) {
+ TypeSP type_sp(type_list.GetTypeAtIndex(idx));
+ if (type_sp)
+ retval.Append(SBType(type_sp));
+ }
}
}
-
return LLDB_RECORD_RESULT(retval);
}
@@ -532,9 +533,8 @@ lldb::SBType SBModule::GetTypeByID(lldb::user_id_t uid) {
ModuleSP module_sp(GetSP());
if (module_sp) {
- SymbolVendor *vendor = module_sp->GetSymbolVendor();
- if (vendor) {
- Type *type_ptr = vendor->ResolveTypeUID(uid);
+ if (SymbolFile *symfile = module_sp->GetSymbolFile()) {
+ Type *type_ptr = symfile->ResolveTypeUID(uid);
if (type_ptr)
return LLDB_RECORD_RESULT(SBType(type_ptr->shared_from_this()));
}
@@ -551,13 +551,13 @@ lldb::SBTypeList SBModule::GetTypes(uint32_t type_mask) {
ModuleSP module_sp(GetSP());
if (!module_sp)
return LLDB_RECORD_RESULT(sb_type_list);
- SymbolVendor *vendor = module_sp->GetSymbolVendor();
- if (!vendor)
+ SymbolFile *symfile = module_sp->GetSymbolFile();
+ if (!symfile)
return LLDB_RECORD_RESULT(sb_type_list);
TypeClass type_class = static_cast<TypeClass>(type_mask);
TypeList type_list;
- vendor->GetTypes(nullptr, type_class, type_list);
+ symfile->GetTypes(nullptr, type_class, type_list);
sb_type_list.m_opaque_up->Append(type_list);
return LLDB_RECORD_RESULT(sb_type_list);
}
@@ -571,7 +571,7 @@ SBSection SBModule::FindSection(const char *sect_name) {
ModuleSP module_sp(GetSP());
if (sect_name && module_sp) {
// Give the symbol vendor a chance to add to the unified section list.
- module_sp->GetSymbolVendor();
+ module_sp->GetSymbolFile();
SectionList *section_list = module_sp->GetSectionList();
if (section_list) {
ConstString const_sect_name(sect_name);
@@ -653,9 +653,8 @@ lldb::SBFileSpec SBModule::GetSymbolFileSpec() const {
lldb::SBFileSpec sb_file_spec;
ModuleSP module_sp(GetSP());
if (module_sp) {
- SymbolVendor *symbol_vendor_ptr = module_sp->GetSymbolVendor();
- if (symbol_vendor_ptr)
- sb_file_spec.SetFileSpec(symbol_vendor_ptr->GetMainFileSpec());
+ if (SymbolFile *symfile = module_sp->GetSymbolFile())
+ sb_file_spec.SetFileSpec(symfile->GetObjectFile()->GetFileSpec());
}
return LLDB_RECORD_RESULT(sb_file_spec);
}
diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp
index 4226ff77ecdc..45aaa0bd2d8a 100644
--- a/source/API/SBProcess.cpp
+++ b/source/API/SBProcess.cpp
@@ -29,11 +29,11 @@
#include "lldb/Utility/State.h"
#include "lldb/Utility/Stream.h"
-
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBCommandReturnObject.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBEvent.h"
+#include "lldb/API/SBFile.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBMemoryRegionInfo.h"
#include "lldb/API/SBMemoryRegionInfoList.h"
@@ -331,23 +331,34 @@ lldb::SBTrace SBProcess::StartTrace(SBTraceOptions &options,
return LLDB_RECORD_RESULT(trace_instance);
}
+void SBProcess::ReportEventState(const SBEvent &event, SBFile out) const {
+ LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
+ (const SBEvent &, SBFile), event, out);
+
+ return ReportEventState(event, out.m_opaque_sp);
+}
+
void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const {
LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
(const lldb::SBEvent &, FILE *), event, out);
+ FileSP outfile = std::make_shared<NativeFile>(out, false);
+ return ReportEventState(event, outfile);
+}
+
+void SBProcess::ReportEventState(const SBEvent &event, FileSP out) const {
+
+ LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
+ (const SBEvent &, FileSP), event, out);
- if (out == nullptr)
+ if (!out || !out->IsValid())
return;
ProcessSP process_sp(GetSP());
if (process_sp) {
+ StreamFile stream(out);
const StateType event_state = SBProcess::GetStateFromEvent(event);
- char message[1024];
- int message_len = ::snprintf(
- message, sizeof(message), "Process %" PRIu64 " %s\n",
+ stream.Printf("Process %" PRIu64 " %s\n",
process_sp->GetID(), SBDebugger::StateAsCString(event_state));
-
- if (message_len > 0)
- ::fwrite(message, 1, message_len, out);
}
}
@@ -1180,6 +1191,9 @@ bool SBProcess::IsInstrumentationRuntimePresent(
if (!process_sp)
return false;
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+
InstrumentationRuntimeSP runtime_sp =
process_sp->GetInstrumentationRuntime(type);
@@ -1307,6 +1321,10 @@ void RegisterMethods<SBProcess>(Registry &R) {
(lldb::SBTraceOptions &, lldb::SBError &));
LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
(const lldb::SBEvent &, FILE *));
+ LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
+ (const lldb::SBEvent &, FileSP));
+ LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
+ (const lldb::SBEvent &, SBFile));
LLDB_REGISTER_METHOD(
void, SBProcess, AppendEventStateReport,
(const lldb::SBEvent &, lldb::SBCommandReturnObject &));
diff --git a/source/API/SBReproducer.cpp b/source/API/SBReproducer.cpp
index 439ee5a70460..6e11b2c6366f 100644
--- a/source/API/SBReproducer.cpp
+++ b/source/API/SBReproducer.cpp
@@ -52,6 +52,7 @@ SBRegistry::SBRegistry() {
RegisterMethods<SBEvent>(R);
RegisterMethods<SBExecutionContext>(R);
RegisterMethods<SBExpressionOptions>(R);
+ RegisterMethods<SBFile>(R);
RegisterMethods<SBFileSpec>(R);
RegisterMethods<SBFileSpecList>(R);
RegisterMethods<SBFrame>(R);
diff --git a/source/API/SBReproducerPrivate.h b/source/API/SBReproducerPrivate.h
index 84b6ce967c0b..edd06941398f 100644
--- a/source/API/SBReproducerPrivate.h
+++ b/source/API/SBReproducerPrivate.h
@@ -40,7 +40,7 @@ public:
SBProvider(const FileSpec &directory)
: Provider(directory),
m_stream(directory.CopyByAppendingPathComponent("sbapi.bin").GetPath(),
- m_ec, llvm::sys::fs::OpenFlags::F_None),
+ m_ec, llvm::sys::fs::OpenFlags::OF_None),
m_serializer(m_stream) {}
Serializer &GetSerializer() { return m_serializer; }
diff --git a/source/API/SBStream.cpp b/source/API/SBStream.cpp
index ae652338e1ea..d57634d2947c 100644
--- a/source/API/SBStream.cpp
+++ b/source/API/SBStream.cpp
@@ -9,6 +9,7 @@
#include "lldb/API/SBStream.h"
#include "SBReproducerPrivate.h"
+#include "lldb/API/SBFile.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Utility/Status.h"
@@ -82,33 +83,45 @@ void SBStream::RedirectToFile(const char *path, bool append) {
if (!m_is_file)
local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString();
}
- StreamFile *stream_file = new StreamFile;
- uint32_t open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate;
+ auto open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate;
if (append)
open_options |= File::eOpenOptionAppend;
else
open_options |= File::eOpenOptionTruncate;
- FileSystem::Instance().Open(stream_file->GetFile(), FileSpec(path),
- open_options);
- m_opaque_up.reset(stream_file);
+ llvm::Expected<FileUP> file =
+ FileSystem::Instance().Open(FileSpec(path), open_options);
+ if (!file) {
+ LLDB_LOG_ERROR(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), file.takeError(),
+ "Cannot open {1}: {0}", path);
+ return;
+ }
- if (m_opaque_up) {
- m_is_file = true;
+ m_opaque_up = std::make_unique<StreamFile>(std::move(file.get()));
+ m_is_file = true;
- // If we had any data locally in our StreamString, then pass that along to
- // the to new file we are redirecting to.
- if (!local_data.empty())
- m_opaque_up->Write(&local_data[0], local_data.size());
- } else
- m_is_file = false;
+ // If we had any data locally in our StreamString, then pass that along to
+ // the to new file we are redirecting to.
+ if (!local_data.empty())
+ m_opaque_up->Write(&local_data[0], local_data.size());
}
void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) {
LLDB_RECORD_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool), fh,
transfer_fh_ownership);
+ FileSP file = std::make_unique<NativeFile>(fh, transfer_fh_ownership);
+ return RedirectToFile(file);
+}
- if (fh == nullptr)
+void SBStream::RedirectToFile(SBFile file) {
+ LLDB_RECORD_METHOD(void, SBStream, RedirectToFile, (SBFile), file)
+ RedirectToFile(file.GetFile());
+}
+
+void SBStream::RedirectToFile(FileSP file_sp) {
+ LLDB_RECORD_METHOD(void, SBStream, RedirectToFile, (FileSP), file_sp);
+
+ if (!file_sp || !file_sp->IsValid())
return;
std::string local_data;
@@ -118,17 +131,14 @@ void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) {
if (!m_is_file)
local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString();
}
- m_opaque_up.reset(new StreamFile(fh, transfer_fh_ownership));
- if (m_opaque_up) {
- m_is_file = true;
+ m_opaque_up = std::make_unique<StreamFile>(file_sp);
+ m_is_file = true;
- // If we had any data locally in our StreamString, then pass that along to
- // the to new file we are redirecting to.
- if (!local_data.empty())
- m_opaque_up->Write(&local_data[0], local_data.size());
- } else
- m_is_file = false;
+ // If we had any data locally in our StreamString, then pass that along to
+ // the to new file we are redirecting to.
+ if (!local_data.empty())
+ m_opaque_up->Write(&local_data[0], local_data.size());
}
void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) {
@@ -143,16 +153,13 @@ void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) {
local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString();
}
- m_opaque_up.reset(new StreamFile(::fdopen(fd, "w"), transfer_fh_ownership));
- if (m_opaque_up) {
- m_is_file = true;
+ m_opaque_up = std::make_unique<StreamFile>(fd, transfer_fh_ownership);
+ m_is_file = true;
- // If we had any data locally in our StreamString, then pass that along to
- // the to new file we are redirecting to.
- if (!local_data.empty())
- m_opaque_up->Write(&local_data[0], local_data.size());
- } else
- m_is_file = false;
+ // If we had any data locally in our StreamString, then pass that along to
+ // the to new file we are redirecting to.
+ if (!local_data.empty())
+ m_opaque_up->Write(&local_data[0], local_data.size());
}
lldb_private::Stream *SBStream::operator->() { return m_opaque_up.get(); }
@@ -189,6 +196,8 @@ void RegisterMethods<SBStream>(Registry &R) {
LLDB_REGISTER_METHOD(const char *, SBStream, GetData, ());
LLDB_REGISTER_METHOD(size_t, SBStream, GetSize, ());
LLDB_REGISTER_METHOD(void, SBStream, RedirectToFile, (const char *, bool));
+ LLDB_REGISTER_METHOD(void, SBStream, RedirectToFile, (FileSP));
+ LLDB_REGISTER_METHOD(void, SBStream, RedirectToFile, (SBFile));
LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool));
LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool));
LLDB_REGISTER_METHOD(void, SBStream, Clear, ());
diff --git a/source/API/SBStringList.cpp b/source/API/SBStringList.cpp
index 2f8bd55855a1..ac07b8faac4d 100644
--- a/source/API/SBStringList.cpp
+++ b/source/API/SBStringList.cpp
@@ -21,7 +21,7 @@ SBStringList::SBStringList() : m_opaque_up() {
SBStringList::SBStringList(const lldb_private::StringList *lldb_strings_ptr)
: m_opaque_up() {
if (lldb_strings_ptr)
- m_opaque_up = llvm::make_unique<StringList>(*lldb_strings_ptr);
+ m_opaque_up = std::make_unique<StringList>(*lldb_strings_ptr);
}
SBStringList::SBStringList(const SBStringList &rhs) : m_opaque_up() {
diff --git a/source/API/SBSymbolContext.cpp b/source/API/SBSymbolContext.cpp
index 365f0ccc2fbf..6e01e5535c32 100644
--- a/source/API/SBSymbolContext.cpp
+++ b/source/API/SBSymbolContext.cpp
@@ -27,7 +27,7 @@ SBSymbolContext::SBSymbolContext(const SymbolContext *sc_ptr) : m_opaque_up() {
(const lldb_private::SymbolContext *), sc_ptr);
if (sc_ptr)
- m_opaque_up = llvm::make_unique<SymbolContext>(*sc_ptr);
+ m_opaque_up = std::make_unique<SymbolContext>(*sc_ptr);
}
SBSymbolContext::SBSymbolContext(const SBSymbolContext &rhs) : m_opaque_up() {
@@ -51,7 +51,7 @@ const SBSymbolContext &SBSymbolContext::operator=(const SBSymbolContext &rhs) {
void SBSymbolContext::SetSymbolContext(const SymbolContext *sc_ptr) {
if (sc_ptr)
- m_opaque_up = llvm::make_unique<SymbolContext>(*sc_ptr);
+ m_opaque_up = std::make_unique<SymbolContext>(*sc_ptr);
else
m_opaque_up->Clear(true);
}
diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp
index 5e87eb6273b3..1d13087eef69 100644
--- a/source/API/SBTarget.cpp
+++ b/source/API/SBTarget.cpp
@@ -44,11 +44,11 @@
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Host/Host.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/DeclVendor.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/Language.h"
@@ -218,7 +218,7 @@ SBStructuredData SBTarget::GetStatistics() {
if (!target_sp)
return LLDB_RECORD_RESULT(data);
- auto stats_up = llvm::make_unique<StructuredData::Dictionary>();
+ auto stats_up = std::make_unique<StructuredData::Dictionary>();
int i = 0;
for (auto &Entry : target_sp->GetStatistics()) {
std::string Desc = lldb_private::GetStatDescription(
@@ -960,8 +960,8 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex(
const LazyBool skip_prologue = eLazyBoolCalculate;
sb_bp = target_sp->CreateFuncRegexBreakpoint(
- module_list.get(), comp_unit_list.get(), regexp, symbol_language,
- skip_prologue, internal, hardware);
+ module_list.get(), comp_unit_list.get(), std::move(regexp),
+ symbol_language, skip_prologue, internal, hardware);
}
return LLDB_RECORD_RESULT(sb_bp);
@@ -1061,8 +1061,8 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
}
sb_bp = target_sp->CreateSourceRegexBreakpoint(
- module_list.get(), source_file_list.get(), func_names_set, regexp,
- false, hardware, move_to_nearest_code);
+ module_list.get(), source_file_list.get(), func_names_set,
+ std::move(regexp), false, hardware, move_to_nearest_code);
}
return LLDB_RECORD_RESULT(sb_bp);
@@ -1653,11 +1653,8 @@ SBSymbolContextList SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) {
SBSymbolContextList sb_sc_list;
const TargetSP target_sp(GetSP());
- if (target_sp && sb_file_spec.IsValid()) {
- const bool append = true;
- target_sp->GetImages().FindCompileUnits(*sb_file_spec,
- append, *sb_sc_list);
- }
+ if (target_sp && sb_file_spec.IsValid())
+ target_sp->GetImages().FindCompileUnits(*sb_file_spec, *sb_sc_list);
return LLDB_RECORD_RESULT(sb_sc_list);
}
@@ -1783,10 +1780,9 @@ lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name,
const bool symbols_ok = true;
const bool inlines_ok = true;
- const bool append = true;
FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
target_sp->GetImages().FindFunctions(ConstString(name), mask, symbols_ok,
- inlines_ok, append, *sb_sc_list);
+ inlines_ok, *sb_sc_list);
return LLDB_RECORD_RESULT(sb_sc_list);
}
@@ -1806,17 +1802,16 @@ lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name,
switch (matchtype) {
case eMatchTypeRegex:
target_sp->GetImages().FindFunctions(RegularExpression(name_ref), true,
- true, true, *sb_sc_list);
+ true, *sb_sc_list);
break;
case eMatchTypeStartsWith:
regexstr = llvm::Regex::escape(name) + ".*";
target_sp->GetImages().FindFunctions(RegularExpression(regexstr), true,
- true, true, *sb_sc_list);
+ true, *sb_sc_list);
break;
default:
- target_sp->GetImages().FindFunctions(ConstString(name),
- eFunctionNameTypeAny, true, true,
- true, *sb_sc_list);
+ target_sp->GetImages().FindFunctions(
+ ConstString(name), eFunctionNameTypeAny, true, true, *sb_sc_list);
break;
}
}
@@ -1858,11 +1853,11 @@ lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
}
// No matches, search for basic typename matches
- ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
- if (clang_ast)
- return LLDB_RECORD_RESULT(SBType(ClangASTContext::GetBasicType(
- clang_ast->getASTContext(), const_typename)));
+ for (auto *type_system : target_sp->GetScratchTypeSystems())
+ if (auto type = type_system->GetBuiltinTypeByName(const_typename))
+ return LLDB_RECORD_RESULT(SBType(type));
}
+
return LLDB_RECORD_RESULT(SBType());
}
@@ -1872,10 +1867,9 @@ SBType SBTarget::GetBasicType(lldb::BasicType type) {
TargetSP target_sp(GetSP());
if (target_sp) {
- ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
- if (clang_ast)
- return LLDB_RECORD_RESULT(SBType(
- ClangASTContext::GetBasicType(clang_ast->getASTContext(), type)));
+ for (auto *type_system : target_sp->GetScratchTypeSystems())
+ if (auto compiler_type = type_system->GetBasicTypeFromAST(type))
+ return LLDB_RECORD_RESULT(SBType(compiler_type));
}
return LLDB_RECORD_RESULT(SBType());
}
@@ -1892,16 +1886,13 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
bool exact_match = false;
TypeList type_list;
llvm::DenseSet<SymbolFile *> searched_symbol_files;
- uint32_t num_matches =
- images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX,
- searched_symbol_files, type_list);
+ images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX,
+ searched_symbol_files, type_list);
- if (num_matches > 0) {
- for (size_t idx = 0; idx < num_matches; idx++) {
- TypeSP type_sp(type_list.GetTypeAtIndex(idx));
- if (type_sp)
- sb_type_list.Append(SBType(type_sp));
- }
+ for (size_t idx = 0; idx < type_list.GetSize(); idx++) {
+ TypeSP type_sp(type_list.GetTypeAtIndex(idx));
+ if (type_sp)
+ sb_type_list.Append(SBType(type_sp));
}
// Try the loaded language runtimes
@@ -1918,10 +1909,10 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
if (sb_type_list.GetSize() == 0) {
// No matches, search for basic typename matches
- ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
- if (clang_ast)
- sb_type_list.Append(SBType(ClangASTContext::GetBasicType(
- clang_ast->getASTContext(), const_typename)));
+ for (auto *type_system : target_sp->GetScratchTypeSystems())
+ if (auto compiler_type =
+ type_system->GetBuiltinTypeByName(const_typename))
+ sb_type_list.Append(SBType(compiler_type));
}
}
return LLDB_RECORD_RESULT(sb_type_list);
@@ -1937,9 +1928,9 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
TargetSP target_sp(GetSP());
if (name && target_sp) {
VariableList variable_list;
- const uint32_t match_count = target_sp->GetImages().FindGlobalVariables(
- ConstString(name), max_matches, variable_list);
-
+ target_sp->GetImages().FindGlobalVariables(ConstString(name), max_matches,
+ variable_list);
+ const uint32_t match_count = variable_list.GetSize();
if (match_count > 0) {
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
if (exe_scope == nullptr)
@@ -1974,20 +1965,20 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
uint32_t match_count;
switch (matchtype) {
case eMatchTypeNormal:
- match_count = target_sp->GetImages().FindGlobalVariables(
- ConstString(name), max_matches, variable_list);
+ target_sp->GetImages().FindGlobalVariables(ConstString(name), max_matches,
+ variable_list);
break;
case eMatchTypeRegex:
- match_count = target_sp->GetImages().FindGlobalVariables(
- RegularExpression(name_ref), max_matches, variable_list);
+ target_sp->GetImages().FindGlobalVariables(RegularExpression(name_ref),
+ max_matches, variable_list);
break;
case eMatchTypeStartsWith:
regexstr = llvm::Regex::escape(name) + ".*";
- match_count = target_sp->GetImages().FindGlobalVariables(
- RegularExpression(regexstr), max_matches, variable_list);
+ target_sp->GetImages().FindGlobalVariables(RegularExpression(regexstr),
+ max_matches, variable_list);
break;
}
-
+ match_count = variable_list.GetSize();
if (match_count > 0) {
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
if (exe_scope == nullptr)
@@ -2291,11 +2282,9 @@ lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name,
SBSymbolContextList sb_sc_list;
if (name && name[0]) {
TargetSP target_sp(GetSP());
- if (target_sp) {
- bool append = true;
+ if (target_sp)
target_sp->GetImages().FindSymbolsWithNameAndType(
- ConstString(name), symbol_type, *sb_sc_list, append);
- }
+ ConstString(name), symbol_type, *sb_sc_list);
}
return LLDB_RECORD_RESULT(sb_sc_list);
}
@@ -2355,10 +2344,10 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr,
expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
}
}
- if (expr_log)
- expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is "
- "%s, summary %s **",
- expr_result.GetValue(), expr_result.GetSummary());
+ LLDB_LOGF(expr_log,
+ "** [SBTarget::EvaluateExpression] Expression result is "
+ "%s, summary %s **",
+ expr_result.GetValue(), expr_result.GetSummary());
return LLDB_RECORD_RESULT(expr_result);
}
diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp
index 85e9a6b47955..8d4930bf6edb 100644
--- a/source/API/SBThread.cpp
+++ b/source/API/SBThread.cpp
@@ -16,6 +16,7 @@
#include "lldb/API/SBFrame.h"
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBStructuredData.h"
#include "lldb/API/SBSymbolContext.h"
#include "lldb/API/SBThreadCollection.h"
#include "lldb/API/SBThreadPlan.h"
@@ -23,6 +24,7 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Symbol/CompileUnit.h"
@@ -965,9 +967,24 @@ SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) {
}
SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
+ bool resume_immediately) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
+ (const char *, bool), script_class_name,
+ resume_immediately);
+
+ lldb::SBStructuredData no_data;
+ return LLDB_RECORD_RESULT(
+ StepUsingScriptedThreadPlan(script_class_name,
+ no_data,
+ resume_immediately));
+}
+
+SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
+ SBStructuredData &args_data,
bool resume_immediately) {
LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
- (const char *, bool), script_class_name,
+ (const char *, lldb::SBStructuredData &, bool),
+ script_class_name, args_data,
resume_immediately);
SBError error;
@@ -982,8 +999,10 @@ SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
Thread *thread = exe_ctx.GetThreadPtr();
Status new_plan_status;
+ StructuredData::ObjectSP obj_sp = args_data.m_impl_up->GetObjectSP();
+
ThreadPlanSP new_plan_sp = thread->QueueThreadPlanForStepScripted(
- false, script_class_name, false, new_plan_status);
+ false, script_class_name, obj_sp, false, new_plan_status);
if (new_plan_status.Fail()) {
error.SetErrorString(new_plan_status.AsCString());
@@ -1460,6 +1479,8 @@ void RegisterMethods<SBThread>(Registry &R) {
(const char *));
LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
(const char *, bool));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
+ (const char *, SBStructuredData &, bool));
LLDB_REGISTER_METHOD(lldb::SBError, SBThread, JumpToLine,
(lldb::SBFileSpec &, uint32_t));
LLDB_REGISTER_METHOD(lldb::SBError, SBThread, ReturnFromFrame,
diff --git a/source/API/SBThreadPlan.cpp b/source/API/SBThreadPlan.cpp
index 8f6802fe9cef..eed4d1bfb9c4 100644
--- a/source/API/SBThreadPlan.cpp
+++ b/source/API/SBThreadPlan.cpp
@@ -11,10 +11,12 @@
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBStructuredData.h"
#include "lldb/API/SBSymbolContext.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -67,7 +69,20 @@ SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name) {
Thread *thread = sb_thread.get();
if (thread)
- m_opaque_sp = std::make_shared<ThreadPlanPython>(*thread, class_name);
+ m_opaque_sp = std::make_shared<ThreadPlanPython>(*thread, class_name,
+ nullptr);
+}
+
+SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name,
+ lldb::SBStructuredData &args_data) {
+ LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *,
+ SBStructuredData &),
+ sb_thread, class_name, args_data);
+
+ Thread *thread = sb_thread.get();
+ if (thread)
+ m_opaque_sp = std::make_shared<ThreadPlanPython>(*thread, class_name,
+ args_data.m_impl_up.get());
}
// Assignment operator
@@ -368,9 +383,35 @@ SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
if (m_opaque_sp) {
Status plan_status;
+ StructuredData::ObjectSP empty_args;
SBThreadPlan plan =
SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepScripted(
- false, script_class_name, false, plan_status));
+ false, script_class_name, empty_args, false, plan_status));
+
+ if (plan_status.Fail())
+ error.SetErrorString(plan_status.AsCString());
+
+ return LLDB_RECORD_RESULT(plan);
+ } else {
+ return LLDB_RECORD_RESULT(SBThreadPlan());
+ }
+}
+
+SBThreadPlan
+SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
+ lldb::SBStructuredData &args_data,
+ SBError &error) {
+ LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepScripted,
+ (const char *, lldb::SBStructuredData &, lldb::SBError &),
+ script_class_name, args_data, error);
+
+ if (m_opaque_sp) {
+ Status plan_status;
+ StructuredData::ObjectSP args_obj = args_data.m_impl_up->GetObjectSP();
+ SBThreadPlan plan =
+ SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepScripted(
+ false, script_class_name, args_obj, false, plan_status));
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
@@ -390,6 +431,8 @@ void RegisterMethods<SBThreadPlan>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &));
LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &));
LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *));
+ LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *,
+ lldb::SBStructuredData &));
LLDB_REGISTER_METHOD(const lldb::SBThreadPlan &,
SBThreadPlan, operator=,(const lldb::SBThreadPlan &));
LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, IsValid, ());
@@ -433,6 +476,10 @@ void RegisterMethods<SBThreadPlan>(Registry &R) {
LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
QueueThreadPlanForStepScripted,
(const char *, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepScripted,
+ (const char *, lldb::SBStructuredData &,
+ lldb::SBError &));
}
}
diff --git a/source/API/SBType.cpp b/source/API/SBType.cpp
index 5402128b3fae..8efc701a79fb 100644
--- a/source/API/SBType.cpp
+++ b/source/API/SBType.cpp
@@ -799,7 +799,7 @@ const char *SBTypeMemberFunction::GetDemangledName() {
if (m_opaque_sp) {
ConstString mangled_str = m_opaque_sp->GetMangledName();
if (mangled_str) {
- Mangled mangled(mangled_str, true);
+ Mangled mangled(mangled_str);
return mangled.GetDemangledName(mangled.GuessLanguage()).GetCString();
}
}
diff --git a/source/API/SBTypeCategory.cpp b/source/API/SBTypeCategory.cpp
index 43d5a3ab140f..1e4496575098 100644
--- a/source/API/SBTypeCategory.cpp
+++ b/source/API/SBTypeCategory.cpp
@@ -364,8 +364,8 @@ bool SBTypeCategory::AddTypeFormat(SBTypeNameSpecifier type_name,
if (type_name.IsRegex())
m_opaque_sp->GetRegexTypeFormatsContainer()->Add(
- lldb::RegularExpressionSP(new RegularExpression(
- llvm::StringRef::withNullAsEmpty(type_name.GetName()))),
+ RegularExpression(
+ llvm::StringRef::withNullAsEmpty(type_name.GetName())),
format.GetSP());
else
m_opaque_sp->GetTypeFormatsContainer()->Add(
@@ -443,8 +443,8 @@ bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name,
if (type_name.IsRegex())
m_opaque_sp->GetRegexTypeSummariesContainer()->Add(
- lldb::RegularExpressionSP(new RegularExpression(
- llvm::StringRef::withNullAsEmpty(type_name.GetName()))),
+ RegularExpression(
+ llvm::StringRef::withNullAsEmpty(type_name.GetName())),
summary.GetSP());
else
m_opaque_sp->GetTypeSummariesContainer()->Add(
@@ -488,8 +488,8 @@ bool SBTypeCategory::AddTypeFilter(SBTypeNameSpecifier type_name,
if (type_name.IsRegex())
m_opaque_sp->GetRegexTypeFiltersContainer()->Add(
- lldb::RegularExpressionSP(new RegularExpression(
- llvm::StringRef::withNullAsEmpty(type_name.GetName()))),
+ RegularExpression(
+ llvm::StringRef::withNullAsEmpty(type_name.GetName())),
filter.GetSP());
else
m_opaque_sp->GetTypeFiltersContainer()->Add(
@@ -567,8 +567,8 @@ bool SBTypeCategory::AddTypeSynthetic(SBTypeNameSpecifier type_name,
if (type_name.IsRegex())
m_opaque_sp->GetRegexTypeSyntheticsContainer()->Add(
- lldb::RegularExpressionSP(new RegularExpression(
- llvm::StringRef::withNullAsEmpty(type_name.GetName()))),
+ RegularExpression(
+ llvm::StringRef::withNullAsEmpty(type_name.GetName())),
synth.GetSP());
else
m_opaque_sp->GetTypeSyntheticsContainer()->Add(
diff --git a/source/API/SystemInitializerFull.cpp b/source/API/SystemInitializerFull.cpp
index e7f2206b9a59..0acc496ff879 100644
--- a/source/API/SystemInitializerFull.cpp
+++ b/source/API/SystemInitializerFull.cpp
@@ -24,6 +24,7 @@
#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
#include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h"
#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
+#include "Plugins/ABI/SysV-arc/ABISysV_arc.h"
#include "Plugins/ABI/SysV-arm/ABISysV_arm.h"
#include "Plugins/ABI/SysV-arm64/ABISysV_arm64.h"
#include "Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h"
@@ -131,6 +132,39 @@ SystemInitializerFull::SystemInitializerFull() {}
SystemInitializerFull::~SystemInitializerFull() {}
+#define LLDB_PROCESS_AArch64(op) \
+ ABIMacOSX_arm64::op(); \
+ ABISysV_arm64::op();
+#define LLDB_PROCESS_ARM(op) \
+ ABIMacOSX_arm::op(); \
+ ABISysV_arm::op();
+#define LLDB_PROCESS_ARC(op) \
+ ABISysV_arc::op();
+#define LLDB_PROCESS_Hexagon(op) ABISysV_hexagon::op();
+#define LLDB_PROCESS_Mips(op) \
+ ABISysV_mips::op(); \
+ ABISysV_mips64::op();
+#define LLDB_PROCESS_PowerPC(op) \
+ ABISysV_ppc::op(); \
+ ABISysV_ppc64::op();
+#define LLDB_PROCESS_SystemZ(op) ABISysV_s390x::op();
+#define LLDB_PROCESS_X86(op) \
+ ABIMacOSX_i386::op(); \
+ ABISysV_i386::op(); \
+ ABISysV_x86_64::op(); \
+ ABIWindows_x86_64::op();
+
+#define LLDB_PROCESS_AMDGPU(op)
+#define LLDB_PROCESS_AVR(op)
+#define LLDB_PROCESS_BPF(op)
+#define LLDB_PROCESS_Lanai(op)
+#define LLDB_PROCESS_MSP430(op)
+#define LLDB_PROCESS_NVPTX(op)
+#define LLDB_PROCESS_RISCV(op)
+#define LLDB_PROCESS_Sparc(op)
+#define LLDB_PROCESS_WebAssembly(op)
+#define LLDB_PROCESS_XCore(op)
+
llvm::Error SystemInitializerFull::Initialize() {
if (auto e = SystemInitializerCommon::Initialize())
return e;
@@ -174,20 +208,8 @@ llvm::Error SystemInitializerFull::Initialize() {
ClangASTContext::Initialize();
- ABIMacOSX_i386::Initialize();
- ABIMacOSX_arm::Initialize();
- ABIMacOSX_arm64::Initialize();
- ABISysV_arm::Initialize();
- ABISysV_arm64::Initialize();
- ABISysV_hexagon::Initialize();
- ABISysV_i386::Initialize();
- ABISysV_x86_64::Initialize();
- ABISysV_ppc::Initialize();
- ABISysV_ppc64::Initialize();
- ABISysV_mips::Initialize();
- ABISysV_mips64::Initialize();
- ABISysV_s390x::Initialize();
- ABIWindows_x86_64::Initialize();
+#define LLVM_TARGET(t) LLDB_PROCESS_ ## t(Initialize)
+#include "llvm/Config/Targets.def"
ArchitectureArm::Initialize();
ArchitectureMips::Initialize();
@@ -288,20 +310,9 @@ void SystemInitializerFull::Terminate() {
ArchitectureMips::Terminate();
ArchitecturePPC64::Terminate();
- ABIMacOSX_i386::Terminate();
- ABIMacOSX_arm::Terminate();
- ABIMacOSX_arm64::Terminate();
- ABISysV_arm::Terminate();
- ABISysV_arm64::Terminate();
- ABISysV_hexagon::Terminate();
- ABISysV_i386::Terminate();
- ABISysV_x86_64::Terminate();
- ABISysV_ppc::Terminate();
- ABISysV_ppc64::Terminate();
- ABISysV_mips::Terminate();
- ABISysV_mips64::Terminate();
- ABISysV_s390x::Terminate();
- ABIWindows_x86_64::Terminate();
+#define LLVM_TARGET(t) LLDB_PROCESS_ ## t(Terminate)
+#include "llvm/Config/Targets.def"
+
DisassemblerLLVMC::Terminate();
JITLoaderGDB::Terminate();
diff --git a/source/API/Utils.h b/source/API/Utils.h
index b1975e5421dd..ed81534d2d12 100644
--- a/source/API/Utils.h
+++ b/source/API/Utils.h
@@ -16,7 +16,7 @@ namespace lldb_private {
template <typename T> std::unique_ptr<T> clone(const std::unique_ptr<T> &src) {
if (src)
- return llvm::make_unique<T>(*src);
+ return std::make_unique<T>(*src);
return nullptr;
}