diff options
author | Pavel Labath <pavel@labath.sk> | 2022-02-21 11:07:38 +0100 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2022-02-23 14:25:59 +0100 |
commit | d0810779b1f310d99176467d5d5b5aa4e26d7eb5 (patch) | |
tree | 65650a935786a316c13763f0aba49092273f3eae /lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp | |
parent | 40f908195807953f19322a8d1a193d243dc5bfb6 (diff) | |
download | llvm-d0810779b1f310d99176467d5d5b5aa4e26d7eb5.zip llvm-d0810779b1f310d99176467d5d5b5aa4e26d7eb5.tar.gz llvm-d0810779b1f310d99176467d5d5b5aa4e26d7eb5.tar.bz2 |
[lldb] Modernize ThreadLauncher
Accept a function object instead of a raw pointer. This avoids a bunch
of boilerplate typically needed to pass arguments to the thread
functions.
Differential Revision: https://reviews.llvm.org/D120321
Diffstat (limited to 'lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index 6511227..8843dc8 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -724,7 +724,7 @@ bool ProcessKDP::StartAsyncThread() { return true; llvm::Expected<HostThread> async_thread = ThreadLauncher::LaunchThread( - "<lldb.process.kdp-remote.async>", ProcessKDP::AsyncThread, this); + "<lldb.process.kdp-remote.async>", [this] { return AsyncThread(); }); if (!async_thread) { LLDB_LOG_ERROR(GetLog(LLDBLog::Host), async_thread.takeError(), "failed to launch host thread: {}"); @@ -746,25 +746,21 @@ void ProcessKDP::StopAsyncThread() { m_async_thread.Join(nullptr); } -void *ProcessKDP::AsyncThread(void *arg) { - ProcessKDP *process = (ProcessKDP *)arg; - - const lldb::pid_t pid = process->GetID(); +void *ProcessKDP::AsyncThread() { + const lldb::pid_t pid = GetID(); Log *log = GetLog(KDPLog::Process); LLDB_LOGF(log, - "ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64 - ") thread starting...", - arg, pid); + "ProcessKDP::AsyncThread(pid = %" PRIu64 ") thread starting...", + pid); ListenerSP listener_sp(Listener::MakeListener("ProcessKDP::AsyncThread")); EventSP event_sp; const uint32_t desired_event_mask = eBroadcastBitAsyncContinue | eBroadcastBitAsyncThreadShouldExit; - if (listener_sp->StartListeningForEvents(&process->m_async_broadcaster, - desired_event_mask) == - desired_event_mask) { + if (listener_sp->StartListeningForEvents( + &m_async_broadcaster, desired_event_mask) == desired_event_mask) { bool done = false; while (!done) { LLDB_LOGF(log, @@ -787,9 +783,9 @@ void *ProcessKDP::AsyncThread(void *arg) { switch (event_type) { case eBroadcastBitAsyncContinue: { is_running = true; - if (process->m_comm.WaitForPacketWithTimeoutMicroSeconds( + if (m_comm.WaitForPacketWithTimeoutMicroSeconds( exc_reply_packet, 1 * USEC_PER_SEC)) { - ThreadSP thread_sp(process->GetKernelThread()); + ThreadSP thread_sp(GetKernelThread()); if (thread_sp) { lldb::RegisterContextSP reg_ctx_sp( thread_sp->GetRegisterContext()); @@ -801,7 +797,7 @@ void *ProcessKDP::AsyncThread(void *arg) { // TODO: parse the stop reply packet is_running = false; - process->SetPrivateState(eStateStopped); + SetPrivateState(eStateStopped); } else { // Check to see if we are supposed to exit. There is no way to // interrupt a running kernel, so all we can do is wait for an @@ -843,12 +839,10 @@ void *ProcessKDP::AsyncThread(void *arg) { } } - LLDB_LOGF(log, - "ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64 - ") thread exiting...", - arg, pid); + LLDB_LOGF(log, "ProcessKDP::AsyncThread(pid = %" PRIu64 ") thread exiting...", + pid); - process->m_async_thread.Reset(); + m_async_thread.Reset(); return NULL; } |