summaryrefslogtreecommitdiff
path: root/lldb/source/API
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/API')
-rw-r--r--lldb/source/API/SBBreakpoint.cpp34
-rw-r--r--lldb/source/API/SBBreakpointLocation.cpp31
-rw-r--r--lldb/source/API/SBBreakpointName.cpp37
-rw-r--r--lldb/source/API/SBCompileUnit.cpp4
-rw-r--r--lldb/source/API/SBDebugger.cpp54
-rw-r--r--lldb/source/API/SBEvent.cpp2
-rw-r--r--lldb/source/API/SBFile.cpp11
-rw-r--r--lldb/source/API/SBFileSpec.cpp2
-rw-r--r--lldb/source/API/SBFrame.cpp4
-rw-r--r--lldb/source/API/SBHostOS.cpp7
-rw-r--r--lldb/source/API/SBModule.cpp18
-rw-r--r--lldb/source/API/SBReproducer.cpp40
-rw-r--r--lldb/source/API/SBTarget.cpp35
-rw-r--r--lldb/source/API/SBThread.cpp9
-rw-r--r--lldb/source/API/SBType.cpp6
-rw-r--r--lldb/source/API/SBValue.cpp20
-rw-r--r--lldb/source/API/SystemInitializerFull.cpp18
17 files changed, 213 insertions, 119 deletions
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index 45eaea6b61819..8159b851d58cc 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -14,6 +14,7 @@
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBStringList.h"
+#include "lldb/API/SBStructuredData.h"
#include "lldb/API/SBThread.h"
#include "lldb/Breakpoint/Breakpoint.h"
@@ -25,6 +26,7 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Target/Process.h"
@@ -590,22 +592,38 @@ void SBBreakpoint ::SetCallback(SBBreakpointHitCallback callback, void *baton) {
}
void SBBreakpoint::SetScriptCallbackFunction(
- const char *callback_function_name) {
- LLDB_RECORD_METHOD(void, SBBreakpoint, SetScriptCallbackFunction,
- (const char *), callback_function_name);
-
+ const char *callback_function_name) {
+LLDB_RECORD_METHOD(void, SBBreakpoint, SetScriptCallbackFunction,
+ (const char *), callback_function_name);
+ SBStructuredData empty_args;
+ SetScriptCallbackFunction(callback_function_name, empty_args);
+}
+
+SBError SBBreakpoint::SetScriptCallbackFunction(
+ const char *callback_function_name,
+ SBStructuredData &extra_args) {
+ LLDB_RECORD_METHOD(SBError, SBBreakpoint, SetScriptCallbackFunction,
+ (const char *, SBStructuredData &), callback_function_name, extra_args);
+ SBError sb_error;
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
+ Status error;
std::lock_guard<std::recursive_mutex> guard(
bkpt_sp->GetTarget().GetAPIMutex());
BreakpointOptions *bp_options = bkpt_sp->GetOptions();
- bkpt_sp->GetTarget()
+ error = bkpt_sp->GetTarget()
.GetDebugger()
.GetScriptInterpreter()
->SetBreakpointCommandCallbackFunction(bp_options,
- callback_function_name);
- }
+ callback_function_name,
+ extra_args.m_impl_up
+ ->GetObjectSP());
+ sb_error.SetError(error);
+ } else
+ sb_error.SetErrorString("invalid breakpoint");
+
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) {
@@ -992,6 +1010,8 @@ void RegisterMethods<SBBreakpoint>(Registry &R) {
(lldb::SBAddress &));
LLDB_REGISTER_METHOD(void, SBBreakpoint, SetScriptCallbackFunction,
(const char *));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackFunction,
+ (const char *, SBStructuredData &));
LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody,
(const char *));
LLDB_REGISTER_METHOD(bool, SBBreakpoint, AddName, (const char *));
diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp
index 640545f55ef97..2b62a69a21ef4 100644
--- a/lldb/source/API/SBBreakpointLocation.cpp
+++ b/lldb/source/API/SBBreakpointLocation.cpp
@@ -12,12 +12,14 @@
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBStructuredData.h"
#include "lldb/API/SBStringList.h"
#include "lldb/Breakpoint/Breakpoint.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/Interpreter/ScriptInterpreter.h"
#include "lldb/Target/Target.h"
@@ -207,23 +209,38 @@ bool SBBreakpointLocation::GetAutoContinue() {
}
void SBBreakpointLocation::SetScriptCallbackFunction(
- const char *callback_function_name) {
- LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetScriptCallbackFunction,
- (const char *), callback_function_name);
+ const char *callback_function_name) {
+LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetScriptCallbackFunction,
+ (const char *), callback_function_name);
+}
+SBError SBBreakpointLocation::SetScriptCallbackFunction(
+ const char *callback_function_name,
+ SBStructuredData &extra_args) {
+ LLDB_RECORD_METHOD(SBError, SBBreakpointLocation, SetScriptCallbackFunction,
+ (const char *, SBStructuredData &),
+ callback_function_name, extra_args);
+ SBError sb_error;
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
+ Status error;
std::lock_guard<std::recursive_mutex> guard(
loc_sp->GetTarget().GetAPIMutex());
BreakpointOptions *bp_options = loc_sp->GetLocationOptions();
- loc_sp->GetBreakpoint()
+ error = loc_sp->GetBreakpoint()
.GetTarget()
.GetDebugger()
.GetScriptInterpreter()
->SetBreakpointCommandCallbackFunction(bp_options,
- callback_function_name);
- }
+ callback_function_name,
+ extra_args.m_impl_up
+ ->GetObjectSP());
+ sb_error.SetError(error);
+ } else
+ sb_error.SetErrorString("invalid breakpoint");
+
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError
@@ -482,6 +499,8 @@ void RegisterMethods<SBBreakpointLocation>(Registry &R) {
LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, GetAutoContinue, ());
LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetScriptCallbackFunction,
(const char *));
+ LLDB_REGISTER_METHOD(SBError, SBBreakpointLocation, SetScriptCallbackFunction,
+ (const char *, SBStructuredData &));
LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpointLocation,
SetScriptCallbackBody, (const char *));
LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetCommandLineCommands,
diff --git a/lldb/source/API/SBBreakpointName.cpp b/lldb/source/API/SBBreakpointName.cpp
index 1c794fca8ca5a..5bd7732ebb60b 100644
--- a/lldb/source/API/SBBreakpointName.cpp
+++ b/lldb/source/API/SBBreakpointName.cpp
@@ -12,11 +12,13 @@
#include "lldb/API/SBError.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBStringList.h"
+#include "lldb/API/SBStructuredData.h"
#include "lldb/API/SBTarget.h"
#include "lldb/Breakpoint/BreakpointName.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Debugger.h"
+#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Target/Target.h"
@@ -565,24 +567,41 @@ void SBBreakpointName::SetCallback(SBBreakpointHitCallback callback,
}
void SBBreakpointName::SetScriptCallbackFunction(
- const char *callback_function_name) {
- LLDB_RECORD_METHOD(void, SBBreakpointName, SetScriptCallbackFunction,
- (const char *), callback_function_name);
-
+ const char *callback_function_name) {
+LLDB_RECORD_METHOD(void, SBBreakpointName, SetScriptCallbackFunction,
+ (const char *), callback_function_name);
+ SBStructuredData empty_args;
+ SetScriptCallbackFunction(callback_function_name, empty_args);
+}
+
+SBError SBBreakpointName::SetScriptCallbackFunction(
+ const char *callback_function_name,
+ SBStructuredData &extra_args) {
+ LLDB_RECORD_METHOD(SBError, SBBreakpointName, SetScriptCallbackFunction,
+ (const char *, SBStructuredData &),
+ callback_function_name, extra_args);
+ SBError sb_error;
BreakpointName *bp_name = GetBreakpointName();
- if (!bp_name)
- return;
+ if (!bp_name) {
+ sb_error.SetErrorString("unrecognized breakpoint name");
+ return LLDB_RECORD_RESULT(sb_error);
+ }
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
BreakpointOptions &bp_options = bp_name->GetOptions();
- m_impl_up->GetTarget()
+ Status error;
+ error = m_impl_up->GetTarget()
->GetDebugger()
.GetScriptInterpreter()
->SetBreakpointCommandCallbackFunction(&bp_options,
- callback_function_name);
+ callback_function_name,
+ extra_args.m_impl_up
+ ->GetObjectSP());
+ sb_error.SetError(error);
UpdateName(*bp_name);
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError
@@ -728,6 +747,8 @@ void RegisterMethods<SBBreakpointName>(Registry &R) {
(lldb::SBStream &));
LLDB_REGISTER_METHOD(void, SBBreakpointName, SetScriptCallbackFunction,
(const char *));
+ LLDB_REGISTER_METHOD(SBError, SBBreakpointName, SetScriptCallbackFunction,
+ (const char *, SBStructuredData &));
LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpointName, SetScriptCallbackBody,
(const char *));
LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, GetAllowList, ());
diff --git a/lldb/source/API/SBCompileUnit.cpp b/lldb/source/API/SBCompileUnit.cpp
index 581bda3635073..d52040d850a95 100644
--- a/lldb/source/API/SBCompileUnit.cpp
+++ b/lldb/source/API/SBCompileUnit.cpp
@@ -50,7 +50,7 @@ SBFileSpec SBCompileUnit::GetFileSpec() const {
SBFileSpec file_spec;
if (m_opaque_ptr)
- file_spec.SetFileSpec(*m_opaque_ptr);
+ file_spec.SetFileSpec(m_opaque_ptr->GetPrimaryFile());
return LLDB_RECORD_RESULT(file_spec);
}
@@ -106,7 +106,7 @@ uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line,
if (inline_file_spec && inline_file_spec->IsValid())
file_spec = inline_file_spec->ref();
else
- file_spec = *m_opaque_ptr;
+ file_spec = m_opaque_ptr->GetPrimaryFile();
index = m_opaque_ptr->FindLineEntry(
start_idx, line, inline_file_spec ? inline_file_spec->get() : nullptr,
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 82dc60489008c..b7ac8047f8e5d 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -40,6 +40,7 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/Host/Config.h"
#include "lldb/Host/XML.h"
#include "lldb/Initialization/SystemLifetimeManager.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -294,7 +295,7 @@ void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) {
SBError SBDebugger::SetInputFile(FileSP file_sp) {
LLDB_RECORD_METHOD(SBError, SBDebugger, SetInputFile, (FileSP), file_sp);
- return SetInputFile(SBFile(file_sp));
+ return LLDB_RECORD_RESULT(SetInputFile(SBFile(file_sp)));
}
// Shouldn't really be settable after initialization as this could cause lots
@@ -306,7 +307,7 @@ SBError SBDebugger::SetInputFile(SBFile file) {
SBError error;
if (!m_opaque_sp) {
error.ref().SetErrorString("invalid debugger");
- return error;
+ return LLDB_RECORD_RESULT(error);
}
repro::DataRecorder *recorder = nullptr;
@@ -315,8 +316,9 @@ SBError SBDebugger::SetInputFile(SBFile file) {
FileSP file_sp = file.m_opaque_sp;
- static std::unique_ptr<repro::CommandLoader> loader =
- repro::CommandLoader::Create(repro::Reproducer::Instance().GetLoader());
+ static std::unique_ptr<repro::MultiLoader<repro::CommandProvider>> loader =
+ repro::MultiLoader<repro::CommandProvider>::Create(
+ repro::Reproducer::Instance().GetLoader());
if (loader) {
llvm::Optional<std::string> nextfile = loader->GetNextFile();
FILE *fh = nextfile ? FileSystem::Instance().Fopen(nextfile->c_str(), "r")
@@ -330,16 +332,16 @@ SBError SBDebugger::SetInputFile(SBFile file) {
if (!file_sp || !file_sp->IsValid()) {
error.ref().SetErrorString("invalid file");
- return error;
+ return LLDB_RECORD_RESULT(error);
}
m_opaque_sp->SetInputFile(file_sp, recorder);
- return error;
+ return LLDB_RECORD_RESULT(error);
}
SBError SBDebugger::SetOutputFile(FileSP file_sp) {
LLDB_RECORD_METHOD(SBError, SBDebugger, SetOutputFile, (FileSP), file_sp);
- return SetOutputFile(SBFile(file_sp));
+ return LLDB_RECORD_RESULT(SetOutputFile(SBFile(file_sp)));
}
void SBDebugger::SetOutputFileHandle(FILE *fh, bool transfer_ownership) {
@@ -353,14 +355,14 @@ SBError SBDebugger::SetOutputFile(SBFile file) {
SBError error;
if (!m_opaque_sp) {
error.ref().SetErrorString("invalid debugger");
- return error;
+ return LLDB_RECORD_RESULT(error);
}
if (!file) {
error.ref().SetErrorString("invalid file");
- return error;
+ return LLDB_RECORD_RESULT(error);
}
m_opaque_sp->SetOutputFile(file.m_opaque_sp);
- return error;
+ return LLDB_RECORD_RESULT(error);
}
void SBDebugger::SetErrorFileHandle(FILE *fh, bool transfer_ownership) {
@@ -371,7 +373,7 @@ void SBDebugger::SetErrorFileHandle(FILE *fh, bool transfer_ownership) {
SBError SBDebugger::SetErrorFile(FileSP file_sp) {
LLDB_RECORD_METHOD(SBError, SBDebugger, SetErrorFile, (FileSP), file_sp);
- return SetErrorFile(SBFile(file_sp));
+ return LLDB_RECORD_RESULT(SetErrorFile(SBFile(file_sp)));
}
SBError SBDebugger::SetErrorFile(SBFile file) {
@@ -379,14 +381,14 @@ SBError SBDebugger::SetErrorFile(SBFile file) {
SBError error;
if (!m_opaque_sp) {
error.ref().SetErrorString("invalid debugger");
- return error;
+ return LLDB_RECORD_RESULT(error);
}
if (!file) {
error.ref().SetErrorString("invalid file");
- return error;
+ return LLDB_RECORD_RESULT(error);
}
m_opaque_sp->SetErrorFile(file.m_opaque_sp);
- return error;
+ return LLDB_RECORD_RESULT(error);
}
FILE *SBDebugger::GetInputFileHandle() {
@@ -395,7 +397,7 @@ FILE *SBDebugger::GetInputFileHandle() {
File &file_sp = m_opaque_sp->GetInputFile();
return LLDB_RECORD_RESULT(file_sp.GetStream());
}
- return nullptr;
+ return LLDB_RECORD_RESULT(nullptr);
}
SBFile SBDebugger::GetInputFile() {
@@ -412,7 +414,7 @@ FILE *SBDebugger::GetOutputFileHandle() {
StreamFile &stream_file = m_opaque_sp->GetOutputStream();
return LLDB_RECORD_RESULT(stream_file.GetFile().GetStream());
}
- return nullptr;
+ return LLDB_RECORD_RESULT(nullptr);
}
SBFile SBDebugger::GetOutputFile() {
@@ -431,7 +433,7 @@ FILE *SBDebugger::GetErrorFileHandle() {
StreamFile &stream_file = m_opaque_sp->GetErrorStream();
return LLDB_RECORD_RESULT(stream_file.GetFile().GetStream());
}
- return nullptr;
+ return LLDB_RECORD_RESULT(nullptr);
}
SBFile SBDebugger::GetErrorFile() {
@@ -681,13 +683,21 @@ SBStructuredData SBDebugger::GetBuildConfiguration() {
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,
+ *config_up, "curses", LLDB_ENABLE_CURSES,
"A boolean value that indicates if curses support is enabled in LLDB");
+ AddBoolConfigEntry(
+ *config_up, "editline", LLDB_ENABLE_LIBEDIT,
+ "A boolean value that indicates if editline support is enabled in LLDB");
+ AddBoolConfigEntry(
+ *config_up, "lzma", LLDB_ENABLE_LZMA,
+ "A boolean value that indicates if lzma support is enabled in LLDB");
+ AddBoolConfigEntry(
+ *config_up, "python", LLDB_ENABLE_PYTHON,
+ "A boolean value that indicates if python support is enabled in LLDB");
+ AddBoolConfigEntry(
+ *config_up, "lua", LLDB_ENABLE_LUA,
+ "A boolean value that indicates if lua support is enabled in LLDB");
AddLLVMTargets(*config_up);
SBStructuredData data;
diff --git a/lldb/source/API/SBEvent.cpp b/lldb/source/API/SBEvent.cpp
index 75ca2830df9fb..fb2ad10ddcf92 100644
--- a/lldb/source/API/SBEvent.cpp
+++ b/lldb/source/API/SBEvent.cpp
@@ -175,7 +175,7 @@ const char *SBEvent::GetCStringFromEvent(const SBEvent &event) {
LLDB_RECORD_STATIC_METHOD(const char *, SBEvent, GetCStringFromEvent,
(const lldb::SBEvent &), event);
- return reinterpret_cast<const char *>(
+ return static_cast<const char *>(
EventDataBytes::GetBytesFromEvent(event.get()));
}
diff --git a/lldb/source/API/SBFile.cpp b/lldb/source/API/SBFile.cpp
index f5a38efe4a779..277402f31abf7 100644
--- a/lldb/source/API/SBFile.cpp
+++ b/lldb/source/API/SBFile.cpp
@@ -100,24 +100,27 @@ SBError SBFile::Close() {
SBFile::operator bool() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFile, operator bool);
- return LLDB_RECORD_RESULT(IsValid());
+ return IsValid();
}
bool SBFile::operator!() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFile, operator!);
- return LLDB_RECORD_RESULT(!IsValid());
+ return !IsValid();
}
FileSP SBFile::GetFile() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(FileSP, SBFile, GetFile);
- return m_opaque_sp;
+ return LLDB_RECORD_RESULT(m_opaque_sp);
}
namespace lldb_private {
namespace repro {
template <> void RegisterMethods<SBFile>(Registry &R) {
-
+ LLDB_REGISTER_CONSTRUCTOR(SBFile, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBFile, (FileSP));
+ LLDB_REGISTER_CONSTRUCTOR(SBFile, (FILE *, bool));
+ LLDB_REGISTER_CONSTRUCTOR(SBFile, (int, const char *, bool));
LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Flush, ());
LLDB_REGISTER_METHOD_CONST(bool, SBFile, IsValid, ());
LLDB_REGISTER_METHOD_CONST(bool, SBFile, operator bool,());
diff --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp
index 2f910b9ba294e..2e7eba42bc909 100644
--- a/lldb/source/API/SBFileSpec.cpp
+++ b/lldb/source/API/SBFileSpec.cpp
@@ -143,7 +143,7 @@ void SBFileSpec::SetDirectory(const char *directory) {
}
uint32_t SBFileSpec::GetPath(char *dst_path, size_t dst_len) const {
- LLDB_RECORD_METHOD_CONST(uint32_t, SBFileSpec, GetPath, (char *, size_t),
+ LLDB_RECORD_DUMMY(uint32_t, SBFileSpec, GetPath, (char *, size_t),
dst_path, dst_len);
uint32_t result = m_opaque_up->GetPath(dst_path, dst_len);
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index c0e272e1bcd4f..af42be9ac75e5 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/lldb/source/API/SBFrame.cpp
@@ -831,14 +831,12 @@ SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) {
if (stop_locker.TryLock(&process->GetRunLock())) {
frame = exe_ctx.GetFramePtr();
if (frame) {
- size_t i;
VariableList *variable_list = nullptr;
variable_list = frame->GetVariableList(true);
if (variable_list) {
const size_t num_variables = variable_list->GetSize();
if (num_variables) {
- for (i = 0; i < num_variables; ++i) {
- VariableSP variable_sp(variable_list->GetVariableAtIndex(i));
+ for (const VariableSP &variable_sp : *variable_list) {
if (variable_sp) {
bool add_variable = false;
switch (variable_sp->GetScope()) {
diff --git a/lldb/source/API/SBHostOS.cpp b/lldb/source/API/SBHostOS.cpp
index c3c92e68140d4..6ac8717237e71 100644
--- a/lldb/source/API/SBHostOS.cpp
+++ b/lldb/source/API/SBHostOS.cpp
@@ -6,9 +6,10 @@
//
//===----------------------------------------------------------------------===//
+#include "lldb/API/SBHostOS.h"
#include "SBReproducerPrivate.h"
#include "lldb/API/SBError.h"
-#include "lldb/API/SBHostOS.h"
+#include "lldb/Host/Config.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
@@ -18,7 +19,7 @@
#include "lldb/Utility/FileSpec.h"
#include "Plugins/ExpressionParser/Clang/ClangHost.h"
-#ifndef LLDB_DISABLE_PYTHON
+#if LLDB_ENABLE_PYTHON
#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
#endif
@@ -60,7 +61,7 @@ SBFileSpec SBHostOS::GetLLDBPath(lldb::PathType path_type) {
fspec = HostInfo::GetHeaderDir();
break;
case ePathTypePythonDir:
-#ifndef LLDB_DISABLE_PYTHON
+#if LLDB_ENABLE_PYTHON
fspec = ScriptInterpreterPython::GetPythonDir();
#endif
break;
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 6cc6d2628ace0..4e9dfb0c1e62e 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -245,7 +245,7 @@ bool SBModule::GetDescription(SBStream &description) {
ModuleSP module_sp(GetSP());
if (module_sp) {
- module_sp->GetDescription(&strm);
+ module_sp->GetDescription(strm.AsRawOstream());
} else
strm.PutCString("No value");
@@ -419,16 +419,12 @@ SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name,
VariableList 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;
- TargetSP target_sp(target.GetSP());
- valobj_sp = ValueObjectVariable::Create(
- target_sp.get(), variable_list.GetVariableAtIndex(i));
- if (valobj_sp)
- sb_value_list.Append(SBValue(valobj_sp));
- }
+ for (const VariableSP &var_sp : variable_list) {
+ lldb::ValueObjectSP valobj_sp;
+ TargetSP target_sp(target.GetSP());
+ valobj_sp = ValueObjectVariable::Create(target_sp.get(), var_sp);
+ if (valobj_sp)
+ sb_value_list.Append(SBValue(valobj_sp));
}
}
diff --git a/lldb/source/API/SBReproducer.cpp b/lldb/source/API/SBReproducer.cpp
index 6e11b2c6366f4..3d2de07274448 100644
--- a/lldb/source/API/SBReproducer.cpp
+++ b/lldb/source/API/SBReproducer.cpp
@@ -22,15 +22,15 @@
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBHostOS.h"
#include "lldb/API/SBReproducer.h"
-
#include "lldb/Host/FileSystem.h"
+#include "lldb/lldb-private.h"
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::repro;
SBRegistry::SBRegistry() {
- Registry& R = *this;
+ Registry &R = *this;
RegisterMethods<SBAddress>(R);
RegisterMethods<SBAttachInfo>(R);
@@ -125,6 +125,10 @@ const char *SBReproducer::Capture(const char *path) {
}
const char *SBReproducer::Replay(const char *path) {
+ return SBReproducer::Replay(path, false);
+}
+
+const char *SBReproducer::Replay(const char *path, bool skip_version_check) {
static std::string error;
if (auto e = Reproducer::Initialize(ReproducerMode::Replay, FileSpec(path))) {
error = llvm::toString(std::move(e));
@@ -137,6 +141,22 @@ const char *SBReproducer::Replay(const char *path) {
return error.c_str();
}
+ if (!skip_version_check) {
+ llvm::Expected<std::string> version = loader->LoadBuffer<VersionProvider>();
+ if (!version) {
+ error = llvm::toString(version.takeError());
+ return error.c_str();
+ }
+ if (lldb_private::GetVersion() != llvm::StringRef(*version).rtrim()) {
+ error = "reproducer capture and replay version don't match:\n";
+ error.append("reproducer captured with:\n");
+ error.append(*version);
+ error.append("reproducer replayed with:\n");
+ error.append(lldb_private::GetVersion());
+ return error.c_str();
+ }
+ }
+
FileSpec file = loader->GetFile<SBProvider::Info>();
if (!file) {
error = "unable to get replay data from reproducer.";
@@ -149,6 +169,22 @@ const char *SBReproducer::Replay(const char *path) {
return nullptr;
}
+bool SBReproducer::Generate() {
+ auto &r = Reproducer::Instance();
+ if (auto generator = r.GetGenerator()) {
+ generator->Keep();
+ return true;
+ }
+ return false;
+}
+
+const char *SBReproducer::GetPath() {
+ static std::string path;
+ auto &r = Reproducer::Instance();
+ path = r.GetReproducerPath().GetCString();
+ return path.c_str();
+}
+
char lldb_private::repro::SBProvider::ID = 0;
const char *SBProvider::Info::name = "sbapi";
const char *SBProvider::Info::file = "sbapi.bin";
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 1d13087eef693..312e4df758631 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -36,7 +36,6 @@
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Core/STLUtils.h"
#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/StructuredDataImpl.h"
@@ -1177,12 +1176,15 @@ bool SBTarget::FindBreakpointsByName(const char *name,
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- BreakpointList bkpt_list(false);
- bool is_valid =
- target_sp->GetBreakpointList().FindBreakpointsByName(name, bkpt_list);
- if (!is_valid)
+ llvm::Expected<std::vector<BreakpointSP>> expected_vector =
+ target_sp->GetBreakpointList().FindBreakpointsByName(name);
+ if (!expected_vector) {
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS),
+ "invalid breakpoint name: {}",
+ llvm::toString(expected_vector.takeError()));
return false;
- for (BreakpointSP bkpt_sp : bkpt_list.Breakpoints()) {
+ }
+ for (BreakpointSP bkpt_sp : *expected_vector) {
bkpts.AppendByID(bkpt_sp->GetID());
}
}
@@ -1598,7 +1600,7 @@ lldb::SBModule SBTarget::AddModule(const SBModuleSpec &module_spec) {
lldb::SBModule sb_module;
TargetSP target_sp(GetSP());
if (target_sp)
- sb_module.SetSP(target_sp->GetOrCreateModule(*module_spec.m_opaque_up,
+ sb_module.SetSP(target_sp->GetOrCreateModule(*module_spec.m_opaque_up,
true /* notify */));
return LLDB_RECORD_RESULT(sb_module);
}
@@ -1930,14 +1932,13 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
VariableList variable_list;
target_sp->GetImages().FindGlobalVariables(ConstString(name), max_matches,
variable_list);
- const uint32_t match_count = variable_list.GetSize();
- if (match_count > 0) {
+ if (!variable_list.Empty()) {
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
if (exe_scope == nullptr)
exe_scope = target_sp.get();
- for (uint32_t i = 0; i < match_count; ++i) {
- lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
- exe_scope, variable_list.GetVariableAtIndex(i)));
+ for (const VariableSP &var_sp : variable_list) {
+ lldb::ValueObjectSP valobj_sp(
+ ValueObjectVariable::Create(exe_scope, var_sp));
if (valobj_sp)
sb_value_list.Append(SBValue(valobj_sp));
}
@@ -1962,7 +1963,6 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
VariableList variable_list;
std::string regexstr;
- uint32_t match_count;
switch (matchtype) {
case eMatchTypeNormal:
target_sp->GetImages().FindGlobalVariables(ConstString(name), max_matches,
@@ -1978,14 +1978,13 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
max_matches, variable_list);
break;
}
- match_count = variable_list.GetSize();
- if (match_count > 0) {
+ if (!variable_list.Empty()) {
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
if (exe_scope == nullptr)
exe_scope = target_sp.get();
- for (uint32_t i = 0; i < match_count; ++i) {
- lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
- exe_scope, variable_list.GetVariableAtIndex(i)));
+ for (const VariableSP &var_sp : variable_list) {
+ lldb::ValueObjectSP valobj_sp(
+ ValueObjectVariable::Create(exe_scope, var_sp));
if (valobj_sp)
sb_value_list.Append(SBValue(valobj_sp));
}
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index 8d4930bf6edb0..f7f748f568321 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -914,9 +914,10 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
const bool exact = false;
SymbolContextList sc_list;
- const uint32_t num_matches = frame_sc.comp_unit->ResolveSymbolContext(
- step_file_spec, line, check_inlines, exact, eSymbolContextLineEntry,
- sc_list);
+ frame_sc.comp_unit->ResolveSymbolContext(step_file_spec, line,
+ check_inlines, exact,
+ eSymbolContextLineEntry, sc_list);
+ const uint32_t num_matches = sc_list.GetSize();
if (num_matches > 0) {
SymbolContext sc;
for (uint32_t i = 0; i < num_matches; ++i) {
@@ -1036,7 +1037,7 @@ SBError SBThread::JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line) {
Thread *thread = exe_ctx.GetThreadPtr();
- Status err = thread->JumpToLine(file_spec.get(), line, true);
+ Status err = thread->JumpToLine(file_spec.ref(), line, true);
sb_error.SetError(err);
return LLDB_RECORD_RESULT(sb_error);
}
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 8efc701a79fb7..33b67ad4c0043 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -212,8 +212,10 @@ SBType SBType::GetArrayElementType() {
if (!IsValid())
return LLDB_RECORD_RESULT(SBType());
- return LLDB_RECORD_RESULT(SBType(TypeImplSP(
- new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayElementType()))));
+ CompilerType canonical_type =
+ m_opaque_sp->GetCompilerType(true).GetCanonicalType();
+ return LLDB_RECORD_RESULT(
+ SBType(TypeImplSP(new TypeImpl(canonical_type.GetArrayElementType()))));
}
SBType SBType::GetArrayType(uint64_t size) {
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 8383007635229..396a9d3ea10c4 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -391,25 +391,6 @@ const char *SBValue::GetObjectDescription() {
return cstr;
}
-const char *SBValue::GetTypeValidatorResult() {
- LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetTypeValidatorResult);
-
- const char *cstr = nullptr;
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp) {
- const auto &validation(value_sp->GetValidationStatus());
- if (TypeValidatorResult::Failure == validation.first) {
- if (validation.second.empty())
- cstr = "unknown error";
- else
- cstr = validation.second.c_str();
- }
- }
-
- return cstr;
-}
-
SBType SBValue::GetType() {
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBValue, GetType);
@@ -1585,7 +1566,6 @@ void RegisterMethods<SBValue>(Registry &R) {
LLDB_REGISTER_METHOD(const char *, SBValue, GetValue, ());
LLDB_REGISTER_METHOD(lldb::ValueType, SBValue, GetValueType, ());
LLDB_REGISTER_METHOD(const char *, SBValue, GetObjectDescription, ());
- LLDB_REGISTER_METHOD(const char *, SBValue, GetTypeValidatorResult, ());
LLDB_REGISTER_METHOD(lldb::SBType, SBValue, GetType, ());
LLDB_REGISTER_METHOD(bool, SBValue, GetValueDidChange, ());
LLDB_REGISTER_METHOD(const char *, SBValue, GetSummary, ());
diff --git a/lldb/source/API/SystemInitializerFull.cpp b/lldb/source/API/SystemInitializerFull.cpp
index 0acc496ff8796..06f1a6cd3b750 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -7,13 +7,17 @@
//===----------------------------------------------------------------------===//
#include "SystemInitializerFull.h"
-
#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/Host/Config.h"
-#if !defined(LLDB_DISABLE_PYTHON)
+#if LLDB_ENABLE_PYTHON
#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
#endif
+#if LLDB_ENABLE_LUA
+#include "Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h"
+#endif
+
#include "lldb/Core/Debugger.h"
#include "lldb/Host/Host.h"
#include "lldb/Initialization/SystemInitializerCommon.h"
@@ -179,14 +183,18 @@ llvm::Error SystemInitializerFull::Initialize() {
ScriptInterpreterNone::Initialize();
-#ifndef LLDB_DISABLE_PYTHON
+#if LLDB_ENABLE_PYTHON
OperatingSystemPython::Initialize();
#endif
-#if !defined(LLDB_DISABLE_PYTHON)
+#if LLDB_ENABLE_PYTHON
ScriptInterpreterPython::Initialize();
#endif
+#if LLDB_ENABLE_LUA
+ ScriptInterpreterLua::Initialize();
+#endif
+
platform_freebsd::PlatformFreeBSD::Initialize();
platform_linux::PlatformLinux::Initialize();
platform_netbsd::PlatformNetBSD::Initialize();
@@ -375,7 +383,7 @@ void SystemInitializerFull::Terminate() {
DynamicLoaderStatic::Terminate();
DynamicLoaderWindowsDYLD::Terminate();
-#ifndef LLDB_DISABLE_PYTHON
+#if LLDB_ENABLE_PYTHON
OperatingSystemPython::Terminate();
#endif