diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-07-26 19:03:47 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2023-07-26 19:04:23 +0000 |
| commit | 7fa27ce4a07f19b07799a767fc29416f3b625afb (patch) | |
| tree | 27825c83636c4de341eb09a74f49f5d38a15d165 /lldb/source/API/SBProcess.cpp | |
| parent | e3b557809604d036af6e00c60f012c2025b59a5e (diff) | |
Diffstat (limited to 'lldb/source/API/SBProcess.cpp')
| -rw-r--r-- | lldb/source/API/SBProcess.cpp | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 27593559bb3d..67d08f1f02be 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -38,6 +38,7 @@ #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBMemoryRegionInfo.h" #include "lldb/API/SBMemoryRegionInfoList.h" +#include "lldb/API/SBScriptObject.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" #include "lldb/API/SBStructuredData.h" @@ -466,6 +467,16 @@ SBEvent SBProcess::GetStopEventForStopID(uint32_t stop_id) { return sb_event; } +void SBProcess::ForceScriptedState(StateType new_state) { + LLDB_INSTRUMENT_VA(this, new_state); + + if (ProcessSP process_sp = GetSP()) { + std::lock_guard<std::recursive_mutex> guard( + process_sp->GetTarget().GetAPIMutex()); + process_sp->ForceScriptedState(new_state); + } +} + StateType SBProcess::GetState() { LLDB_INSTRUMENT_VA(this); @@ -497,14 +508,13 @@ int SBProcess::GetExitStatus() { const char *SBProcess::GetExitDescription() { LLDB_INSTRUMENT_VA(this); - const char *exit_desc = nullptr; ProcessSP process_sp(GetSP()); - if (process_sp) { - std::lock_guard<std::recursive_mutex> guard( - process_sp->GetTarget().GetAPIMutex()); - exit_desc = process_sp->GetExitDescription(); - } - return exit_desc; + if (!process_sp) + return nullptr; + + std::lock_guard<std::recursive_mutex> guard( + process_sp->GetTarget().GetAPIMutex()); + return ConstString(process_sp->GetExitDescription()).GetCString(); } lldb::pid_t SBProcess::GetProcessID() { @@ -737,7 +747,9 @@ SBProcess::GetRestartedReasonAtIndexFromEvent(const lldb::SBEvent &event, size_t idx) { LLDB_INSTRUMENT_VA(event, idx); - return Process::ProcessEventData::GetRestartedReasonAtIndex(event.get(), idx); + return ConstString(Process::ProcessEventData::GetRestartedReasonAtIndex( + event.get(), idx)) + .GetCString(); } SBProcess SBProcess::GetProcessFromEvent(const SBEvent &event) { @@ -769,8 +781,8 @@ SBProcess::GetStructuredDataFromEvent(const lldb::SBEvent &event) { bool SBProcess::EventIsProcessEvent(const SBEvent &event) { LLDB_INSTRUMENT_VA(event); - return (event.GetBroadcasterClass() == SBProcess::GetBroadcasterClass()) && - !EventIsStructuredDataEvent(event); + return Process::ProcessEventData::GetEventDataFromEvent(event.get()) != + nullptr; } bool SBProcess::EventIsStructuredDataEvent(const lldb::SBEvent &event) { @@ -802,8 +814,13 @@ size_t SBProcess::ReadMemory(addr_t addr, void *dst, size_t dst_len, SBError &sb_error) { LLDB_INSTRUMENT_VA(this, addr, dst, dst_len, sb_error); - size_t bytes_read = 0; + if (!dst) { + sb_error.SetErrorStringWithFormat( + "no buffer provided to read %zu bytes into", dst_len); + return 0; + } + size_t bytes_read = 0; ProcessSP process_sp(GetSP()); @@ -967,7 +984,12 @@ SBProcess::GetNumSupportedHardwareWatchpoints(lldb::SBError &sb_error) const { if (process_sp) { std::lock_guard<std::recursive_mutex> guard( process_sp->GetTarget().GetAPIMutex()); - sb_error.SetError(process_sp->GetWatchpointSupportInfo(num)); + std::optional<uint32_t> actual_num = process_sp->GetWatchpointSlotCount(); + if (actual_num) { + num = *actual_num; + } else { + sb_error.SetErrorString("Unable to determine number of watchpoints"); + } } else { sb_error.SetErrorString("SBProcess is invalid"); } @@ -1162,6 +1184,7 @@ lldb::SBError SBProcess::SaveCore(const char *file_name, } FileSpec core_file(file_name); + FileSystem::Instance().Resolve(core_file); error.ref() = PluginManager::SaveCore(process_sp, core_file, core_style, flavor); @@ -1262,3 +1285,11 @@ lldb::SBError SBProcess::DeallocateMemory(lldb::addr_t ptr) { } return sb_error; } + +lldb::SBScriptObject SBProcess::GetScriptedImplementation() { + LLDB_INSTRUMENT_VA(this); + ProcessSP process_sp(GetSP()); + return lldb::SBScriptObject((process_sp) ? process_sp->GetImplementation() + : nullptr, + eScriptLanguageDefault); +} |
