aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/API
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/API')
-rw-r--r--lldb/source/API/SBAddress.cpp14
-rw-r--r--lldb/source/API/SBBreakpoint.cpp30
-rw-r--r--lldb/source/API/SBBreakpointLocation.cpp8
-rw-r--r--lldb/source/API/SBCommandInterpreter.cpp21
-rw-r--r--lldb/source/API/SBCommandInterpreterRunOptions.cpp37
-rw-r--r--lldb/source/API/SBDebugger.cpp46
-rw-r--r--lldb/source/API/SBError.cpp2
-rw-r--r--lldb/source/API/SBFrame.cpp2
-rw-r--r--lldb/source/API/SBFunction.cpp4
-rw-r--r--lldb/source/API/SBHostOS.cpp9
-rw-r--r--lldb/source/API/SBInstruction.cpp2
-rw-r--r--lldb/source/API/SBLaunchInfo.cpp7
-rw-r--r--lldb/source/API/SBLineEntry.cpp4
-rw-r--r--lldb/source/API/SBModule.cpp58
-rw-r--r--lldb/source/API/SBPlatform.cpp110
-rw-r--r--lldb/source/API/SBQueueItem.cpp2
-rw-r--r--lldb/source/API/SBReproducer.cpp97
-rw-r--r--lldb/source/API/SBReproducerPrivate.h1
-rw-r--r--lldb/source/API/SBSymbol.cpp4
-rw-r--r--lldb/source/API/SBTarget.cpp70
-rw-r--r--lldb/source/API/SBThreadPlan.cpp143
-rw-r--r--lldb/source/API/SBType.cpp39
-rw-r--r--lldb/source/API/SBValue.cpp4
-rw-r--r--lldb/source/API/SystemInitializerFull.cpp23
24 files changed, 520 insertions, 217 deletions
diff --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp
index 6444a006c0ff..7c102270a87c 100644
--- a/lldb/source/API/SBAddress.cpp
+++ b/lldb/source/API/SBAddress.cpp
@@ -25,11 +25,8 @@ SBAddress::SBAddress() : m_opaque_up(new Address()) {
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBAddress);
}
-SBAddress::SBAddress(const Address *lldb_object_ptr)
- : m_opaque_up(new Address()) {
- if (lldb_object_ptr)
- m_opaque_up = std::make_unique<Address>(*lldb_object_ptr);
-}
+SBAddress::SBAddress(const Address &address)
+ : m_opaque_up(std::make_unique<Address>(address)) {}
SBAddress::SBAddress(const SBAddress &rhs) : m_opaque_up(new Address()) {
LLDB_RECORD_CONSTRUCTOR(SBAddress, (const lldb::SBAddress &), rhs);
@@ -101,12 +98,7 @@ void SBAddress::SetAddress(lldb::SBSection section, lldb::addr_t offset) {
addr.SetOffset(offset);
}
-void SBAddress::SetAddress(const Address *lldb_object_ptr) {
- if (lldb_object_ptr)
- ref() = *lldb_object_ptr;
- else
- m_opaque_up = std::make_unique<Address>();
-}
+void SBAddress::SetAddress(const Address &address) { ref() = address; }
lldb::addr_t SBAddress::GetFileAddress() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBAddress, GetFileAddress);
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index eb75bf8b33f4..96ae305ffce5 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -81,6 +81,16 @@ bool SBBreakpoint::operator!=(const lldb::SBBreakpoint &rhs) {
return m_opaque_wp.lock() != rhs.m_opaque_wp.lock();
}
+SBTarget SBBreakpoint::GetTarget() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBTarget, SBBreakpoint, GetTarget);
+
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp)
+ return LLDB_RECORD_RESULT(SBTarget(bkpt_sp->GetTargetSP()));
+
+ return LLDB_RECORD_RESULT(SBTarget());
+}
+
break_id_t SBBreakpoint::GetID() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::break_id_t, SBBreakpoint, GetID);
@@ -575,7 +585,22 @@ SBError SBBreakpoint::AddLocation(SBAddress &address) {
return LLDB_RECORD_RESULT(error);
}
-void SBBreakpoint ::SetCallback(SBBreakpointHitCallback callback, void *baton) {
+SBStructuredData SBBreakpoint::SerializeToStructuredData() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBBreakpoint,
+ SerializeToStructuredData);
+
+ SBStructuredData data;
+ BreakpointSP bkpt_sp = GetSP();
+
+ if (!bkpt_sp)
+ return LLDB_RECORD_RESULT(data);
+
+ StructuredData::ObjectSP bkpt_dict = bkpt_sp->SerializeToStructuredData();
+ data.m_impl_up->SetObjectSP(bkpt_dict);
+ return LLDB_RECORD_RESULT(data);
+}
+
+void SBBreakpoint::SetCallback(SBBreakpointHitCallback callback, void *baton) {
LLDB_RECORD_DUMMY(void, SBBreakpoint, SetCallback,
(lldb::SBBreakpointHitCallback, void *), callback, baton);
@@ -972,6 +997,7 @@ void RegisterMethods<SBBreakpoint>(Registry &R) {
SBBreakpoint, operator==,(const lldb::SBBreakpoint &));
LLDB_REGISTER_METHOD(bool,
SBBreakpoint, operator!=,(const lldb::SBBreakpoint &));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBTarget, SBBreakpoint, GetTarget, ());
LLDB_REGISTER_METHOD_CONST(lldb::break_id_t, SBBreakpoint, GetID, ());
LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsValid, ());
LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, operator bool, ());
@@ -1017,6 +1043,8 @@ void RegisterMethods<SBBreakpoint>(Registry &R) {
(lldb::SBStream &, bool));
LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, AddLocation,
(lldb::SBAddress &));
+ LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBBreakpoint,
+ SerializeToStructuredData, ());
LLDB_REGISTER_METHOD(void, SBBreakpoint, SetScriptCallbackFunction,
(const char *));
LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackFunction,
diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp
index e29f3fd9c50e..d6bbb5faf041 100644
--- a/lldb/source/API/SBBreakpointLocation.cpp
+++ b/lldb/source/API/SBBreakpointLocation.cpp
@@ -80,7 +80,7 @@ SBAddress SBBreakpointLocation::GetAddress() {
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
- return LLDB_RECORD_RESULT(SBAddress(&loc_sp->GetAddress()));
+ return LLDB_RECORD_RESULT(SBAddress(loc_sp->GetAddress()));
}
return LLDB_RECORD_RESULT(SBAddress());
@@ -218,8 +218,8 @@ 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);
+ (const char *, SBStructuredData &), callback_function_name,
+ extra_args);
SBError sb_error;
BreakpointLocationSP loc_sp = GetSP();
@@ -239,7 +239,7 @@ SBError SBBreakpointLocation::SetScriptCallbackFunction(
sb_error.SetError(error);
} else
sb_error.SetErrorString("invalid breakpoint");
-
+
return LLDB_RECORD_RESULT(sb_error);
}
diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp
index f4f19577b36c..31e7da8323b8 100644
--- a/lldb/source/API/SBCommandInterpreter.cpp
+++ b/lldb/source/API/SBCommandInterpreter.cpp
@@ -478,6 +478,24 @@ void SBCommandInterpreter::SourceInitFileInHomeDirectory(
}
}
+void SBCommandInterpreter::SourceInitFileInHomeDirectory(
+ SBCommandReturnObject &result, bool is_repl) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory,
+ (lldb::SBCommandReturnObject &, bool), result, is_repl);
+
+ result.Clear();
+ if (IsValid()) {
+ TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
+ std::unique_lock<std::recursive_mutex> lock;
+ if (target_sp)
+ lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
+ m_opaque_ptr->SourceInitFileHome(result.ref(), is_repl);
+ } else {
+ result->AppendError("SBCommandInterpreter is not valid");
+ result->SetStatus(eReturnStatusFailed);
+ }
+}
+
void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory(
SBCommandReturnObject &result) {
LLDB_RECORD_METHOD(void, SBCommandInterpreter,
@@ -807,6 +825,9 @@ template <> void RegisterMethods<SBCommandInterpreter>(Registry &R) {
SourceInitFileInHomeDirectory,
(lldb::SBCommandReturnObject &));
LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
+ SourceInitFileInHomeDirectory,
+ (lldb::SBCommandReturnObject &, bool));
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
SourceInitFileInCurrentWorkingDirectory,
(lldb::SBCommandReturnObject &));
LLDB_REGISTER_METHOD(lldb::SBBroadcaster, SBCommandInterpreter,
diff --git a/lldb/source/API/SBCommandInterpreterRunOptions.cpp b/lldb/source/API/SBCommandInterpreterRunOptions.cpp
index fcfbf5e5401a..da800e8b7804 100644
--- a/lldb/source/API/SBCommandInterpreterRunOptions.cpp
+++ b/lldb/source/API/SBCommandInterpreterRunOptions.cpp
@@ -24,8 +24,29 @@ SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions() {
m_opaque_up = std::make_unique<CommandInterpreterRunOptions>();
}
+SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions(
+ const SBCommandInterpreterRunOptions &rhs)
+ : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreterRunOptions,
+ (const lldb::SBCommandInterpreterRunOptions &), rhs);
+
+ m_opaque_up = std::make_unique<CommandInterpreterRunOptions>(rhs.ref());
+}
+
SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() = default;
+SBCommandInterpreterRunOptions &SBCommandInterpreterRunOptions::operator=(
+ const SBCommandInterpreterRunOptions &rhs) {
+ LLDB_RECORD_METHOD(lldb::SBCommandInterpreterRunOptions &,
+ SBCommandInterpreterRunOptions, operator=,
+ (const lldb::SBCommandInterpreterRunOptions &), rhs);
+
+ if (this == &rhs)
+ return LLDB_RECORD_RESULT(*this);
+ *m_opaque_up = *rhs.m_opaque_up;
+ return LLDB_RECORD_RESULT(*this);
+}
+
bool SBCommandInterpreterRunOptions::GetStopOnContinue() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
GetStopOnContinue);
@@ -190,12 +211,11 @@ SBCommandInterpreterRunResult::~SBCommandInterpreterRunResult() = default;
SBCommandInterpreterRunResult &SBCommandInterpreterRunResult::operator=(
const SBCommandInterpreterRunResult &rhs) {
LLDB_RECORD_METHOD(lldb::SBCommandInterpreterRunResult &,
- SBCommandInterpreterRunResult,
- operator=,(const lldb::SBCommandInterpreterRunResult &),
- rhs);
+ SBCommandInterpreterRunResult, operator=,
+ (const lldb::SBCommandInterpreterRunResult &), rhs);
if (this == &rhs)
- return *this;
+ return LLDB_RECORD_RESULT(*this);
*m_opaque_up = *rhs.m_opaque_up;
return LLDB_RECORD_RESULT(*this);
}
@@ -220,6 +240,11 @@ namespace repro {
template <> void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunOptions, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunOptions,
+ (const lldb::SBCommandInterpreterRunOptions &));
+ LLDB_REGISTER_METHOD(lldb::SBCommandInterpreterRunOptions &,
+ SBCommandInterpreterRunOptions, operator=,
+ (const lldb::SBCommandInterpreterRunOptions &));
LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
GetStopOnContinue, ());
LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnContinue,
@@ -260,8 +285,8 @@ template <> void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunResult,
(const lldb::SBCommandInterpreterRunResult &));
LLDB_REGISTER_METHOD(lldb::SBCommandInterpreterRunResult &,
- SBCommandInterpreterRunResult,
- operator=,(const lldb::SBCommandInterpreterRunResult &));
+ SBCommandInterpreterRunResult, operator=,
+ (const lldb::SBCommandInterpreterRunResult &));
LLDB_REGISTER_METHOD_CONST(int, SBCommandInterpreterRunResult,
GetNumberOfErrors, ());
LLDB_REGISTER_METHOD_CONST(lldb::CommandInterpreterResult,
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 5f62987f37da..6245b3a83565 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -220,7 +220,7 @@ SBDebugger SBDebugger::Create(bool source_init_files,
interp.get()->SkipLLDBInitFiles(false);
interp.get()->SkipAppInitFiles(false);
SBCommandReturnObject result;
- interp.SourceInitFileInHomeDirectory(result);
+ interp.SourceInitFileInHomeDirectory(result, false);
} else {
interp.get()->SkipLLDBInitFiles(true);
interp.get()->SkipAppInitFiles(true);
@@ -804,23 +804,33 @@ SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename,
TargetSP target_sp;
if (m_opaque_sp) {
Status error;
- const bool add_dependent_modules = true;
-
- error = m_opaque_sp->GetTargetList().CreateTarget(
- *m_opaque_sp, filename, arch_cstr,
- add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr,
- target_sp);
-
- if (error.Success()) {
- m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp.get());
- sb_target.SetSP(target_sp);
+ if (arch_cstr == nullptr) {
+ // The version of CreateTarget that takes an ArchSpec won't accept an
+ // empty ArchSpec, so when the arch hasn't been specified, we need to
+ // call the target triple version.
+ error = m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp, filename,
+ arch_cstr, eLoadDependentsYes, nullptr, target_sp);
+ } else {
+ PlatformSP platform_sp = m_opaque_sp->GetPlatformList()
+ .GetSelectedPlatform();
+ ArchSpec arch = Platform::GetAugmentedArchSpec(platform_sp.get(),
+ arch_cstr);
+ if (arch.IsValid())
+ error = m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp, filename,
+ arch, eLoadDependentsYes, platform_sp, target_sp);
+ else
+ error.SetErrorStringWithFormat("invalid arch_cstr: %s", arch_cstr);
}
+ if (error.Success())
+ sb_target.SetSP(target_sp);
}
-
+
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 *>(m_opaque_sp.get()),
+ filename ? filename : "<unspecified>",
+ arch_cstr ? arch_cstr : "<unspecified>",
static_cast<void *>(target_sp.get()));
return LLDB_RECORD_RESULT(sb_target);
@@ -840,10 +850,8 @@ SBTarget SBDebugger::CreateTarget(const char *filename) {
add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr,
target_sp);
- if (error.Success()) {
- m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp.get());
+ if (error.Success())
sb_target.SetSP(target_sp);
- }
}
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
LLDB_LOGF(log,
@@ -858,7 +866,7 @@ 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));
LLDB_LOGF(log, "SBDebugger(%p)::GetDummyTarget() => SBTarget(%p)",
@@ -879,8 +887,6 @@ bool SBDebugger::DeleteTarget(lldb::SBTarget &target) {
result = m_opaque_sp->GetTargetList().DeleteTarget(target_sp);
target_sp->Destroy();
target.Clear();
- const bool mandatory = true;
- ModuleList::RemoveOrphanSharedModules(mandatory);
}
}
@@ -1000,7 +1006,7 @@ void SBDebugger::SetSelectedTarget(SBTarget &sb_target) {
TargetSP target_sp(sb_target.GetSP());
if (m_opaque_sp) {
- m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp.get());
+ m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp);
}
if (log) {
SBStream sstr;
diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp
index 67c7663d3583..f979572778e0 100644
--- a/lldb/source/API/SBError.cpp
+++ b/lldb/source/API/SBError.cpp
@@ -118,7 +118,7 @@ void SBError::SetErrorToGenericError() {
LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToGenericError);
CreateIfNeeded();
- m_opaque_up->SetErrorToErrno();
+ m_opaque_up->SetErrorToGenericError();
}
void SBError::SetErrorString(const char *err_str) {
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index 81782dbf838f..8f9e426e066e 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/lldb/source/API/SBFrame.cpp
@@ -431,7 +431,7 @@ SBAddress SBFrame::GetPCAddress() const {
if (stop_locker.TryLock(&process->GetRunLock())) {
frame = exe_ctx.GetFramePtr();
if (frame)
- sb_addr.SetAddress(&frame->GetFrameCodeAddress());
+ sb_addr.SetAddress(frame->GetFrameCodeAddress());
}
}
return LLDB_RECORD_RESULT(sb_addr);
diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index e49513bd0da5..9f3cf817fc8c 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/lldb/source/API/SBFunction.cpp
@@ -152,7 +152,7 @@ SBAddress SBFunction::GetStartAddress() {
SBAddress addr;
if (m_opaque_ptr)
- addr.SetAddress(&m_opaque_ptr->GetAddressRange().GetBaseAddress());
+ addr.SetAddress(m_opaque_ptr->GetAddressRange().GetBaseAddress());
return LLDB_RECORD_RESULT(addr);
}
@@ -163,7 +163,7 @@ SBAddress SBFunction::GetEndAddress() {
if (m_opaque_ptr) {
addr_t byte_size = m_opaque_ptr->GetAddressRange().GetByteSize();
if (byte_size > 0) {
- addr.SetAddress(&m_opaque_ptr->GetAddressRange().GetBaseAddress());
+ addr.SetAddress(m_opaque_ptr->GetAddressRange().GetBaseAddress());
addr->Slide(byte_size);
}
}
diff --git a/lldb/source/API/SBHostOS.cpp b/lldb/source/API/SBHostOS.cpp
index 9d3d119e4c2a..deca4ac81a1a 100644
--- a/lldb/source/API/SBHostOS.cpp
+++ b/lldb/source/API/SBHostOS.cpp
@@ -91,14 +91,13 @@ SBFileSpec SBHostOS::GetUserHomeDirectory() {
LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBFileSpec, SBHostOS,
GetUserHomeDirectory);
- SBFileSpec sb_fspec;
-
- llvm::SmallString<64> home_dir_path;
- llvm::sys::path::home_directory(home_dir_path);
- FileSpec homedir(home_dir_path.c_str());
+ FileSpec homedir;
+ FileSystem::Instance().GetHomeDirectory(homedir);
FileSystem::Instance().Resolve(homedir);
+ SBFileSpec sb_fspec;
sb_fspec.SetFileSpec(homedir);
+
return LLDB_RECORD_RESULT(sb_fspec);
}
diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp
index 207e81272e50..579ddf84cf45 100644
--- a/lldb/source/API/SBInstruction.cpp
+++ b/lldb/source/API/SBInstruction.cpp
@@ -107,7 +107,7 @@ SBAddress SBInstruction::GetAddress() {
SBAddress sb_addr;
lldb::InstructionSP inst_sp(GetOpaque());
if (inst_sp && inst_sp->GetAddress().IsValid())
- sb_addr.SetAddress(&inst_sp->GetAddress());
+ sb_addr.SetAddress(inst_sp->GetAddress());
return LLDB_RECORD_RESULT(sb_addr);
}
diff --git a/lldb/source/API/SBLaunchInfo.cpp b/lldb/source/API/SBLaunchInfo.cpp
index ba13072e8f9b..cda8134c9853 100644
--- a/lldb/source/API/SBLaunchInfo.cpp
+++ b/lldb/source/API/SBLaunchInfo.cpp
@@ -190,9 +190,10 @@ void SBLaunchInfo::SetEnvironment(const SBEnvironment &env, bool append) {
LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironment,
(const lldb::SBEnvironment &, bool), env, append);
Environment &refEnv = env.ref();
- if (append)
- m_opaque_sp->GetEnvironment().insert(refEnv.begin(), refEnv.end());
- else
+ if (append) {
+ for (auto &KV : refEnv)
+ m_opaque_sp->GetEnvironment().insert_or_assign(KV.first(), KV.second);
+ } else
m_opaque_sp->GetEnvironment() = refEnv;
m_opaque_sp->RegenerateEnvp();
}
diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp
index cefbe3ee1a1e..9866acbcbec3 100644
--- a/lldb/source/API/SBLineEntry.cpp
+++ b/lldb/source/API/SBLineEntry.cpp
@@ -56,7 +56,7 @@ SBAddress SBLineEntry::GetStartAddress() const {
SBAddress sb_address;
if (m_opaque_up)
- sb_address.SetAddress(&m_opaque_up->range.GetBaseAddress());
+ sb_address.SetAddress(m_opaque_up->range.GetBaseAddress());
return LLDB_RECORD_RESULT(sb_address);
}
@@ -66,7 +66,7 @@ SBAddress SBLineEntry::GetEndAddress() const {
SBAddress sb_address;
if (m_opaque_up) {
- sb_address.SetAddress(&m_opaque_up->range.GetBaseAddress());
+ sb_address.SetAddress(m_opaque_up->range.GetBaseAddress());
sb_address.OffsetAddress(m_opaque_up->range.GetByteSize());
}
return LLDB_RECORD_RESULT(sb_address);
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index c30529b37eb1..b5b9fe16aa63 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -67,8 +67,8 @@ SBModule::SBModule(lldb::SBProcess &process, lldb::addr_t header_addr)
}
const SBModule &SBModule::operator=(const SBModule &rhs) {
- LLDB_RECORD_METHOD(const lldb::SBModule &,
- SBModule, operator=,(const lldb::SBModule &), rhs);
+ LLDB_RECORD_METHOD(const lldb::SBModule &, SBModule, operator=,
+ (const lldb::SBModule &), rhs);
if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp;
@@ -108,7 +108,6 @@ lldb::SBFileSpec SBModule::GetPlatformFileSpec() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBModule,
GetPlatformFileSpec);
-
SBFileSpec file_spec;
ModuleSP module_sp(GetSP());
if (module_sp)
@@ -187,7 +186,7 @@ const char *SBModule::GetUUIDString() const {
}
bool SBModule::operator==(const SBModule &rhs) const {
- LLDB_RECORD_METHOD_CONST(bool, SBModule, operator==,(const lldb::SBModule &),
+ LLDB_RECORD_METHOD_CONST(bool, SBModule, operator==, (const lldb::SBModule &),
rhs);
if (m_opaque_sp)
@@ -196,7 +195,7 @@ bool SBModule::operator==(const SBModule &rhs) const {
}
bool SBModule::operator!=(const SBModule &rhs) const {
- LLDB_RECORD_METHOD_CONST(bool, SBModule, operator!=,(const lldb::SBModule &),
+ LLDB_RECORD_METHOD_CONST(bool, SBModule, operator!=, (const lldb::SBModule &),
rhs);
if (m_opaque_sp)
@@ -625,7 +624,7 @@ uint32_t SBModule::GetVersion(uint32_t *versions, uint32_t num_versions) {
++result;
if (version.getMinor())
++result;
- if(version.getSubminor())
+ if (version.getSubminor())
++result;
if (!versions)
@@ -690,17 +689,24 @@ uint32_t SBModule::GetNumberAllocatedModules() {
return Module::GetNumberAllocatedModules();
}
+void SBModule::GarbageCollectAllocatedModules() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBModule,
+ GarbageCollectAllocatedModules);
+
+ const bool mandatory = false;
+ ModuleList::RemoveOrphanSharedModules(mandatory);
+}
+
namespace lldb_private {
namespace repro {
-template <>
-void RegisterMethods<SBModule>(Registry &R) {
+template <> void RegisterMethods<SBModule>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBModule, ());
LLDB_REGISTER_CONSTRUCTOR(SBModule, (const lldb::SBModuleSpec &));
LLDB_REGISTER_CONSTRUCTOR(SBModule, (const lldb::SBModule &));
LLDB_REGISTER_CONSTRUCTOR(SBModule, (lldb::SBProcess &, lldb::addr_t));
- LLDB_REGISTER_METHOD(const lldb::SBModule &,
- SBModule, operator=,(const lldb::SBModule &));
+ LLDB_REGISTER_METHOD(const lldb::SBModule &, SBModule, operator=,
+ (const lldb::SBModule &));
LLDB_REGISTER_METHOD_CONST(bool, SBModule, IsValid, ());
LLDB_REGISTER_METHOD_CONST(bool, SBModule, operator bool, ());
LLDB_REGISTER_METHOD(void, SBModule, Clear, ());
@@ -714,10 +720,10 @@ void RegisterMethods<SBModule>(Registry &R) {
LLDB_REGISTER_METHOD(bool, SBModule, SetRemoteInstallFileSpec,
(lldb::SBFileSpec &));
LLDB_REGISTER_METHOD_CONST(const char *, SBModule, GetUUIDString, ());
- LLDB_REGISTER_METHOD_CONST(bool,
- SBModule, operator==,(const lldb::SBModule &));
- LLDB_REGISTER_METHOD_CONST(bool,
- SBModule, operator!=,(const lldb::SBModule &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBModule, operator==,
+ (const lldb::SBModule &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBModule, operator!=,
+ (const lldb::SBModule &));
LLDB_REGISTER_METHOD(lldb::SBAddress, SBModule, ResolveFileAddress,
(lldb::addr_t));
LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBModule,
@@ -736,8 +742,7 @@ void RegisterMethods<SBModule>(Registry &R) {
LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindSymbols,
(const char *, lldb::SymbolType));
LLDB_REGISTER_METHOD(size_t, SBModule, GetNumSections, ());
- LLDB_REGISTER_METHOD(lldb::SBSection, SBModule, GetSectionAtIndex,
- (size_t));
+ LLDB_REGISTER_METHOD(lldb::SBSection, SBModule, GetSectionAtIndex, (size_t));
LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindFunctions,
(const char *, uint32_t));
LLDB_REGISTER_METHOD(lldb::SBValueList, SBModule, FindGlobalVariables,
@@ -745,28 +750,25 @@ void RegisterMethods<SBModule>(Registry &R) {
LLDB_REGISTER_METHOD(lldb::SBValue, SBModule, FindFirstGlobalVariable,
(lldb::SBTarget &, const char *));
LLDB_REGISTER_METHOD(lldb::SBType, SBModule, FindFirstType, (const char *));
- LLDB_REGISTER_METHOD(lldb::SBType, SBModule, GetBasicType,
- (lldb::BasicType));
+ LLDB_REGISTER_METHOD(lldb::SBType, SBModule, GetBasicType, (lldb::BasicType));
LLDB_REGISTER_METHOD(lldb::SBTypeList, SBModule, FindTypes, (const char *));
- LLDB_REGISTER_METHOD(lldb::SBType, SBModule, GetTypeByID,
- (lldb::user_id_t));
+ LLDB_REGISTER_METHOD(lldb::SBType, SBModule, GetTypeByID, (lldb::user_id_t));
LLDB_REGISTER_METHOD(lldb::SBTypeList, SBModule, GetTypes, (uint32_t));
- LLDB_REGISTER_METHOD(lldb::SBSection, SBModule, FindSection,
- (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBSection, SBModule, FindSection, (const char *));
LLDB_REGISTER_METHOD(lldb::ByteOrder, SBModule, GetByteOrder, ());
LLDB_REGISTER_METHOD(const char *, SBModule, GetTriple, ());
LLDB_REGISTER_METHOD(uint32_t, SBModule, GetAddressByteSize, ());
- LLDB_REGISTER_METHOD(uint32_t, SBModule, GetVersion,
- (uint32_t *, uint32_t));
- LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetSymbolFileSpec,
- ());
+ LLDB_REGISTER_METHOD(uint32_t, SBModule, GetVersion, (uint32_t *, uint32_t));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetSymbolFileSpec, ());
LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule,
GetObjectFileHeaderAddress, ());
LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule,
GetObjectFileEntryPointAddress, ());
LLDB_REGISTER_STATIC_METHOD(uint32_t, SBModule, GetNumberAllocatedModules,
());
+ LLDB_REGISTER_STATIC_METHOD(void, SBModule, GarbageCollectAllocatedModules,
+ ());
}
-}
-}
+} // namespace repro
+} // namespace lldb_private
diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index 7ac852488ffb..f118048156b9 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -50,14 +50,25 @@ struct PlatformConnectOptions {
// PlatformShellCommand
struct PlatformShellCommand {
- PlatformShellCommand(const char *shell_command = nullptr)
+ PlatformShellCommand(llvm::StringRef shell_interpreter,
+ llvm::StringRef shell_command)
: m_command(), m_working_dir(), m_status(0), m_signo(0) {
- if (shell_command && shell_command[0])
- m_command = shell_command;
+ if (!shell_interpreter.empty())
+ m_shell = shell_interpreter.str();
+
+ if (!m_shell.empty() && !shell_command.empty())
+ m_command = shell_command.str();
+ }
+
+ PlatformShellCommand(llvm::StringRef shell_command = llvm::StringRef())
+ : m_shell(), m_command(), m_working_dir(), m_status(0), m_signo(0) {
+ if (!shell_command.empty())
+ m_command = shell_command.str();
}
~PlatformShellCommand() = default;
+ std::string m_shell;
std::string m_command;
std::string m_working_dir;
std::string m_output;
@@ -82,8 +93,8 @@ SBPlatformConnectOptions::SBPlatformConnectOptions(
SBPlatformConnectOptions::~SBPlatformConnectOptions() { delete m_opaque_ptr; }
-SBPlatformConnectOptions &SBPlatformConnectOptions::
-operator=(const SBPlatformConnectOptions &rhs) {
+SBPlatformConnectOptions &
+SBPlatformConnectOptions::operator=(const SBPlatformConnectOptions &rhs) {
LLDB_RECORD_METHOD(
SBPlatformConnectOptions &,
SBPlatformConnectOptions, operator=,(
@@ -163,6 +174,13 @@ void SBPlatformConnectOptions::SetLocalCacheDirectory(const char *path) {
}
// SBPlatformShellCommand
+SBPlatformShellCommand::SBPlatformShellCommand(const char *shell_interpreter,
+ const char *shell_command)
+ : m_opaque_ptr(new PlatformShellCommand(shell_interpreter, shell_command)) {
+ LLDB_RECORD_CONSTRUCTOR(SBPlatformShellCommand, (const char *, const char *),
+ shell_interpreter, shell_command);
+}
+
SBPlatformShellCommand::SBPlatformShellCommand(const char *shell_command)
: m_opaque_ptr(new PlatformShellCommand(shell_command)) {
LLDB_RECORD_CONSTRUCTOR(SBPlatformShellCommand, (const char *),
@@ -178,8 +196,8 @@ SBPlatformShellCommand::SBPlatformShellCommand(
*m_opaque_ptr = *rhs.m_opaque_ptr;
}
-SBPlatformShellCommand &SBPlatformShellCommand::
-operator=(const SBPlatformShellCommand &rhs) {
+SBPlatformShellCommand &
+SBPlatformShellCommand::operator=(const SBPlatformShellCommand &rhs) {
LLDB_RECORD_METHOD(
SBPlatformShellCommand &,
@@ -200,6 +218,24 @@ void SBPlatformShellCommand::Clear() {
m_opaque_ptr->m_signo = 0;
}
+const char *SBPlatformShellCommand::GetShell() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, GetShell);
+
+ if (m_opaque_ptr->m_shell.empty())
+ return nullptr;
+ return m_opaque_ptr->m_shell.c_str();
+}
+
+void SBPlatformShellCommand::SetShell(const char *shell_interpreter) {
+ LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetShell, (const char *),
+ shell_interpreter);
+
+ if (shell_interpreter && shell_interpreter[0])
+ m_opaque_ptr->m_shell = shell_interpreter;
+ else
+ m_opaque_ptr->m_shell.clear();
+}
+
const char *SBPlatformShellCommand::GetCommand() {
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, GetCommand);
@@ -545,24 +581,25 @@ SBError SBPlatform::Install(SBFileSpec &src, SBFileSpec &dst) {
SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) {
LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Run,
(lldb::SBPlatformShellCommand &), shell_command);
- return LLDB_RECORD_RESULT(ExecuteConnected([&](const lldb::PlatformSP
- &platform_sp) {
- const char *command = shell_command.GetCommand();
- if (!command)
- return Status("invalid shell command (empty)");
+ return LLDB_RECORD_RESULT(
+ ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ const char *command = shell_command.GetCommand();
+ if (!command)
+ return Status("invalid shell command (empty)");
- const char *working_dir = shell_command.GetWorkingDirectory();
- if (working_dir == nullptr) {
- working_dir = platform_sp->GetWorkingDirectory().GetCString();
- if (working_dir)
- shell_command.SetWorkingDirectory(working_dir);
- }
- return platform_sp->RunShellCommand(command, FileSpec(working_dir),
- &shell_command.m_opaque_ptr->m_status,
- &shell_command.m_opaque_ptr->m_signo,
- &shell_command.m_opaque_ptr->m_output,
- shell_command.m_opaque_ptr->m_timeout);
- }));
+ const char *working_dir = shell_command.GetWorkingDirectory();
+ if (working_dir == nullptr) {
+ working_dir = platform_sp->GetWorkingDirectory().GetCString();
+ if (working_dir)
+ shell_command.SetWorkingDirectory(working_dir);
+ }
+ return platform_sp->RunShellCommand(
+ shell_command.m_opaque_ptr->m_shell, command, FileSpec(working_dir),
+ &shell_command.m_opaque_ptr->m_status,
+ &shell_command.m_opaque_ptr->m_signo,
+ &shell_command.m_opaque_ptr->m_output,
+ shell_command.m_opaque_ptr->m_timeout);
+ }));
}
SBError SBPlatform::Launch(SBLaunchInfo &launch_info) {
@@ -668,8 +705,7 @@ SBEnvironment SBPlatform::GetEnvironment() {
namespace lldb_private {
namespace repro {
-template <>
-void RegisterMethods<SBPlatformConnectOptions>(Registry &R) {
+template <> void RegisterMethods<SBPlatformConnectOptions>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions, (const char *));
LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions,
(const lldb::SBPlatformConnectOptions &));
@@ -678,8 +714,7 @@ void RegisterMethods<SBPlatformConnectOptions>(Registry &R) {
SBPlatformConnectOptions, operator=,(
const lldb::SBPlatformConnectOptions &));
LLDB_REGISTER_METHOD(const char *, SBPlatformConnectOptions, GetURL, ());
- LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, SetURL,
- (const char *));
+ LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, SetURL, (const char *));
LLDB_REGISTER_METHOD(bool, SBPlatformConnectOptions, GetRsyncEnabled, ());
LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, EnableRsync,
(const char *, const char *, bool));
@@ -690,8 +725,7 @@ void RegisterMethods<SBPlatformConnectOptions>(Registry &R) {
(const char *));
}
-template <>
-void RegisterMethods<SBPlatformShellCommand>(Registry &R) {
+template <> void RegisterMethods<SBPlatformShellCommand>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, (const char *));
LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand,
(const lldb::SBPlatformShellCommand &));
@@ -699,6 +733,8 @@ void RegisterMethods<SBPlatformShellCommand>(Registry &R) {
SBPlatformShellCommand &,
SBPlatformShellCommand, operator=,(const lldb::SBPlatformShellCommand &));
LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, Clear, ());
+ LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetShell, ());
+ LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetShell, (const char *));
LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetCommand, ());
LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetCommand,
(const char *));
@@ -706,8 +742,7 @@ void RegisterMethods<SBPlatformShellCommand>(Registry &R) {
GetWorkingDirectory, ());
LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetWorkingDirectory,
(const char *));
- LLDB_REGISTER_METHOD(uint32_t, SBPlatformShellCommand, GetTimeoutSeconds,
- ());
+ LLDB_REGISTER_METHOD(uint32_t, SBPlatformShellCommand, GetTimeoutSeconds, ());
LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetTimeoutSeconds,
(uint32_t));
LLDB_REGISTER_METHOD(int, SBPlatformShellCommand, GetSignal, ());
@@ -715,15 +750,16 @@ void RegisterMethods<SBPlatformShellCommand>(Registry &R) {
LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetOutput, ());
}
-template <>
-void RegisterMethods<SBPlatform>(Registry &R) {
+template <> void RegisterMethods<SBPlatform>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBPlatform, ());
LLDB_REGISTER_CONSTRUCTOR(SBPlatform, (const char *));
LLDB_REGISTER_CONSTRUCTOR(SBPlatform, (const lldb::SBPlatform &));
+ LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand,
+ (const char *, const char *));
LLDB_REGISTER_METHOD(SBPlatform &,
SBPlatform, operator=,(const lldb::SBPlatform &));
LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, IsValid, ());
- LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, operator bool, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, operator bool,());
LLDB_REGISTER_METHOD(void, SBPlatform, Clear, ());
LLDB_REGISTER_METHOD(const char *, SBPlatform, GetName, ());
LLDB_REGISTER_METHOD(const char *, SBPlatform, GetWorkingDirectory, ());
@@ -763,5 +799,5 @@ void RegisterMethods<SBPlatform>(Registry &R) {
());
}
-}
-}
+} // namespace repro
+} // namespace lldb_private
diff --git a/lldb/source/API/SBQueueItem.cpp b/lldb/source/API/SBQueueItem.cpp
index 0f92e2e04126..6cd9e4514caf 100644
--- a/lldb/source/API/SBQueueItem.cpp
+++ b/lldb/source/API/SBQueueItem.cpp
@@ -80,7 +80,7 @@ SBAddress SBQueueItem::GetAddress() const {
SBAddress result;
if (m_queue_item_sp) {
- result.SetAddress(&m_queue_item_sp->GetAddress());
+ result.SetAddress(m_queue_item_sp->GetAddress());
}
return LLDB_RECORD_RESULT(result);
}
diff --git a/lldb/source/API/SBReproducer.cpp b/lldb/source/API/SBReproducer.cpp
index 0eb3429c4fef..4d25fcc4a8f6 100644
--- a/lldb/source/API/SBReproducer.cpp
+++ b/lldb/source/API/SBReproducer.cpp
@@ -8,7 +8,6 @@
#include "SBReproducerPrivate.h"
-#include "SBReproducerPrivate.h"
#include "lldb/API/LLDB.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBAttachInfo.h"
@@ -30,6 +29,33 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::repro;
+SBReplayOptions::SBReplayOptions()
+ : m_opaque_up(std::make_unique<ReplayOptions>()){}
+
+SBReplayOptions::SBReplayOptions(const SBReplayOptions &rhs)
+ : m_opaque_up(std::make_unique<ReplayOptions>(*rhs.m_opaque_up)) {}
+
+SBReplayOptions::~SBReplayOptions() = default;
+
+SBReplayOptions &SBReplayOptions::operator=(const SBReplayOptions &rhs) {
+ if (this == &rhs)
+ return *this;
+ *m_opaque_up = *rhs.m_opaque_up;
+ return *this;
+}
+
+void SBReplayOptions::SetVerify(bool verify) { m_opaque_up->verify = verify; }
+
+bool SBReplayOptions::GetVerify() const { return m_opaque_up->verify; }
+
+void SBReplayOptions::SetCheckVersion(bool check) {
+ m_opaque_up->check_version = check;
+}
+
+bool SBReplayOptions::GetCheckVersion() const {
+ return m_opaque_up->check_version;
+}
+
SBRegistry::SBRegistry() {
Registry &R = *this;
@@ -163,10 +189,18 @@ const char *SBReproducer::PassiveReplay(const char *path) {
}
const char *SBReproducer::Replay(const char *path) {
- return SBReproducer::Replay(path, false);
+ SBReplayOptions options;
+ return SBReproducer::Replay(path, options);
}
const char *SBReproducer::Replay(const char *path, bool skip_version_check) {
+ SBReplayOptions options;
+ options.SetCheckVersion(!skip_version_check);
+ return SBReproducer::Replay(path, options);
+}
+
+const char *SBReproducer::Replay(const char *path,
+ const SBReplayOptions &options) {
static std::string error;
if (auto e = Reproducer::Initialize(ReproducerMode::Replay, FileSpec(path))) {
error = llvm::toString(std::move(e));
@@ -179,7 +213,7 @@ const char *SBReproducer::Replay(const char *path, bool skip_version_check) {
return error.c_str();
}
- if (!skip_version_check) {
+ if (options.GetCheckVersion()) {
llvm::Expected<std::string> version = loader->LoadBuffer<VersionProvider>();
if (!version) {
error = llvm::toString(version.takeError());
@@ -195,6 +229,30 @@ const char *SBReproducer::Replay(const char *path, bool skip_version_check) {
}
}
+ if (options.GetVerify()) {
+ bool verification_failed = false;
+ llvm::raw_string_ostream os(error);
+ auto error_callback = [&](llvm::StringRef error) {
+ verification_failed = true;
+ os << "\nerror: " << error;
+ };
+
+ auto warning_callback = [&](llvm::StringRef warning) {
+ verification_failed = true;
+ os << "\nwarning: " << warning;
+ };
+
+ auto note_callback = [&](llvm::StringRef warning) {};
+
+ Verifier verifier(loader);
+ verifier.Verify(error_callback, warning_callback, note_callback);
+
+ if (verification_failed) {
+ os.flush();
+ return error.c_str();
+ }
+ }
+
FileSpec file = loader->GetFile<SBProvider::Info>();
if (!file) {
error = "unable to get replay data from reproducer.";
@@ -207,6 +265,27 @@ const char *SBReproducer::Replay(const char *path, bool skip_version_check) {
return nullptr;
}
+const char *SBReproducer::Finalize(const char *path) {
+ static std::string error;
+ if (auto e = Reproducer::Initialize(ReproducerMode::Replay, FileSpec(path))) {
+ error = llvm::toString(std::move(e));
+ return error.c_str();
+ }
+
+ repro::Loader *loader = repro::Reproducer::Instance().GetLoader();
+ if (!loader) {
+ error = "unable to get replay loader.";
+ return error.c_str();
+ }
+
+ if (auto e = repro::Finalize(loader)) {
+ error = llvm::toString(std::move(e));
+ return error.c_str();
+ }
+
+ return nullptr;
+}
+
bool SBReproducer::Generate() {
auto &r = Reproducer::Instance();
if (auto generator = r.GetGenerator()) {
@@ -226,15 +305,19 @@ bool SBReproducer::SetAutoGenerate(bool b) {
}
const char *SBReproducer::GetPath() {
- static std::string path;
+ ConstString path;
auto &r = Reproducer::Instance();
- path = r.GetReproducerPath().GetCString();
- return path.c_str();
+ if (FileSpec reproducer_path = Reproducer::Instance().GetReproducerPath())
+ path = ConstString(r.GetReproducerPath().GetCString());
+ return path.GetCString();
}
void SBReproducer::SetWorkingDirectory(const char *path) {
if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
- g->GetOrCreate<WorkingDirectoryProvider>().Update(path);
+ auto &wp = g->GetOrCreate<repro::WorkingDirectoryProvider>();
+ wp.SetDirectory(path);
+ auto &fp = g->GetOrCreate<repro::FileProvider>();
+ fp.RecordInterestingDirectory(wp.GetDirectory());
}
}
diff --git a/lldb/source/API/SBReproducerPrivate.h b/lldb/source/API/SBReproducerPrivate.h
index a4c6eb94627b..02ac31c2ad89 100644
--- a/lldb/source/API/SBReproducerPrivate.h
+++ b/lldb/source/API/SBReproducerPrivate.h
@@ -16,6 +16,7 @@
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Reproducer.h"
#include "lldb/Utility/ReproducerInstrumentation.h"
+#include "lldb/Utility/ReproducerProvider.h"
#include "llvm/ADT/DenseMap.h"
diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp
index e4f2f3518270..eafc3e630bcd 100644
--- a/lldb/source/API/SBSymbol.cpp
+++ b/lldb/source/API/SBSymbol.cpp
@@ -151,7 +151,7 @@ SBAddress SBSymbol::GetStartAddress() {
SBAddress addr;
if (m_opaque_ptr && m_opaque_ptr->ValueIsAddress()) {
- addr.SetAddress(&m_opaque_ptr->GetAddressRef());
+ addr.SetAddress(m_opaque_ptr->GetAddressRef());
}
return LLDB_RECORD_RESULT(addr);
}
@@ -163,7 +163,7 @@ SBAddress SBSymbol::GetEndAddress() {
if (m_opaque_ptr && m_opaque_ptr->ValueIsAddress()) {
lldb::addr_t range_size = m_opaque_ptr->GetByteSize();
if (range_size > 0) {
- addr.SetAddress(&m_opaque_ptr->GetAddressRef());
+ addr.SetAddress(m_opaque_ptr->GetAddressRef());
addr->Slide(m_opaque_ptr->GetByteSize());
}
}
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index b84e9f10fafe..6128c04de32b 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -267,7 +267,7 @@ SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) {
FileSpec filespec(core_file);
FileSystem::Instance().Resolve(filespec);
ProcessSP process_sp(target_sp->CreateProcess(
- target_sp->GetDebugger().GetListener(), "", &filespec));
+ target_sp->GetDebugger().GetListener(), "", &filespec, false));
if (process_sp) {
error.SetError(process_sp->LoadCore());
if (error.Success())
@@ -287,16 +287,24 @@ SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp,
(const char **, const char **, const char *), argv, envp,
working_directory);
- char *stdin_path = nullptr;
- char *stdout_path = nullptr;
- char *stderr_path = nullptr;
- uint32_t launch_flags = 0;
- bool stop_at_entry = false;
+ TargetSP target_sp = GetSP();
+ if (!target_sp)
+ return LLDB_RECORD_RESULT(SBProcess());
+
+ SBLaunchInfo launch_info = GetLaunchInfo();
+
+ if (Module *exe_module = target_sp->GetExecutableModulePointer())
+ launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(),
+ /*add_as_first_arg*/ true);
+ if (argv)
+ launch_info.SetArguments(argv, /*append*/ true);
+ if (envp)
+ launch_info.SetEnvironmentEntries(envp, /*append*/ false);
+ if (working_directory)
+ launch_info.SetWorkingDirectory(working_directory);
+
SBError error;
- SBListener listener = GetDebugger().GetListener();
- return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path,
- stdout_path, stderr_path, working_directory,
- launch_flags, stop_at_entry, error));
+ return LLDB_RECORD_RESULT(Launch(launch_info, error));
}
SBError SBTarget::Install() {
@@ -559,10 +567,11 @@ lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url,
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
if (listener.IsValid())
process_sp =
- target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, nullptr);
+ target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, nullptr,
+ true);
else
process_sp = target_sp->CreateProcess(
- target_sp->GetDebugger().GetListener(), plugin_name, nullptr);
+ target_sp->GetDebugger().GetListener(), plugin_name, nullptr, true);
if (process_sp) {
sb_process.SetSP(process_sp);
@@ -778,6 +787,38 @@ SBBreakpoint SBTarget::BreakpointCreateByLocation(
return LLDB_RECORD_RESULT(sb_bp);
}
+SBBreakpoint SBTarget::BreakpointCreateByLocation(
+ const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
+ lldb::addr_t offset, SBFileSpecList &sb_module_list,
+ bool move_to_nearest_code) {
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+ lldb::addr_t, lldb::SBFileSpecList &, bool),
+ sb_file_spec, line, column, offset, sb_module_list,
+ move_to_nearest_code);
+
+ SBBreakpoint sb_bp;
+ TargetSP target_sp(GetSP());
+ if (target_sp && line != 0) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+
+ const LazyBool check_inlines = eLazyBoolCalculate;
+ const LazyBool skip_prologue = eLazyBoolCalculate;
+ const bool internal = false;
+ const bool hardware = false;
+ const FileSpecList *module_list = nullptr;
+ if (sb_module_list.GetSize() > 0) {
+ module_list = sb_module_list.get();
+ }
+ sb_bp = target_sp->CreateBreakpoint(
+ module_list, *sb_file_spec, line, column, offset, check_inlines,
+ skip_prologue, internal, hardware,
+ move_to_nearest_code ? eLazyBoolYes : eLazyBoolNo);
+ }
+
+ return LLDB_RECORD_RESULT(sb_bp);
+}
+
SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name,
const char *module_name) {
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
@@ -1783,7 +1824,7 @@ lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name,
(const char *, uint32_t), name, name_type_mask);
lldb::SBSymbolContextList sb_sc_list;
- if (!name | !name[0])
+ if (!name || !name[0])
return LLDB_RECORD_RESULT(sb_sc_list);
TargetSP target_sp(GetSP());
@@ -2480,6 +2521,9 @@ void RegisterMethods<SBTarget>(Registry &R) {
BreakpointCreateByLocation,
(const lldb::SBFileSpec &, uint32_t, uint32_t,
lldb::addr_t, lldb::SBFileSpecList &));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+ lldb::addr_t, lldb::SBFileSpecList &, bool));
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
(const char *, const char *));
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
diff --git a/lldb/source/API/SBThreadPlan.cpp b/lldb/source/API/SBThreadPlan.cpp
index 1a947bbc2608..9af673b0f3a9 100644
--- a/lldb/source/API/SBThreadPlan.cpp
+++ b/lldb/source/API/SBThreadPlan.cpp
@@ -53,13 +53,13 @@ using namespace lldb_private;
SBThreadPlan::SBThreadPlan() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThreadPlan); }
SBThreadPlan::SBThreadPlan(const ThreadPlanSP &lldb_object_sp)
- : m_opaque_sp(lldb_object_sp) {
+ : m_opaque_wp(lldb_object_sp) {
LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &),
lldb_object_sp);
}
SBThreadPlan::SBThreadPlan(const SBThreadPlan &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {
+ : m_opaque_wp(rhs.m_opaque_wp) {
LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &), rhs);
}
@@ -69,8 +69,8 @@ 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,
- nullptr);
+ m_opaque_wp =
+ std::make_shared<ThreadPlanPython>(*thread, class_name, nullptr);
}
SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name,
@@ -81,7 +81,7 @@ 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_wp = std::make_shared<ThreadPlanPython>(*thread, class_name,
args_data.m_impl_up.get());
}
@@ -92,14 +92,12 @@ const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) {
SBThreadPlan, operator=,(const lldb::SBThreadPlan &), rhs);
if (this != &rhs)
- m_opaque_sp = rhs.m_opaque_sp;
+ m_opaque_wp = rhs.m_opaque_wp;
return LLDB_RECORD_RESULT(*this);
}
// Destructor
SBThreadPlan::~SBThreadPlan() = default;
-lldb_private::ThreadPlan *SBThreadPlan::get() { return m_opaque_sp.get(); }
-
bool SBThreadPlan::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, IsValid);
return this->operator bool();
@@ -107,13 +105,13 @@ bool SBThreadPlan::IsValid() const {
SBThreadPlan::operator bool() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, operator bool);
- return m_opaque_sp.get() != nullptr;
+ return static_cast<bool>(GetSP());
}
void SBThreadPlan::Clear() {
LLDB_RECORD_METHOD_NO_ARGS(void, SBThreadPlan, Clear);
- m_opaque_sp.reset();
+ m_opaque_wp.reset();
}
lldb::StopReason SBThreadPlan::GetStopReason() {
@@ -138,9 +136,10 @@ uint64_t SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx) {
SBThread SBThreadPlan::GetThread() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBThreadPlan, GetThread);
- if (m_opaque_sp) {
+ ThreadPlanSP thread_plan_sp(GetSP());
+ if (thread_plan_sp) {
return LLDB_RECORD_RESULT(
- SBThread(m_opaque_sp->GetThread().shared_from_this()));
+ SBThread(thread_plan_sp->GetThread().shared_from_this()));
} else
return LLDB_RECORD_RESULT(SBThread());
}
@@ -149,50 +148,69 @@ bool SBThreadPlan::GetDescription(lldb::SBStream &description) const {
LLDB_RECORD_METHOD_CONST(bool, SBThreadPlan, GetDescription,
(lldb::SBStream &), description);
- if (m_opaque_sp) {
- m_opaque_sp->GetDescription(description.get(), eDescriptionLevelFull);
+ ThreadPlanSP thread_plan_sp(GetSP());
+ if (thread_plan_sp) {
+ thread_plan_sp->GetDescription(description.get(), eDescriptionLevelFull);
} else {
description.Printf("Empty SBThreadPlan");
}
return true;
}
-void SBThreadPlan::SetThreadPlan(const ThreadPlanSP &lldb_object_sp) {
- m_opaque_sp = lldb_object_sp;
+void SBThreadPlan::SetThreadPlan(const ThreadPlanSP &lldb_object_wp) {
+ m_opaque_wp = lldb_object_wp;
}
void SBThreadPlan::SetPlanComplete(bool success) {
LLDB_RECORD_METHOD(void, SBThreadPlan, SetPlanComplete, (bool), success);
- if (m_opaque_sp)
- m_opaque_sp->SetPlanComplete(success);
+ ThreadPlanSP thread_plan_sp(GetSP());
+ if (thread_plan_sp)
+ thread_plan_sp->SetPlanComplete(success);
}
bool SBThreadPlan::IsPlanComplete() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanComplete);
- if (m_opaque_sp)
- return m_opaque_sp->IsPlanComplete();
- else
- return true;
+ ThreadPlanSP thread_plan_sp(GetSP());
+ if (thread_plan_sp)
+ return thread_plan_sp->IsPlanComplete();
+ return true;
}
bool SBThreadPlan::IsPlanStale() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanStale);
- if (m_opaque_sp)
- return m_opaque_sp->IsPlanStale();
- else
- return true;
+ ThreadPlanSP thread_plan_sp(GetSP());
+ if (thread_plan_sp)
+ return thread_plan_sp->IsPlanStale();
+ return true;
}
bool SBThreadPlan::IsValid() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsValid);
- if (m_opaque_sp)
- return m_opaque_sp->ValidatePlan(nullptr);
- else
- return false;
+ ThreadPlanSP thread_plan_sp(GetSP());
+ if (thread_plan_sp)
+ return thread_plan_sp->ValidatePlan(nullptr);
+ return false;
+}
+
+bool SBThreadPlan::GetStopOthers() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, GetStopOthers);
+
+ ThreadPlanSP thread_plan_sp(GetSP());
+ if (thread_plan_sp)
+ return thread_plan_sp->StopOthers();
+ return false;
+}
+
+void SBThreadPlan::SetStopOthers(bool stop_others) {
+ LLDB_RECORD_METHOD(void, SBThreadPlan, SetStopOthers, (bool), stop_others);
+
+ ThreadPlanSP thread_plan_sp(GetSP());
+ if (thread_plan_sp)
+ thread_plan_sp->SetStopOthers(stop_others);
}
// This section allows an SBThreadPlan to push another of the common types of
@@ -220,7 +238,8 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(
(lldb::SBAddress &, lldb::addr_t, lldb::SBError &),
sb_start_address, size, error);
- if (m_opaque_sp) {
+ ThreadPlanSP thread_plan_sp(GetSP());
+ if (thread_plan_sp) {
Address *start_address = sb_start_address.get();
if (!start_address) {
return LLDB_RECORD_RESULT(SBThreadPlan());
@@ -231,19 +250,18 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(
start_address->CalculateSymbolContext(&sc);
Status plan_status;
- SBThreadPlan plan =
- SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepOverRange(
+ SBThreadPlan plan = SBThreadPlan(
+ thread_plan_sp->GetThread().QueueThreadPlanForStepOverRange(
false, range, sc, eAllThreads, plan_status));
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
else
- plan.m_opaque_sp->SetPrivate(true);
-
+ plan.GetSP()->SetPrivate(true);
+
return LLDB_RECORD_RESULT(plan);
- } else {
- return LLDB_RECORD_RESULT(SBThreadPlan());
}
+ return LLDB_RECORD_RESULT(SBThreadPlan());
}
SBThreadPlan
@@ -266,7 +284,8 @@ SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
(lldb::SBAddress &, lldb::addr_t, lldb::SBError &),
sb_start_address, size, error);
- if (m_opaque_sp) {
+ ThreadPlanSP thread_plan_sp(GetSP());
+ if (thread_plan_sp) {
Address *start_address = sb_start_address.get();
if (!start_address) {
return LLDB_RECORD_RESULT(SBThreadPlan());
@@ -278,18 +297,17 @@ SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
Status plan_status;
SBThreadPlan plan =
- SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepInRange(
+ SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepInRange(
false, range, sc, nullptr, eAllThreads, plan_status));
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
else
- plan.m_opaque_sp->SetPrivate(true);
+ plan.GetSP()->SetPrivate(true);
return LLDB_RECORD_RESULT(plan);
- } else {
- return LLDB_RECORD_RESULT(SBThreadPlan());
}
+ return LLDB_RECORD_RESULT(SBThreadPlan());
}
SBThreadPlan
@@ -312,26 +330,26 @@ SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
(uint32_t, bool, lldb::SBError &), frame_idx_to_step_to,
first_insn, error);
- if (m_opaque_sp) {
+ ThreadPlanSP thread_plan_sp(GetSP());
+ if (thread_plan_sp) {
SymbolContext sc;
- sc = m_opaque_sp->GetThread().GetStackFrameAtIndex(0)->GetSymbolContext(
+ sc = thread_plan_sp->GetThread().GetStackFrameAtIndex(0)->GetSymbolContext(
lldb::eSymbolContextEverything);
Status plan_status;
SBThreadPlan plan =
- SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepOut(
+ SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepOut(
false, &sc, first_insn, false, eVoteYes, eVoteNoOpinion,
frame_idx_to_step_to, plan_status));
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
else
- plan.m_opaque_sp->SetPrivate(true);
+ plan.GetSP()->SetPrivate(true);
return LLDB_RECORD_RESULT(plan);
- } else {
- return LLDB_RECORD_RESULT(SBThreadPlan());
}
+ return LLDB_RECORD_RESULT(SBThreadPlan());
}
SBThreadPlan
@@ -350,25 +368,25 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address,
QueueThreadPlanForRunToAddress,
(lldb::SBAddress, lldb::SBError &), sb_address, error);
- if (m_opaque_sp) {
+ ThreadPlanSP thread_plan_sp(GetSP());
+ if (thread_plan_sp) {
Address *address = sb_address.get();
if (!address)
return LLDB_RECORD_RESULT(SBThreadPlan());
Status plan_status;
SBThreadPlan plan =
- SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForRunToAddress(
+ SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForRunToAddress(
false, *address, false, plan_status));
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
else
- plan.m_opaque_sp->SetPrivate(true);
+ plan.GetSP()->SetPrivate(true);
return LLDB_RECORD_RESULT(plan);
- } else {
- return LLDB_RECORD_RESULT(SBThreadPlan());
}
+ return LLDB_RECORD_RESULT(SBThreadPlan());
}
SBThreadPlan
@@ -389,22 +407,22 @@ SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
QueueThreadPlanForStepScripted,
(const char *, lldb::SBError &), script_class_name, error);
- if (m_opaque_sp) {
+ ThreadPlanSP thread_plan_sp(GetSP());
+ if (thread_plan_sp) {
Status plan_status;
StructuredData::ObjectSP empty_args;
SBThreadPlan plan =
- SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepScripted(
+ SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepScripted(
false, script_class_name, empty_args, false, plan_status));
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
else
- plan.m_opaque_sp->SetPrivate(true);
+ plan.GetSP()->SetPrivate(true);
return LLDB_RECORD_RESULT(plan);
- } else {
- return LLDB_RECORD_RESULT(SBThreadPlan());
}
+ return LLDB_RECORD_RESULT(SBThreadPlan());
}
SBThreadPlan
@@ -416,17 +434,18 @@ SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
(const char *, lldb::SBStructuredData &, lldb::SBError &),
script_class_name, args_data, error);
- if (m_opaque_sp) {
+ ThreadPlanSP thread_plan_sp(GetSP());
+ if (thread_plan_sp) {
Status plan_status;
StructuredData::ObjectSP args_obj = args_data.m_impl_up->GetObjectSP();
SBThreadPlan plan =
- SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepScripted(
+ SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepScripted(
false, script_class_name, args_obj, false, plan_status));
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
else
- plan.m_opaque_sp->SetPrivate(true);
+ plan.GetSP()->SetPrivate(true);
return LLDB_RECORD_RESULT(plan);
} else {
@@ -461,6 +480,8 @@ void RegisterMethods<SBThreadPlan>(Registry &R) {
LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanComplete, ());
LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanStale, ());
LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsValid, ());
+ LLDB_REGISTER_METHOD(void, SBThreadPlan, SetStopOthers, (bool));
+ LLDB_REGISTER_METHOD(bool, SBThreadPlan, GetStopOthers, ());
LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
QueueThreadPlanForStepOverRange,
(lldb::SBAddress &, lldb::addr_t));
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 852630f2d01a..550c4b065914 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -9,6 +9,7 @@
#include "lldb/API/SBType.h"
#include "SBReproducerPrivate.h"
#include "lldb/API/SBDefines.h"
+#include "lldb/API/SBModule.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBTypeEnumMember.h"
#include "lldb/Core/Mangled.h"
@@ -212,10 +213,8 @@ SBType SBType::GetArrayElementType() {
if (!IsValid())
return LLDB_RECORD_RESULT(SBType());
- CompilerType canonical_type =
- m_opaque_sp->GetCompilerType(true).GetCanonicalType();
- return LLDB_RECORD_RESULT(
- SBType(TypeImplSP(new TypeImpl(canonical_type.GetArrayElementType()))));
+ return LLDB_RECORD_RESULT(SBType(TypeImplSP(new TypeImpl(
+ m_opaque_sp->GetCompilerType(true).GetArrayElementType(nullptr)))));
}
SBType SBType::GetArrayType(uint64_t size) {
@@ -272,6 +271,14 @@ bool SBType::IsAnonymousType() {
return m_opaque_sp->GetCompilerType(true).IsAnonymousType();
}
+bool SBType::IsScopedEnumerationType() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsScopedEnumerationType);
+
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->GetCompilerType(true).IsScopedEnumerationType();
+}
+
lldb::SBType SBType::GetFunctionReturnType() {
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetFunctionReturnType);
@@ -337,6 +344,16 @@ lldb::SBType SBType::GetCanonicalType() {
return LLDB_RECORD_RESULT(SBType());
}
+SBType SBType::GetEnumerationIntegerType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetEnumerationIntegerType);
+
+ if (IsValid()) {
+ return LLDB_RECORD_RESULT(
+ SBType(m_opaque_sp->GetCompilerType(true).GetEnumerationIntegerType()));
+ }
+ return LLDB_RECORD_RESULT(SBType());
+}
+
lldb::BasicType SBType::GetBasicType() {
LLDB_RECORD_METHOD_NO_ARGS(lldb::BasicType, SBType, GetBasicType);
@@ -495,6 +512,17 @@ uint32_t SBType::GetTypeFlags() {
return m_opaque_sp->GetCompilerType(true).GetTypeInfo();
}
+lldb::SBModule SBType::GetModule() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBModule, SBType, GetModule);
+
+ lldb::SBModule sb_module;
+ if (!IsValid())
+ return LLDB_RECORD_RESULT(sb_module);
+
+ sb_module.SetSP(m_opaque_sp->GetModule());
+ return LLDB_RECORD_RESULT(sb_module);
+}
+
const char *SBType::GetName() {
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBType, GetName);
@@ -925,6 +953,7 @@ void RegisterMethods<SBType>(Registry &R) {
LLDB_REGISTER_METHOD(bool, SBType, IsPolymorphicClass, ());
LLDB_REGISTER_METHOD(bool, SBType, IsTypedefType, ());
LLDB_REGISTER_METHOD(bool, SBType, IsAnonymousType, ());
+ LLDB_REGISTER_METHOD(bool, SBType, IsScopedEnumerationType, ());
LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetFunctionReturnType, ());
LLDB_REGISTER_METHOD(lldb::SBTypeList, SBType, GetFunctionArgumentTypes,
());
@@ -933,6 +962,7 @@ void RegisterMethods<SBType>(Registry &R) {
GetMemberFunctionAtIndex, (uint32_t));
LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetUnqualifiedType, ());
LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetCanonicalType, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetEnumerationIntegerType, ());
LLDB_REGISTER_METHOD(lldb::BasicType, SBType, GetBasicType, ());
LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetBasicType, (lldb::BasicType));
LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfDirectBaseClasses, ());
@@ -950,6 +980,7 @@ void RegisterMethods<SBType>(Registry &R) {
(uint32_t));
LLDB_REGISTER_METHOD(bool, SBType, IsTypeComplete, ());
LLDB_REGISTER_METHOD(uint32_t, SBType, GetTypeFlags, ());
+ LLDB_REGISTER_METHOD(lldb::SBModule, SBType, GetModule, ());
LLDB_REGISTER_METHOD(const char *, SBType, GetName, ());
LLDB_REGISTER_METHOD(const char *, SBType, GetDisplayTypeName, ());
LLDB_REGISTER_METHOD(lldb::TypeClass, SBType, GetTypeClass, ());
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 7485b0ee1838..0a95cf41263d 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -333,7 +333,7 @@ size_t SBValue::GetByteSize() {
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
- result = value_sp->GetByteSize();
+ result = value_sp->GetByteSize().getValueOr(0);
}
return result;
@@ -1356,7 +1356,7 @@ lldb::SBAddress SBValue::GetAddress() {
}
}
- return LLDB_RECORD_RESULT(SBAddress(new Address(addr)));
+ return LLDB_RECORD_RESULT(SBAddress(addr));
}
lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) {
diff --git a/lldb/source/API/SystemInitializerFull.cpp b/lldb/source/API/SystemInitializerFull.cpp
index 7f95e7acf62a..0530f94580b3 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -14,6 +14,8 @@
#include "lldb/Host/Host.h"
#include "lldb/Initialization/SystemInitializerCommon.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/ProcessTrace.h"
+#include "lldb/Utility/Reproducer.h"
#include "lldb/Utility/Timer.h"
#include "llvm/Support/TargetSelect.h"
@@ -33,8 +35,16 @@ SystemInitializerFull::SystemInitializerFull() = default;
SystemInitializerFull::~SystemInitializerFull() = default;
llvm::Error SystemInitializerFull::Initialize() {
- if (auto e = SystemInitializerCommon::Initialize())
- return e;
+ llvm::Error error = SystemInitializerCommon::Initialize();
+ if (error) {
+ // During active replay, the ::Initialize call is replayed like any other
+ // SB API call and the return value is ignored. Since we can't intercept
+ // this, we terminate here before the uninitialized debugger inevitably
+ // crashes.
+ if (repro::Reproducer::Instance().IsReplaying())
+ llvm::report_fatal_error(std::move(error));
+ return error;
+ }
// Initialize LLVM and Clang
llvm::InitializeAllTargets();
@@ -45,6 +55,9 @@ llvm::Error SystemInitializerFull::Initialize() {
#define LLDB_PLUGIN(p) LLDB_PLUGIN_INITIALIZE(p);
#include "Plugins/Plugins.def"
+ // Initialize plug-ins in core LLDB
+ ProcessTrace::Initialize();
+
// Scan for any system or user LLDB plug-ins
PluginManager::Initialize();
@@ -56,11 +69,11 @@ llvm::Error SystemInitializerFull::Initialize() {
}
void SystemInitializerFull::Terminate() {
- static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
- Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
-
Debugger::SettingsTerminate();
+ // Terminate plug-ins in core LLDB
+ ProcessTrace::Terminate();
+
// Terminate and unload and loaded system or user LLDB plug-ins
PluginManager::Terminate();