summaryrefslogtreecommitdiff
path: root/source/Target/Process.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Target/Process.cpp')
-rw-r--r--source/Target/Process.cpp837
1 files changed, 411 insertions, 426 deletions
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index 6c634dba00c7f..ed0b951fbce1a 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -13,7 +13,6 @@
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/Threading.h"
-#include "Plugins/Process/Utility/InferiorCallPOSIX.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Debugger.h"
@@ -59,6 +58,7 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanBase.h"
+#include "lldb/Target/ThreadPlanCallFunction.h"
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/Event.h"
#include "lldb/Utility/Log.h"
@@ -112,55 +112,12 @@ public:
}
};
-static constexpr PropertyDefinition g_properties[] = {
- {"disable-memory-cache", OptionValue::eTypeBoolean, false,
- DISABLE_MEM_CACHE_DEFAULT, nullptr, {},
- "Disable reading and caching of memory in fixed-size units."},
- {"extra-startup-command", OptionValue::eTypeArray, false,
- OptionValue::eTypeString, nullptr, {},
- "A list containing extra commands understood by the particular process "
- "plugin used. "
- "For instance, to turn on debugserver logging set this to "
- "\"QSetLogging:bitmask=LOG_DEFAULT;\""},
- {"ignore-breakpoints-in-expressions", OptionValue::eTypeBoolean, true, true,
- nullptr, {},
- "If true, breakpoints will be ignored during expression evaluation."},
- {"unwind-on-error-in-expressions", OptionValue::eTypeBoolean, true, true,
- nullptr, {}, "If true, errors in expression evaluation will unwind "
- "the stack back to the state before the call."},
- {"python-os-plugin-path", OptionValue::eTypeFileSpec, false, true, nullptr,
- {}, "A path to a python OS plug-in module file that contains a "
- "OperatingSystemPlugIn class."},
- {"stop-on-sharedlibrary-events", OptionValue::eTypeBoolean, true, false,
- nullptr, {},
- "If true, stop when a shared library is loaded or unloaded."},
- {"detach-keeps-stopped", OptionValue::eTypeBoolean, true, false, nullptr,
- {}, "If true, detach will attempt to keep the process stopped."},
- {"memory-cache-line-size", OptionValue::eTypeUInt64, false, 512, nullptr,
- {}, "The memory cache line size"},
- {"optimization-warnings", OptionValue::eTypeBoolean, false, true, nullptr,
- {}, "If true, warn when stopped in code that is optimized where "
- "stepping and variable availability may not behave as expected."},
- {"stop-on-exec", OptionValue::eTypeBoolean, true, true,
- nullptr, {},
- "If true, stop when a shared library is loaded or unloaded."},
- {"utility-expression-timeout", OptionValue::eTypeUInt64, false, 15,
- nullptr, {},
- "The time in seconds to wait for LLDB-internal utility expressions."}
-};
+#define LLDB_PROPERTIES_process
+#include "TargetProperties.inc"
enum {
- ePropertyDisableMemCache,
- ePropertyExtraStartCommand,
- ePropertyIgnoreBreakpointsInExpressions,
- ePropertyUnwindOnErrorInExpressions,
- ePropertyPythonOSPluginPath,
- ePropertyStopOnSharedLibraryEvents,
- ePropertyDetachKeepsStopped,
- ePropertyMemCacheLineSize,
- ePropertyWarningOptimization,
- ePropertyStopOnExec,
- ePropertyUtilityExpressionTimeout,
+#define LLDB_PROPERTIES_process
+#include "TargetPropertiesEnum.inc"
};
ProcessProperties::ProcessProperties(lldb_private::Process *process)
@@ -171,7 +128,7 @@ ProcessProperties::ProcessProperties(lldb_private::Process *process)
// Global process properties, set them up one time
m_collection_sp =
std::make_shared<ProcessOptionValueProperties>(ConstString("process"));
- m_collection_sp->Initialize(g_properties);
+ m_collection_sp->Initialize(g_process_properties);
m_collection_sp->AppendProperty(
ConstString("thread"), ConstString("Settings specific to threads."),
true, Thread::GetGlobalProperties()->GetValueProperties());
@@ -196,13 +153,13 @@ void ProcessProperties::OptionValueChangedCallback(void *baton,
bool ProcessProperties::GetDisableMemoryCache() const {
const uint32_t idx = ePropertyDisableMemCache;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
uint64_t ProcessProperties::GetMemoryCacheLineSize() const {
const uint32_t idx = ePropertyMemCacheLineSize;
return m_collection_sp->GetPropertyAtIndexAsUInt64(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_process_properties[idx].default_uint_value);
}
Args ProcessProperties::GetExtraStartupCommands() const {
@@ -230,7 +187,7 @@ void ProcessProperties::SetPythonOSPluginPath(const FileSpec &file) {
bool ProcessProperties::GetIgnoreBreakpointsInExpressions() const {
const uint32_t idx = ePropertyIgnoreBreakpointsInExpressions;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
void ProcessProperties::SetIgnoreBreakpointsInExpressions(bool ignore) {
@@ -241,7 +198,7 @@ void ProcessProperties::SetIgnoreBreakpointsInExpressions(bool ignore) {
bool ProcessProperties::GetUnwindOnErrorInExpressions() const {
const uint32_t idx = ePropertyUnwindOnErrorInExpressions;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
void ProcessProperties::SetUnwindOnErrorInExpressions(bool ignore) {
@@ -252,7 +209,7 @@ void ProcessProperties::SetUnwindOnErrorInExpressions(bool ignore) {
bool ProcessProperties::GetStopOnSharedLibraryEvents() const {
const uint32_t idx = ePropertyStopOnSharedLibraryEvents;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
void ProcessProperties::SetStopOnSharedLibraryEvents(bool stop) {
@@ -263,7 +220,7 @@ void ProcessProperties::SetStopOnSharedLibraryEvents(bool stop) {
bool ProcessProperties::GetDetachKeepsStopped() const {
const uint32_t idx = ePropertyDetachKeepsStopped;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
void ProcessProperties::SetDetachKeepsStopped(bool stop) {
@@ -274,19 +231,19 @@ void ProcessProperties::SetDetachKeepsStopped(bool stop) {
bool ProcessProperties::GetWarningsOptimization() const {
const uint32_t idx = ePropertyWarningOptimization;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
bool ProcessProperties::GetStopOnExec() const {
const uint32_t idx = ePropertyStopOnExec;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
std::chrono::seconds ProcessProperties::GetUtilityExpressionTimeout() const {
const uint32_t idx = ePropertyUtilityExpressionTimeout;
uint64_t value = m_collection_sp->GetPropertyAtIndexAsUInt64(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_process_properties[idx].default_uint_value);
return std::chrono::seconds(value);
}
@@ -544,8 +501,7 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp,
CheckInWithManager();
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p Process::Process()", static_cast<void *>(this));
+ LLDB_LOGF(log, "%p Process::Process()", static_cast<void *>(this));
if (!m_unix_signals_sp)
m_unix_signals_sp = std::make_shared<UnixSignals>();
@@ -593,8 +549,7 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp,
Process::~Process() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p Process::~Process()", static_cast<void *>(this));
+ LLDB_LOGF(log, "%p Process::~Process()", static_cast<void *>(this));
StopPrivateStateThread();
// ThreadList::Clear() will try to acquire this process's mutex, so
@@ -781,10 +736,10 @@ StateType Process::WaitForProcessToStop(const Timeout<std::micro> &timeout,
if (!wait_always && StateIsStoppedState(state, true) &&
StateIsStoppedState(GetPrivateState(), true)) {
- if (log)
- log->Printf("Process::%s returning without waiting for events; process "
- "private and public states are already 'stopped'.",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "Process::%s returning without waiting for events; process "
+ "private and public states are already 'stopped'.",
+ __FUNCTION__);
// We need to toggle the run lock as this won't get done in
// SetPublicState() if the process is hijacked.
if (hijack_listener_sp && use_run_lock)
@@ -1073,19 +1028,17 @@ StateType Process::GetStateChangedEvents(EventSP &event_sp,
Event *Process::PeekAtStateChangedEvents() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::%s...", __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s...", __FUNCTION__);
Event *event_ptr;
event_ptr = m_listener_sp->PeekAtNextEventForBroadcasterWithType(
this, eBroadcastBitStateChanged);
if (log) {
if (event_ptr) {
- log->Printf(
- "Process::%s (event_ptr) => %s", __FUNCTION__,
- StateAsCString(ProcessEventData::GetStateFromEvent(event_ptr)));
+ LLDB_LOGF(log, "Process::%s (event_ptr) => %s", __FUNCTION__,
+ StateAsCString(ProcessEventData::GetStateFromEvent(event_ptr)));
} else {
- log->Printf("Process::%s no events found", __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s no events found", __FUNCTION__);
}
}
return event_ptr;
@@ -1149,17 +1102,14 @@ bool Process::SetExitStatus(int status, const char *cstr) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STATE |
LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "Process::SetExitStatus (status=%i (0x%8.8x), description=%s%s%s)",
- status, status, cstr ? "\"" : "", cstr ? cstr : "NULL",
- cstr ? "\"" : "");
+ LLDB_LOGF(
+ log, "Process::SetExitStatus (status=%i (0x%8.8x), description=%s%s%s)",
+ status, status, cstr ? "\"" : "", cstr ? cstr : "NULL", cstr ? "\"" : "");
// We were already in the exited state
if (m_private_state.GetValue() == eStateExited) {
- if (log)
- log->Printf("Process::SetExitStatus () ignoring exit status because "
- "state was already set to eStateExited");
+ LLDB_LOGF(log, "Process::SetExitStatus () ignoring exit status because "
+ "state was already set to eStateExited");
return false;
}
@@ -1207,10 +1157,10 @@ bool Process::SetProcessExitStatus(
int exit_status // Exit value of process if signal is zero
) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::SetProcessExitStatus (pid=%" PRIu64
- ", exited=%i, signal=%i, exit_status=%i)\n",
- pid, exited, signo, exit_status);
+ LLDB_LOGF(log,
+ "Process::SetProcessExitStatus (pid=%" PRIu64
+ ", exited=%i, signal=%i, exit_status=%i)\n",
+ pid, exited, signo, exit_status);
if (exited) {
TargetSP target_sp(Debugger::FindTargetWithProcessID(pid));
@@ -1353,9 +1303,8 @@ StateType Process::GetState() {
void Process::SetPublicState(StateType new_state, bool restarted) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STATE |
LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::SetPublicState (state = %s, restarted = %i)",
- StateAsCString(new_state), restarted);
+ LLDB_LOGF(log, "Process::SetPublicState (state = %s, restarted = %i)",
+ StateAsCString(new_state), restarted);
const StateType old_state = m_public_state.GetValue();
m_public_state.SetValue(new_state);
@@ -1364,19 +1313,17 @@ void Process::SetPublicState(StateType new_state, bool restarted) {
// program to run.
if (!StateChangedIsExternallyHijacked()) {
if (new_state == eStateDetached) {
- if (log)
- log->Printf(
- "Process::SetPublicState (%s) -- unlocking run lock for detach",
- StateAsCString(new_state));
+ LLDB_LOGF(log,
+ "Process::SetPublicState (%s) -- unlocking run lock for detach",
+ StateAsCString(new_state));
m_public_run_lock.SetStopped();
} else {
const bool old_state_is_stopped = StateIsStoppedState(old_state, false);
const bool new_state_is_stopped = StateIsStoppedState(new_state, false);
if ((old_state_is_stopped != new_state_is_stopped)) {
if (new_state_is_stopped && !restarted) {
- if (log)
- log->Printf("Process::SetPublicState (%s) -- unlocking run lock",
- StateAsCString(new_state));
+ LLDB_LOGF(log, "Process::SetPublicState (%s) -- unlocking run lock",
+ StateAsCString(new_state));
m_public_run_lock.SetStopped();
}
}
@@ -1387,12 +1334,10 @@ void Process::SetPublicState(StateType new_state, bool restarted) {
Status Process::Resume() {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STATE |
LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::Resume -- locking run lock");
+ LLDB_LOGF(log, "Process::Resume -- locking run lock");
if (!m_public_run_lock.TrySetRunning()) {
Status error("Resume request failed - process still running.");
- if (log)
- log->Printf("Process::Resume: -- TrySetRunning failed, not resuming.");
+ LLDB_LOGF(log, "Process::Resume: -- TrySetRunning failed, not resuming.");
return error;
}
Status error = PrivateResume();
@@ -1408,12 +1353,10 @@ static const char *g_resume_sync_name = "lldb.Process.ResumeSynchronous.hijack";
Status Process::ResumeSynchronous(Stream *stream) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STATE |
LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::ResumeSynchronous -- locking run lock");
+ LLDB_LOGF(log, "Process::ResumeSynchronous -- locking run lock");
if (!m_public_run_lock.TrySetRunning()) {
Status error("Resume request failed - process still running.");
- if (log)
- log->Printf("Process::Resume: -- TrySetRunning failed, not resuming.");
+ LLDB_LOGF(log, "Process::Resume: -- TrySetRunning failed, not resuming.");
return error;
}
@@ -1472,8 +1415,7 @@ void Process::SetPrivateState(StateType new_state) {
LIBLLDB_LOG_PROCESS));
bool state_changed = false;
- if (log)
- log->Printf("Process::SetPrivateState (%s)", StateAsCString(new_state));
+ LLDB_LOGF(log, "Process::SetPrivateState (%s)", StateAsCString(new_state));
std::lock_guard<std::recursive_mutex> thread_guard(m_thread_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_private_state.GetMutex());
@@ -1512,9 +1454,8 @@ void Process::SetPrivateState(StateType new_state) {
if (!m_mod_id.IsLastResumeForUserExpression())
m_mod_id.SetStopEventForLastNaturalStopID(event_sp);
m_memory_cache.Clear();
- if (log)
- log->Printf("Process::SetPrivateState (%s) stop_id = %u",
- StateAsCString(new_state), m_mod_id.GetStopID());
+ LLDB_LOGF(log, "Process::SetPrivateState (%s) stop_id = %u",
+ StateAsCString(new_state), m_mod_id.GetStopID());
}
// Use our target to get a shared pointer to ourselves...
@@ -1523,10 +1464,9 @@ void Process::SetPrivateState(StateType new_state) {
else
m_private_state_broadcaster.BroadcastEvent(event_sp);
} else {
- if (log)
- log->Printf(
- "Process::SetPrivateState (%s) state didn't change. Ignoring...",
- StateAsCString(new_state));
+ LLDB_LOGF(log,
+ "Process::SetPrivateState (%s) state didn't change. Ignoring...",
+ StateAsCString(new_state));
}
}
@@ -1709,7 +1649,7 @@ Process::CreateBreakpointSite(const BreakpointLocationSP &owner,
Address symbol_address = symbol->GetAddress();
load_addr = ResolveIndirectFunction(&symbol_address, error);
if (!error.Success() && show_error) {
- GetTarget().GetDebugger().GetErrorFile()->Printf(
+ GetTarget().GetDebugger().GetErrorStream().Printf(
"warning: failed to resolve indirect function at 0x%" PRIx64
" for breakpoint %i.%i: %s\n",
symbol->GetLoadAddress(&GetTarget()),
@@ -1748,7 +1688,7 @@ Process::CreateBreakpointSite(const BreakpointLocationSP &owner,
} else {
if (show_error || use_hardware) {
// Report error for setting breakpoint...
- GetTarget().GetDebugger().GetErrorFile()->Printf(
+ GetTarget().GetDebugger().GetErrorStream().Printf(
"warning: failed to set breakpoint site at 0x%" PRIx64
" for breakpoint %i.%i: %s\n",
load_addr, owner->GetBreakpoint().GetID(), owner->GetID(),
@@ -1816,16 +1756,15 @@ Status Process::EnableSoftwareBreakpoint(BreakpointSite *bp_site) {
assert(bp_site != nullptr);
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
const addr_t bp_addr = bp_site->GetLoadAddress();
- if (log)
- log->Printf(
- "Process::EnableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64,
- bp_site->GetID(), (uint64_t)bp_addr);
+ LLDB_LOGF(
+ log, "Process::EnableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64,
+ bp_site->GetID(), (uint64_t)bp_addr);
if (bp_site->IsEnabled()) {
- if (log)
- log->Printf(
- "Process::EnableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
- " -- already enabled",
- bp_site->GetID(), (uint64_t)bp_addr);
+ LLDB_LOGF(
+ log,
+ "Process::EnableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
+ " -- already enabled",
+ bp_site->GetID(), (uint64_t)bp_addr);
return error;
}
@@ -1864,10 +1803,10 @@ Status Process::EnableSoftwareBreakpoint(BreakpointSite *bp_site) {
bp_opcode_size) == 0) {
bp_site->SetEnabled(true);
bp_site->SetType(BreakpointSite::eSoftware);
- if (log)
- log->Printf("Process::EnableSoftwareBreakpoint (site_id = %d) "
- "addr = 0x%" PRIx64 " -- SUCCESS",
- bp_site->GetID(), (uint64_t)bp_addr);
+ LLDB_LOGF(log,
+ "Process::EnableSoftwareBreakpoint (site_id = %d) "
+ "addr = 0x%" PRIx64 " -- SUCCESS",
+ bp_site->GetID(), (uint64_t)bp_addr);
} else
error.SetErrorString(
"failed to verify the breakpoint trap in memory.");
@@ -1880,7 +1819,8 @@ Status Process::EnableSoftwareBreakpoint(BreakpointSite *bp_site) {
error.SetErrorString("Unable to read memory at breakpoint address.");
}
if (log && error.Fail())
- log->Printf(
+ LLDB_LOGF(
+ log,
"Process::EnableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
" -- FAILED: %s",
bp_site->GetID(), (uint64_t)bp_addr, error.AsCString());
@@ -1893,10 +1833,10 @@ Status Process::DisableSoftwareBreakpoint(BreakpointSite *bp_site) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
addr_t bp_addr = bp_site->GetLoadAddress();
lldb::user_id_t breakID = bp_site->GetID();
- if (log)
- log->Printf("Process::DisableSoftwareBreakpoint (breakID = %" PRIu64
- ") addr = 0x%" PRIx64,
- breakID, (uint64_t)bp_addr);
+ LLDB_LOGF(log,
+ "Process::DisableSoftwareBreakpoint (breakID = %" PRIu64
+ ") addr = 0x%" PRIx64,
+ breakID, (uint64_t)bp_addr);
if (bp_site->IsHardware()) {
error.SetErrorString("Breakpoint site is a hardware breakpoint.");
@@ -1943,10 +1883,10 @@ Status Process::DisableSoftwareBreakpoint(BreakpointSite *bp_site) {
break_op_size) == 0) {
// SUCCESS
bp_site->SetEnabled(false);
- if (log)
- log->Printf("Process::DisableSoftwareBreakpoint (site_id = %d) "
- "addr = 0x%" PRIx64 " -- SUCCESS",
- bp_site->GetID(), (uint64_t)bp_addr);
+ LLDB_LOGF(log,
+ "Process::DisableSoftwareBreakpoint (site_id = %d) "
+ "addr = 0x%" PRIx64 " -- SUCCESS",
+ bp_site->GetID(), (uint64_t)bp_addr);
return error;
} else {
if (break_op_found)
@@ -1961,19 +1901,19 @@ Status Process::DisableSoftwareBreakpoint(BreakpointSite *bp_site) {
"Unable to read memory that should contain the breakpoint trap.");
}
} else {
- if (log)
- log->Printf(
- "Process::DisableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
- " -- already disabled",
- bp_site->GetID(), (uint64_t)bp_addr);
+ LLDB_LOGF(
+ log,
+ "Process::DisableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
+ " -- already disabled",
+ bp_site->GetID(), (uint64_t)bp_addr);
return error;
}
- if (log)
- log->Printf(
- "Process::DisableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
- " -- FAILED: %s",
- bp_site->GetID(), (uint64_t)bp_addr, error.AsCString());
+ LLDB_LOGF(
+ log,
+ "Process::DisableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
+ " -- FAILED: %s",
+ bp_site->GetID(), (uint64_t)bp_addr, error.AsCString());
return error;
}
@@ -2371,13 +2311,13 @@ addr_t Process::AllocateMemory(size_t size, uint32_t permissions,
#else
addr_t allocated_addr = DoAllocateMemory(size, permissions, error);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::AllocateMemory(size=%" PRIu64
- ", permissions=%s) => 0x%16.16" PRIx64
- " (m_stop_id = %u m_memory_id = %u)",
- (uint64_t)size, GetPermissionsAsCString(permissions),
- (uint64_t)allocated_addr, m_mod_id.GetStopID(),
- m_mod_id.GetMemoryID());
+ LLDB_LOGF(log,
+ "Process::AllocateMemory(size=%" PRIu64
+ ", permissions=%s) => 0x%16.16" PRIx64
+ " (m_stop_id = %u m_memory_id = %u)",
+ (uint64_t)size, GetPermissionsAsCString(permissions),
+ (uint64_t)allocated_addr, m_mod_id.GetStopID(),
+ m_mod_id.GetMemoryID());
return allocated_addr;
#endif
}
@@ -2403,16 +2343,16 @@ bool Process::CanJIT() {
if (err.Success()) {
m_can_jit = eCanJITYes;
- if (log)
- log->Printf("Process::%s pid %" PRIu64
- " allocation test passed, CanJIT () is true",
- __FUNCTION__, GetID());
+ LLDB_LOGF(log,
+ "Process::%s pid %" PRIu64
+ " allocation test passed, CanJIT () is true",
+ __FUNCTION__, GetID());
} else {
m_can_jit = eCanJITNo;
- if (log)
- log->Printf("Process::%s pid %" PRIu64
- " allocation test failed, CanJIT () is false: %s",
- __FUNCTION__, GetID(), err.AsCString());
+ LLDB_LOGF(log,
+ "Process::%s pid %" PRIu64
+ " allocation test failed, CanJIT () is false: %s",
+ __FUNCTION__, GetID(), err.AsCString());
}
DeallocateMemory(allocated_memory);
@@ -2441,11 +2381,11 @@ Status Process::DeallocateMemory(addr_t ptr) {
error = DoDeallocateMemory(ptr);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::DeallocateMemory(addr=0x%16.16" PRIx64
- ") => err = %s (m_stop_id = %u, m_memory_id = %u)",
- ptr, error.AsCString("SUCCESS"), m_mod_id.GetStopID(),
- m_mod_id.GetMemoryID());
+ LLDB_LOGF(log,
+ "Process::DeallocateMemory(addr=0x%16.16" PRIx64
+ ") => err = %s (m_stop_id = %u, m_memory_id = %u)",
+ ptr, error.AsCString("SUCCESS"), m_mod_id.GetStopID(),
+ m_mod_id.GetMemoryID());
#endif
return error;
}
@@ -2455,8 +2395,9 @@ ModuleSP Process::ReadModuleFromMemory(const FileSpec &file_spec,
size_t size_to_read) {
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (log) {
- log->Printf("Process::ReadModuleFromMemory reading %s binary from memory",
- file_spec.GetPath().c_str());
+ LLDB_LOGF(log,
+ "Process::ReadModuleFromMemory reading %s binary from memory",
+ file_spec.GetPath().c_str());
}
ModuleSP module_sp(new Module(file_spec, ArchSpec()));
if (module_sp) {
@@ -2691,9 +2632,8 @@ Status Process::LoadCore() {
if (!StateIsStoppedState(state, false)) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::Halt() failed to stop, state is: %s",
- StateAsCString(state));
+ LLDB_LOGF(log, "Process::Halt() failed to stop, state is: %s",
+ StateAsCString(state));
error.SetErrorString(
"Did not get stopped event after loading the core file.");
}
@@ -2728,10 +2668,10 @@ Process::AttachCompletionHandler::AttachCompletionHandler(Process *process,
uint32_t exec_count)
: NextEventAction(process), m_exec_count(exec_count) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "Process::AttachCompletionHandler::%s process=%p, exec_count=%" PRIu32,
- __FUNCTION__, static_cast<void *>(process), exec_count);
+ LLDB_LOGF(
+ log,
+ "Process::AttachCompletionHandler::%s process=%p, exec_count=%" PRIu32,
+ __FUNCTION__, static_cast<void *>(process), exec_count);
}
Process::NextEventAction::EventActionResult
@@ -2739,10 +2679,9 @@ Process::AttachCompletionHandler::PerformAction(lldb::EventSP &event_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
StateType state = ProcessEventData::GetStateFromEvent(event_sp.get());
- if (log)
- log->Printf(
- "Process::AttachCompletionHandler::%s called with state %s (%d)",
- __FUNCTION__, StateAsCString(state), static_cast<int>(state));
+ LLDB_LOGF(log,
+ "Process::AttachCompletionHandler::%s called with state %s (%d)",
+ __FUNCTION__, StateAsCString(state), static_cast<int>(state));
switch (state) {
case eStateAttaching:
@@ -2764,18 +2703,18 @@ Process::AttachCompletionHandler::PerformAction(lldb::EventSP &event_sp) {
if (m_exec_count > 0) {
--m_exec_count;
- if (log)
- log->Printf("Process::AttachCompletionHandler::%s state %s: reduced "
- "remaining exec count to %" PRIu32 ", requesting resume",
- __FUNCTION__, StateAsCString(state), m_exec_count);
+ LLDB_LOGF(log,
+ "Process::AttachCompletionHandler::%s state %s: reduced "
+ "remaining exec count to %" PRIu32 ", requesting resume",
+ __FUNCTION__, StateAsCString(state), m_exec_count);
RequestResume();
return eEventActionRetry;
} else {
- if (log)
- log->Printf("Process::AttachCompletionHandler::%s state %s: no more "
- "execs expected to start, continuing with attach",
- __FUNCTION__, StateAsCString(state));
+ LLDB_LOGF(log,
+ "Process::AttachCompletionHandler::%s state %s: no more "
+ "execs expected to start, continuing with attach",
+ __FUNCTION__, StateAsCString(state));
m_process->CompleteAttach();
return eEventActionSuccess;
@@ -2932,8 +2871,7 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
void Process::CompleteAttach() {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS |
LIBLLDB_LOG_TARGET));
- if (log)
- log->Printf("Process::%s()", __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s()", __FUNCTION__);
// Let the process subclass figure out at much as it can about the process
// before we go looking for a dynamic loader plug-in.
@@ -2944,9 +2882,10 @@ void Process::CompleteAttach() {
GetTarget().SetArchitecture(process_arch);
if (log) {
const char *triple_str = process_arch.GetTriple().getTriple().c_str();
- log->Printf("Process::%s replacing process architecture with DidAttach() "
- "architecture: %s",
- __FUNCTION__, triple_str ? triple_str : "<null>");
+ LLDB_LOGF(log,
+ "Process::%s replacing process architecture with DidAttach() "
+ "architecture: %s",
+ __FUNCTION__, triple_str ? triple_str : "<null>");
}
}
@@ -2965,11 +2904,11 @@ void Process::CompleteAttach() {
if (platform_sp) {
GetTarget().SetPlatform(platform_sp);
GetTarget().SetArchitecture(platform_arch);
- if (log)
- log->Printf("Process::%s switching platform to %s and architecture "
- "to %s based on info from attach",
- __FUNCTION__, platform_sp->GetName().AsCString(""),
- platform_arch.GetTriple().getTriple().c_str());
+ LLDB_LOGF(log,
+ "Process::%s switching platform to %s and architecture "
+ "to %s based on info from attach",
+ __FUNCTION__, platform_sp->GetName().AsCString(""),
+ platform_arch.GetTriple().getTriple().c_str());
}
} else if (!process_arch.IsValid()) {
ProcessInstanceInfo process_info;
@@ -2978,11 +2917,11 @@ void Process::CompleteAttach() {
if (process_arch.IsValid() &&
!GetTarget().GetArchitecture().IsExactMatch(process_arch)) {
GetTarget().SetArchitecture(process_arch);
- if (log)
- log->Printf("Process::%s switching architecture to %s based on info "
- "the platform retrieved for pid %" PRIu64,
- __FUNCTION__,
- process_arch.GetTriple().getTriple().c_str(), GetID());
+ LLDB_LOGF(log,
+ "Process::%s switching architecture to %s based on info "
+ "the platform retrieved for pid %" PRIu64,
+ __FUNCTION__, process_arch.GetTriple().getTriple().c_str(),
+ GetID());
}
}
}
@@ -2994,12 +2933,13 @@ void Process::CompleteAttach() {
dyld->DidAttach();
if (log) {
ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
- log->Printf("Process::%s after DynamicLoader::DidAttach(), target "
- "executable is %s (using %s plugin)",
- __FUNCTION__,
- exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str()
- : "<none>",
- dyld->GetPluginName().AsCString("<unnamed>"));
+ LLDB_LOGF(log,
+ "Process::%s after DynamicLoader::DidAttach(), target "
+ "executable is %s (using %s plugin)",
+ __FUNCTION__,
+ exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str()
+ : "<none>",
+ dyld->GetPluginName().AsCString("<unnamed>"));
}
}
@@ -3010,12 +2950,13 @@ void Process::CompleteAttach() {
system_runtime->DidAttach();
if (log) {
ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
- log->Printf("Process::%s after SystemRuntime::DidAttach(), target "
- "executable is %s (using %s plugin)",
- __FUNCTION__,
- exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str()
- : "<none>",
- system_runtime->GetPluginName().AsCString("<unnamed>"));
+ LLDB_LOGF(log,
+ "Process::%s after SystemRuntime::DidAttach(), target "
+ "executable is %s (using %s plugin)",
+ __FUNCTION__,
+ exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str()
+ : "<none>",
+ system_runtime->GetPluginName().AsCString("<unnamed>"));
}
}
@@ -3048,7 +2989,8 @@ void Process::CompleteAttach() {
eLoadDependentsNo);
if (log) {
ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
- log->Printf(
+ LLDB_LOGF(
+ log,
"Process::%s after looping through modules, target executable is %s",
__FUNCTION__,
exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str()
@@ -3092,11 +3034,11 @@ Status Process::ConnectRemote(Stream *strm, llvm::StringRef remote_url) {
Status Process::PrivateResume() {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS |
LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("Process::PrivateResume() m_stop_id = %u, public state: %s "
- "private state: %s",
- m_mod_id.GetStopID(), StateAsCString(m_public_state.GetValue()),
- StateAsCString(m_private_state.GetValue()));
+ LLDB_LOGF(log,
+ "Process::PrivateResume() m_stop_id = %u, public state: %s "
+ "private state: %s",
+ m_mod_id.GetStopID(), StateAsCString(m_public_state.GetValue()),
+ StateAsCString(m_private_state.GetValue()));
// If signals handing status changed we might want to update our signal
// filters before resuming.
@@ -3123,12 +3065,9 @@ Status Process::PrivateResume() {
if (error.Success()) {
DidResume();
m_thread_list.DidResume();
- if (log)
- log->Printf("Process thinks the process has resumed.");
+ LLDB_LOGF(log, "Process thinks the process has resumed.");
} else {
- if (log)
- log->Printf(
- "Process::PrivateResume() DoResume failed.");
+ LLDB_LOGF(log, "Process::PrivateResume() DoResume failed.");
return error;
}
}
@@ -3137,16 +3076,15 @@ Status Process::PrivateResume() {
// from one frame of a set of inlined frames that share the same PC to
// another.) So generate a continue & a stopped event, and let the world
// handle them.
- if (log)
- log->Printf(
- "Process::PrivateResume() asked to simulate a start & stop.");
+ LLDB_LOGF(log,
+ "Process::PrivateResume() asked to simulate a start & stop.");
SetPrivateState(eStateRunning);
SetPrivateState(eStateStopped);
}
- } else if (log)
- log->Printf("Process::PrivateResume() got an error \"%s\".",
- error.AsCString("<unknown error>"));
+ } else
+ LLDB_LOGF(log, "Process::PrivateResume() got an error \"%s\".",
+ error.AsCString("<unknown error>"));
return error;
}
@@ -3199,8 +3137,7 @@ Status Process::StopForDestroyOrDetach(lldb::EventSP &exit_event_sp) {
if (m_public_state.GetValue() == eStateRunning ||
m_private_state.GetValue() == eStateRunning) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::%s() About to stop.", __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s() About to stop.", __FUNCTION__);
ListenerSP listener_sp(
Listener::MakeListener("lldb.Process.StopForDestroyOrDetach.hijack"));
@@ -3220,17 +3157,15 @@ Status Process::StopForDestroyOrDetach(lldb::EventSP &exit_event_sp) {
// anymore...
if (state == eStateExited || m_private_state.GetValue() == eStateExited) {
- if (log)
- log->Printf("Process::%s() Process exited while waiting to stop.",
- __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s() Process exited while waiting to stop.",
+ __FUNCTION__);
return error;
} else
exit_event_sp.reset(); // It is ok to consume any non-exit stop events
if (state != eStateStopped) {
- if (log)
- log->Printf("Process::%s() failed to stop, state is: %s", __FUNCTION__,
- StateAsCString(state));
+ LLDB_LOGF(log, "Process::%s() failed to stop, state is: %s", __FUNCTION__,
+ StateAsCString(state));
// If we really couldn't stop the process then we should just error out
// here, but if the lower levels just bobbled sending the event and we
// really are stopped, then continue on.
@@ -3475,10 +3410,10 @@ bool Process::ShouldBroadcastEvent(Event *event_ptr) {
m_stdio_communication.SynchronizeWithReadThread();
RefreshStateAfterStop();
if (ProcessEventData::GetInterruptedFromEvent(event_ptr)) {
- if (log)
- log->Printf("Process::ShouldBroadcastEvent (%p) stopped due to an "
- "interrupt, state: %s",
- static_cast<void *>(event_ptr), StateAsCString(state));
+ LLDB_LOGF(log,
+ "Process::ShouldBroadcastEvent (%p) stopped due to an "
+ "interrupt, state: %s",
+ static_cast<void *>(event_ptr), StateAsCString(state));
// Even though we know we are going to stop, we should let the threads
// have a look at the stop, so they can properly set their state.
m_thread_list.ShouldStop(event_ptr);
@@ -3496,11 +3431,11 @@ bool Process::ShouldBroadcastEvent(Event *event_ptr) {
if (was_restarted || should_resume || m_resume_requested) {
Vote stop_vote = m_thread_list.ShouldReportStop(event_ptr);
- if (log)
- log->Printf("Process::ShouldBroadcastEvent: should_resume: %i state: "
- "%s was_restarted: %i stop_vote: %d.",
- should_resume, StateAsCString(state), was_restarted,
- stop_vote);
+ LLDB_LOGF(log,
+ "Process::ShouldBroadcastEvent: should_resume: %i state: "
+ "%s was_restarted: %i stop_vote: %d.",
+ should_resume, StateAsCString(state), was_restarted,
+ stop_vote);
switch (stop_vote) {
case eVoteYes:
@@ -3513,10 +3448,10 @@ bool Process::ShouldBroadcastEvent(Event *event_ptr) {
}
if (!was_restarted) {
- if (log)
- log->Printf("Process::ShouldBroadcastEvent (%p) Restarting process "
- "from state: %s",
- static_cast<void *>(event_ptr), StateAsCString(state));
+ LLDB_LOGF(log,
+ "Process::ShouldBroadcastEvent (%p) Restarting process "
+ "from state: %s",
+ static_cast<void *>(event_ptr), StateAsCString(state));
ProcessEventData::SetRestartedInEvent(event_ptr, true);
PrivateResume();
}
@@ -3543,12 +3478,12 @@ bool Process::ShouldBroadcastEvent(Event *event_ptr) {
if (return_value)
m_last_broadcast_state = state;
- if (log)
- log->Printf("Process::ShouldBroadcastEvent (%p) => new state: %s, last "
- "broadcast state: %s - %s",
- static_cast<void *>(event_ptr), StateAsCString(state),
- StateAsCString(m_last_broadcast_state),
- return_value ? "YES" : "NO");
+ LLDB_LOGF(log,
+ "Process::ShouldBroadcastEvent (%p) => new state: %s, last "
+ "broadcast state: %s - %s",
+ static_cast<void *>(event_ptr), StateAsCString(state),
+ StateAsCString(m_last_broadcast_state),
+ return_value ? "YES" : "NO");
return return_value;
}
@@ -3556,10 +3491,9 @@ bool Process::StartPrivateStateThread(bool is_secondary_thread) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS));
bool already_running = PrivateStateThreadIsValid();
- if (log)
- log->Printf("Process::%s()%s ", __FUNCTION__,
- already_running ? " already running"
- : " starting private state thread");
+ LLDB_LOGF(log, "Process::%s()%s ", __FUNCTION__,
+ already_running ? " already running"
+ : " starting private state thread");
if (!is_secondary_thread && already_running)
return true;
@@ -3617,9 +3551,9 @@ void Process::StopPrivateStateThread() {
ControlPrivateStateThread(eBroadcastInternalStateControlStop);
else {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "Went to stop the private state thread, but it was already invalid.");
+ LLDB_LOGF(
+ log,
+ "Went to stop the private state thread, but it was already invalid.");
}
}
@@ -3630,8 +3564,7 @@ void Process::ControlPrivateStateThread(uint32_t signal) {
signal == eBroadcastInternalStateControlPause ||
signal == eBroadcastInternalStateControlResume);
- if (log)
- log->Printf("Process::%s (signal = %d)", __FUNCTION__, signal);
+ LLDB_LOGF(log, "Process::%s (signal = %d)", __FUNCTION__, signal);
// Signal the private state thread
if (m_private_state_thread.IsJoinable()) {
@@ -3640,8 +3573,7 @@ void Process::ControlPrivateStateThread(uint32_t signal) {
// possible that the thread state is invalid but that the thread is waiting
// on a control event instead of simply being on its way out (this should
// not happen, but it apparently can).
- if (log)
- log->Printf("Sending control event of type: %d.", signal);
+ LLDB_LOGF(log, "Sending control event of type: %d.", signal);
std::shared_ptr<EventDataReceipt> event_receipt_sp(new EventDataReceipt());
m_private_state_control_broadcaster.BroadcastEvent(signal,
event_receipt_sp);
@@ -3669,9 +3601,9 @@ void Process::ControlPrivateStateThread(uint32_t signal) {
m_private_state_thread.Reset();
}
} else {
- if (log)
- log->Printf(
- "Private state thread already dead, no need to signal it to stop.");
+ LLDB_LOGF(
+ log,
+ "Private state thread already dead, no need to signal it to stop.");
}
}
@@ -3694,8 +3626,7 @@ void Process::HandlePrivateEvent(EventSP &event_sp) {
if (m_next_event_action_up) {
NextEventAction::EventActionResult action_result =
m_next_event_action_up->PerformAction(event_sp);
- if (log)
- log->Printf("Ran next event action, result was %d.", action_result);
+ LLDB_LOGF(log, "Ran next event action, result was %d.", action_result);
switch (action_result) {
case NextEventAction::eEventActionSuccess:
@@ -3726,11 +3657,12 @@ void Process::HandlePrivateEvent(EventSP &event_sp) {
if (should_broadcast) {
const bool is_hijacked = IsHijackedForEvent(eBroadcastBitStateChanged);
if (log) {
- log->Printf("Process::%s (pid = %" PRIu64
- ") broadcasting new state %s (old state %s) to %s",
- __FUNCTION__, GetID(), StateAsCString(new_state),
- StateAsCString(GetState()),
- is_hijacked ? "hijacked" : "public");
+ LLDB_LOGF(log,
+ "Process::%s (pid = %" PRIu64
+ ") broadcasting new state %s (old state %s) to %s",
+ __FUNCTION__, GetID(), StateAsCString(new_state),
+ StateAsCString(GetState()),
+ is_hijacked ? "hijacked" : "public");
}
Process::ProcessEventData::SetUpdateStateOnRemoval(event_sp.get());
if (StateIsRunningState(new_state)) {
@@ -3742,9 +3674,8 @@ void Process::HandlePrivateEvent(EventSP &event_sp) {
PushProcessIOHandler();
m_iohandler_sync.SetValue(m_iohandler_sync.GetValue() + 1,
eBroadcastAlways);
- if (log)
- log->Printf("Process::%s updated m_iohandler_sync to %d",
- __FUNCTION__, m_iohandler_sync.GetValue());
+ LLDB_LOGF(log, "Process::%s updated m_iohandler_sync to %d",
+ __FUNCTION__, m_iohandler_sync.GetValue());
}
} else if (StateIsStoppedState(new_state, false)) {
if (!Process::ProcessEventData::GetRestartedFromEvent(event_sp.get())) {
@@ -3785,7 +3716,8 @@ void Process::HandlePrivateEvent(EventSP &event_sp) {
BroadcastEvent(event_sp);
} else {
if (log) {
- log->Printf(
+ LLDB_LOGF(
+ log,
"Process::%s (pid = %" PRIu64
") suppressing state %s (old state %s): should_broadcast == false",
__FUNCTION__, GetID(), StateAsCString(new_state),
@@ -3820,9 +3752,8 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) {
bool control_only = true;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::%s (arg = %p, pid = %" PRIu64 ") thread starting...",
- __FUNCTION__, static_cast<void *>(this), GetID());
+ LLDB_LOGF(log, "Process::%s (arg = %p, pid = %" PRIu64 ") thread starting...",
+ __FUNCTION__, static_cast<void *>(this), GetID());
bool exit_now = false;
bool interrupt_requested = false;
@@ -3830,11 +3761,11 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) {
EventSP event_sp;
GetEventsPrivate(event_sp, llvm::None, control_only);
if (event_sp->BroadcasterIs(&m_private_state_control_broadcaster)) {
- if (log)
- log->Printf("Process::%s (arg = %p, pid = %" PRIu64
- ") got a control event: %d",
- __FUNCTION__, static_cast<void *>(this), GetID(),
- event_sp->GetType());
+ LLDB_LOGF(log,
+ "Process::%s (arg = %p, pid = %" PRIu64
+ ") got a control event: %d",
+ __FUNCTION__, static_cast<void *>(this), GetID(),
+ event_sp->GetType());
switch (event_sp->GetType()) {
case eBroadcastInternalStateControlStop:
@@ -3853,23 +3784,24 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) {
continue;
} else if (event_sp->GetType() == eBroadcastBitInterrupt) {
if (m_public_state.GetValue() == eStateAttaching) {
- if (log)
- log->Printf("Process::%s (arg = %p, pid = %" PRIu64
- ") woke up with an interrupt while attaching - "
- "forwarding interrupt.",
- __FUNCTION__, static_cast<void *>(this), GetID());
+ LLDB_LOGF(log,
+ "Process::%s (arg = %p, pid = %" PRIu64
+ ") woke up with an interrupt while attaching - "
+ "forwarding interrupt.",
+ __FUNCTION__, static_cast<void *>(this), GetID());
BroadcastEvent(eBroadcastBitInterrupt, nullptr);
} else if (StateIsRunningState(m_last_broadcast_state)) {
- if (log)
- log->Printf("Process::%s (arg = %p, pid = %" PRIu64
- ") woke up with an interrupt - Halting.",
- __FUNCTION__, static_cast<void *>(this), GetID());
+ LLDB_LOGF(log,
+ "Process::%s (arg = %p, pid = %" PRIu64
+ ") woke up with an interrupt - Halting.",
+ __FUNCTION__, static_cast<void *>(this), GetID());
Status error = HaltPrivate();
if (error.Fail() && log)
- log->Printf("Process::%s (arg = %p, pid = %" PRIu64
- ") failed to halt the process: %s",
- __FUNCTION__, static_cast<void *>(this), GetID(),
- error.AsCString());
+ LLDB_LOGF(log,
+ "Process::%s (arg = %p, pid = %" PRIu64
+ ") failed to halt the process: %s",
+ __FUNCTION__, static_cast<void *>(this), GetID(),
+ error.AsCString());
// Halt should generate a stopped event. Make a note of the fact that
// we were doing the interrupt, so we can set the interrupted flag
// after we receive the event. We deliberately set this to true even if
@@ -3883,10 +3815,9 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) {
// request. We use m_last_broadcast_state, because the Stopped event
// may not have been popped of the event queue yet, which is when the
// public state gets updated.
- if (log)
- log->Printf(
- "Process::%s ignoring interrupt as we have already stopped.",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "Process::%s ignoring interrupt as we have already stopped.",
+ __FUNCTION__);
}
continue;
}
@@ -3908,9 +3839,10 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) {
ProcessEventData::SetInterruptedInEvent(event_sp.get(), true);
interrupt_requested = false;
} else if (log) {
- log->Printf("Process::%s interrupt_requested, but a non-stopped "
- "state '%s' received.",
- __FUNCTION__, StateAsCString(internal_state));
+ LLDB_LOGF(log,
+ "Process::%s interrupt_requested, but a non-stopped "
+ "state '%s' received.",
+ __FUNCTION__, StateAsCString(internal_state));
}
}
@@ -3919,20 +3851,19 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) {
if (internal_state == eStateInvalid || internal_state == eStateExited ||
internal_state == eStateDetached) {
- if (log)
- log->Printf("Process::%s (arg = %p, pid = %" PRIu64
- ") about to exit with internal state %s...",
- __FUNCTION__, static_cast<void *>(this), GetID(),
- StateAsCString(internal_state));
+ LLDB_LOGF(log,
+ "Process::%s (arg = %p, pid = %" PRIu64
+ ") about to exit with internal state %s...",
+ __FUNCTION__, static_cast<void *>(this), GetID(),
+ StateAsCString(internal_state));
break;
}
}
// Verify log is still enabled before attempting to write to it...
- if (log)
- log->Printf("Process::%s (arg = %p, pid = %" PRIu64 ") thread exiting...",
- __FUNCTION__, static_cast<void *>(this), GetID());
+ LLDB_LOGF(log, "Process::%s (arg = %p, pid = %" PRIu64 ") thread exiting...",
+ __FUNCTION__, static_cast<void *>(this), GetID());
// If we are a secondary thread, then the primary thread we are working for
// will have already acquired the public_run_lock, and isn't done with what
@@ -4042,10 +3973,10 @@ void Process::ProcessEventData::DoOnRemoval(Event *event_ptr) {
if (curr_thread_list.GetSize() != num_threads) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP |
LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "Number of threads changed from %u to %u while processing event.",
- num_threads, curr_thread_list.GetSize());
+ LLDB_LOGF(
+ log,
+ "Number of threads changed from %u to %u while processing event.",
+ num_threads, curr_thread_list.GetSize());
break;
}
@@ -4054,10 +3985,10 @@ void Process::ProcessEventData::DoOnRemoval(Event *event_ptr) {
if (thread_sp->GetIndexID() != thread_index_array[idx]) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP |
LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("The thread at position %u changed from %u to %u while "
- "processing event.",
- idx, thread_index_array[idx], thread_sp->GetIndexID());
+ LLDB_LOGF(log,
+ "The thread at position %u changed from %u to %u while "
+ "processing event.",
+ idx, thread_index_array[idx], thread_sp->GetIndexID());
break;
}
@@ -4303,9 +4234,8 @@ size_t Process::GetAsyncProfileData(char *buf, size_t buf_size, Status &error) {
size_t bytes_available = one_profile_data.size();
if (bytes_available > 0) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::GetProfileData (buf = %p, size = %" PRIu64 ")",
- static_cast<void *>(buf), static_cast<uint64_t>(buf_size));
+ LLDB_LOGF(log, "Process::GetProfileData (buf = %p, size = %" PRIu64 ")",
+ static_cast<void *>(buf), static_cast<uint64_t>(buf_size));
if (bytes_available > buf_size) {
memcpy(buf, one_profile_data.c_str(), buf_size);
one_profile_data.erase(0, buf_size);
@@ -4325,9 +4255,8 @@ size_t Process::GetSTDOUT(char *buf, size_t buf_size, Status &error) {
size_t bytes_available = m_stdout_data.size();
if (bytes_available > 0) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::GetSTDOUT (buf = %p, size = %" PRIu64 ")",
- static_cast<void *>(buf), static_cast<uint64_t>(buf_size));
+ LLDB_LOGF(log, "Process::GetSTDOUT (buf = %p, size = %" PRIu64 ")",
+ static_cast<void *>(buf), static_cast<uint64_t>(buf_size));
if (bytes_available > buf_size) {
memcpy(buf, m_stdout_data.c_str(), buf_size);
m_stdout_data.erase(0, buf_size);
@@ -4345,9 +4274,8 @@ size_t Process::GetSTDERR(char *buf, size_t buf_size, Status &error) {
size_t bytes_available = m_stderr_data.size();
if (bytes_available > 0) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::GetSTDERR (buf = %p, size = %" PRIu64 ")",
- static_cast<void *>(buf), static_cast<uint64_t>(buf_size));
+ LLDB_LOGF(log, "Process::GetSTDERR (buf = %p, size = %" PRIu64 ")",
+ static_cast<void *>(buf), static_cast<uint64_t>(buf_size));
if (bytes_available > buf_size) {
memcpy(buf, m_stderr_data.c_str(), buf_size);
m_stderr_data.erase(0, buf_size);
@@ -4371,9 +4299,10 @@ public:
IOHandlerProcessSTDIO(Process *process, int write_fd)
: IOHandler(process->GetTarget().GetDebugger(),
IOHandler::Type::ProcessIO),
- m_process(process), m_write_file(write_fd, false) {
+ m_process(process),
+ m_read_file(GetInputFD(), File::eOpenOptionRead, false),
+ m_write_file(write_fd, File::eOpenOptionWrite, false) {
m_pipe.CreateNew(false);
- m_read_file.SetDescriptor(GetInputFD(), false);
}
~IOHandlerProcessSTDIO() override = default;
@@ -4493,9 +4422,9 @@ public:
protected:
Process *m_process;
- File m_read_file; // Read from this file (usually actual STDIN for LLDB
- File m_write_file; // Write to this file (usually the master pty for getting
- // io to debuggee)
+ NativeFile m_read_file; // Read from this file (usually actual STDIN for LLDB
+ NativeFile m_write_file; // Write to this file (usually the master pty for
+ // getting io to debuggee)
Pipe m_pipe;
std::atomic<bool> m_is_running{false};
};
@@ -4532,8 +4461,7 @@ bool Process::PushProcessIOHandler() {
IOHandlerSP io_handler_sp(m_process_input_reader);
if (io_handler_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::%s pushing IO handler", __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s pushing IO handler", __FUNCTION__);
io_handler_sp->SetIsDone(false);
// If we evaluate an utility function, then we don't cancel the current
@@ -4797,9 +4725,8 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
// public events. The simplest thing to do is to spin up a temporary thread
// to handle private state thread events while we are fielding public
// events here.
- if (log)
- log->Printf("Running thread plan on private state thread, spinning up "
- "another state thread to handle the events.");
+ LLDB_LOGF(log, "Running thread plan on private state thread, spinning up "
+ "another state thread to handle the events.");
backup_private_state_thread = m_private_state_thread;
@@ -4854,9 +4781,10 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
if (log) {
StreamString s;
thread_plan_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
- log->Printf("Process::RunThreadPlan(): Resuming thread %u - 0x%4.4" PRIx64
- " to run thread plan \"%s\".",
- thread->GetIndexID(), thread->GetID(), s.GetData());
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): Resuming thread %u - 0x%4.4" PRIx64
+ " to run thread plan \"%s\".",
+ thread->GetIndexID(), thread->GetID(), s.GetData());
}
bool got_event;
@@ -4877,10 +4805,9 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
if (!options.GetStopOthers() || !options.GetTryAllThreads())
before_first_timeout = false;
- if (log)
- log->Printf("Stop others: %u, try all: %u, before_first: %u.\n",
- options.GetStopOthers(), options.GetTryAllThreads(),
- before_first_timeout);
+ LLDB_LOGF(log, "Stop others: %u, try all: %u, before_first: %u.\n",
+ options.GetStopOthers(), options.GetTryAllThreads(),
+ before_first_timeout);
// This isn't going to work if there are unfetched events on the queue. Are
// there cases where we might want to run the remaining events here, and
@@ -4919,10 +4846,10 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
// loop. The only exception is if we get two running events with no
// intervening stop, which can happen, we will just wait for then next
// stop event.
- if (log)
- log->Printf("Top of while loop: do_resume: %i handle_running_event: %i "
- "before_first_timeout: %i.",
- do_resume, handle_running_event, before_first_timeout);
+ LLDB_LOGF(log,
+ "Top of while loop: do_resume: %i handle_running_event: %i "
+ "before_first_timeout: %i.",
+ do_resume, handle_running_event, before_first_timeout);
if (do_resume || handle_running_event) {
// Do the initial resume and wait for the running event before going
@@ -4944,10 +4871,10 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
got_event =
listener_sp->GetEvent(event_sp, GetUtilityExpressionTimeout());
if (!got_event) {
- if (log)
- log->Printf("Process::RunThreadPlan(): didn't get any event after "
- "resume %" PRIu32 ", exiting.",
- num_resumes);
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): didn't get any event after "
+ "resume %" PRIu32 ", exiting.",
+ num_resumes);
diagnostic_manager.Printf(eDiagnosticSeverityError,
"didn't get any event after resume %" PRIu32
@@ -4966,13 +4893,13 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
if (stop_state == eStateStopped) {
restarted = Process::ProcessEventData::GetRestartedFromEvent(
event_sp.get());
- if (log)
- log->Printf(
- "Process::RunThreadPlan(): didn't get running event after "
- "resume %d, got %s instead (restarted: %i, do_resume: %i, "
- "handle_running_event: %i).",
- num_resumes, StateAsCString(stop_state), restarted, do_resume,
- handle_running_event);
+ LLDB_LOGF(
+ log,
+ "Process::RunThreadPlan(): didn't get running event after "
+ "resume %d, got %s instead (restarted: %i, do_resume: %i, "
+ "handle_running_event: %i).",
+ num_resumes, StateAsCString(stop_state), restarted, do_resume,
+ handle_running_event);
}
if (restarted) {
@@ -5015,19 +4942,20 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
if (log) {
if (timeout) {
auto now = system_clock::now();
- log->Printf("Process::RunThreadPlan(): about to wait - now is %s - "
- "endpoint is %s",
- llvm::to_string(now).c_str(),
- llvm::to_string(now + *timeout).c_str());
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): about to wait - now is %s - "
+ "endpoint is %s",
+ llvm::to_string(now).c_str(),
+ llvm::to_string(now + *timeout).c_str());
} else {
- log->Printf("Process::RunThreadPlan(): about to wait forever.");
+ LLDB_LOGF(log, "Process::RunThreadPlan(): about to wait forever.");
}
}
#ifdef LLDB_RUN_THREAD_HALT_WITH_EVENT
// See comment above...
if (miss_first_event) {
- usleep(1000);
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
miss_first_event = false;
got_event = false;
} else
@@ -5044,17 +4972,15 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
return_value = eExpressionInterrupted;
diagnostic_manager.PutString(eDiagnosticSeverityRemark,
"execution halted by user interrupt.");
- if (log)
- log->Printf("Process::RunThreadPlan(): Got interrupted by "
- "eBroadcastBitInterrupted, exiting.");
+ LLDB_LOGF(log, "Process::RunThreadPlan(): Got interrupted by "
+ "eBroadcastBitInterrupted, exiting.");
break;
} else {
stop_state =
Process::ProcessEventData::GetStateFromEvent(event_sp.get());
- if (log)
- log->Printf(
- "Process::RunThreadPlan(): in while loop, got event: %s.",
- StateAsCString(stop_state));
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): in while loop, got event: %s.",
+ StateAsCString(stop_state));
switch (stop_state) {
case lldb::eStateStopped: {
@@ -5064,18 +4990,18 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
if (!thread_sp) {
// Ooh, our thread has vanished. Unlikely that this was
// successful execution...
- if (log)
- log->Printf("Process::RunThreadPlan(): execution completed "
- "but our thread (index-id=%u) has vanished.",
- thread_idx_id);
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): execution completed "
+ "but our thread (index-id=%u) has vanished.",
+ thread_idx_id);
return_value = eExpressionInterrupted;
} else if (Process::ProcessEventData::GetRestartedFromEvent(
event_sp.get())) {
// If we were restarted, we just need to go back up to fetch
// another event.
if (log) {
- log->Printf("Process::RunThreadPlan(): Got a stop and "
- "restart, so we'll continue waiting.");
+ LLDB_LOGF(log, "Process::RunThreadPlan(): Got a stop and "
+ "restart, so we'll continue waiting.");
}
keep_going = true;
do_resume = false;
@@ -5098,10 +5024,10 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
break;
default:
- if (log)
- log->Printf("Process::RunThreadPlan(): execution stopped with "
- "unexpected state: %s.",
- StateAsCString(stop_state));
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): execution stopped with "
+ "unexpected state: %s.",
+ StateAsCString(stop_state));
if (stop_state == eStateExited)
event_to_broadcast_sp = event_sp;
@@ -5162,8 +5088,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
while (try_halt_again < num_retries) {
Status halt_error;
if (do_halt) {
- if (log)
- log->Printf("Process::RunThreadPlan(): Running Halt.");
+ LLDB_LOGF(log, "Process::RunThreadPlan(): Running Halt.");
const bool clear_thread_plans = false;
const bool use_run_lock = false;
Halt(clear_thread_plans, use_run_lock);
@@ -5179,8 +5104,9 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
stop_state =
Process::ProcessEventData::GetStateFromEvent(event_sp.get());
if (log) {
- log->Printf("Process::RunThreadPlan(): Stopped with event: %s",
- StateAsCString(stop_state));
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): Stopped with event: %s",
+ StateAsCString(stop_state));
if (stop_state == lldb::eStateStopped &&
Process::ProcessEventData::GetInterruptedFromEvent(
event_sp.get()))
@@ -5379,24 +5305,25 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
} while (false);
if (event_explanation)
- log->Printf("Process::RunThreadPlan(): execution interrupted: %s %s",
- s.GetData(), event_explanation);
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan(): execution interrupted: %s %s",
+ s.GetData(), event_explanation);
else
- log->Printf("Process::RunThreadPlan(): execution interrupted: %s",
- s.GetData());
+ LLDB_LOGF(log, "Process::RunThreadPlan(): execution interrupted: %s",
+ s.GetData());
}
if (should_unwind) {
- if (log)
- log->Printf("Process::RunThreadPlan: ExecutionInterrupted - "
- "discarding thread plans up to %p.",
- static_cast<void *>(thread_plan_sp.get()));
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan: ExecutionInterrupted - "
+ "discarding thread plans up to %p.",
+ static_cast<void *>(thread_plan_sp.get()));
thread->DiscardThreadPlansUpToPlan(thread_plan_sp);
} else {
- if (log)
- log->Printf("Process::RunThreadPlan: ExecutionInterrupted - for "
- "plan: %p not discarding.",
- static_cast<void *>(thread_plan_sp.get()));
+ LLDB_LOGF(log,
+ "Process::RunThreadPlan: ExecutionInterrupted - for "
+ "plan: %p not discarding.",
+ static_cast<void *>(thread_plan_sp.get()));
}
} else if (return_value == eExpressionSetupError) {
if (log)
@@ -5559,9 +5486,8 @@ size_t Process::GetThreadStatus(Stream &strm,
++num_thread_infos_dumped;
} else {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::GetThreadStatus - thread 0x" PRIu64
- " vanished while running Thread::GetStatus.");
+ LLDB_LOGF(log, "Process::GetThreadStatus - thread 0x" PRIu64
+ " vanished while running Thread::GetStatus.");
}
}
return num_thread_infos_dumped;
@@ -5612,6 +5538,12 @@ ProcessRunLock &Process::GetRunLock() {
return m_public_run_lock;
}
+bool Process::CurrentThreadIsPrivateStateThread()
+{
+ return m_private_state_thread.EqualsThread(Host::GetCurrentThread());
+}
+
+
void Process::Flush() {
m_thread_list.Flush();
m_extended_thread_list.Flush();
@@ -5622,8 +5554,7 @@ void Process::Flush() {
void Process::DidExec() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::%s()", __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s()", __FUNCTION__);
Target &target = GetTarget();
target.CleanupProcess();
@@ -5669,7 +5600,7 @@ addr_t Process::ResolveIndirectFunction(const Address *address, Status &error) {
if (iter != m_resolved_indirect_addresses.end()) {
function_addr = (*iter).second;
} else {
- if (!InferiorCall(this, address, function_addr)) {
+ if (!CallVoidArgVoidPtrReturn(address, function_addr)) {
Symbol *symbol = address->CalculateSymbolContextSymbol();
error.SetErrorStringWithFormat(
"Unable to call resolver for indirect function %s",
@@ -5929,19 +5860,18 @@ void Process::MapSupportedStructuredDataPlugins(
// Bail out early if there are no type names to map.
if (supported_type_names.GetSize() == 0) {
- if (log)
- log->Printf("Process::%s(): no structured data types supported",
- __FUNCTION__);
+ LLDB_LOGF(log, "Process::%s(): no structured data types supported",
+ __FUNCTION__);
return;
}
// Convert StructuredData type names to ConstString instances.
std::set<ConstString> const_type_names;
- if (log)
- log->Printf("Process::%s(): the process supports the following async "
- "structured data types:",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "Process::%s(): the process supports the following async "
+ "structured data types:",
+ __FUNCTION__);
supported_type_names.ForEach(
[&const_type_names, &log](StructuredData::Object *object) {
@@ -5988,11 +5918,11 @@ void Process::MapSupportedStructuredDataPlugins(
m_structured_data_plugin_map.insert(
std::make_pair(type_name, plugin_sp));
names_to_remove.push_back(type_name);
- if (log)
- log->Printf("Process::%s(): using plugin %s for type name "
- "%s",
- __FUNCTION__, plugin_sp->GetPluginName().GetCString(),
- type_name.GetCString());
+ LLDB_LOGF(log,
+ "Process::%s(): using plugin %s for type name "
+ "%s",
+ __FUNCTION__, plugin_sp->GetPluginName().GetCString(),
+ type_name.GetCString());
}
}
@@ -6042,7 +5972,62 @@ UtilityFunction *Process::GetLoadImageUtilityFunction(
llvm::function_ref<std::unique_ptr<UtilityFunction>()> factory) {
if (platform != GetTarget().GetPlatform().get())
return nullptr;
- std::call_once(m_dlopen_utility_func_flag_once,
- [&] { m_dlopen_utility_func_up = factory(); });
+ llvm::call_once(m_dlopen_utility_func_flag_once,
+ [&] { m_dlopen_utility_func_up = factory(); });
return m_dlopen_utility_func_up.get();
}
+
+bool Process::CallVoidArgVoidPtrReturn(const Address *address,
+ addr_t &returned_func,
+ bool trap_exceptions) {
+ Thread *thread = GetThreadList().GetExpressionExecutionThread().get();
+ if (thread == nullptr || address == nullptr)
+ return false;
+
+ EvaluateExpressionOptions options;
+ options.SetStopOthers(true);
+ options.SetUnwindOnError(true);
+ options.SetIgnoreBreakpoints(true);
+ options.SetTryAllThreads(true);
+ options.SetDebug(false);
+ options.SetTimeout(GetUtilityExpressionTimeout());
+ options.SetTrapExceptions(trap_exceptions);
+
+ auto type_system_or_err =
+ GetTarget().GetScratchTypeSystemForLanguage(eLanguageTypeC);
+ if (!type_system_or_err) {
+ llvm::consumeError(type_system_or_err.takeError());
+ return false;
+ }
+ CompilerType void_ptr_type =
+ type_system_or_err->GetBasicTypeFromAST(eBasicTypeVoid).GetPointerType();
+ lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallFunction(
+ *thread, *address, void_ptr_type, llvm::ArrayRef<addr_t>(), options));
+ if (call_plan_sp) {
+ DiagnosticManager diagnostics;
+
+ StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
+ if (frame) {
+ ExecutionContext exe_ctx;
+ frame->CalculateExecutionContext(exe_ctx);
+ ExpressionResults result =
+ RunThreadPlan(exe_ctx, call_plan_sp, options, diagnostics);
+ if (result == eExpressionCompleted) {
+ returned_func =
+ call_plan_sp->GetReturnValueObject()->GetValueAsUnsigned(
+ LLDB_INVALID_ADDRESS);
+
+ if (GetAddressByteSize() == 4) {
+ if (returned_func == UINT32_MAX)
+ return false;
+ } else if (GetAddressByteSize() == 8) {
+ if (returned_func == UINT64_MAX)
+ return false;
+ }
+ return true;
+ }
+ }
+ }
+
+ return false;
+}