Files
llvm/lldb/source/Host/common/HostThread.cpp
jimingham 9adc8ddad0 When running OS Plugins from dSYM's, make sure start state is correct (#146441)
This is an odd corner case of the use of scripts loaded from dSYM's - a
macOS only feature, which can load OS Plugins that re-present the thread
state of the program we attach to. If we find out about and load the
dSYM scripts when we discover a target in the course of attaching to it,
we can end up running the OS plugin before we've started up the private
state thread. However, the os_plugin in that case will be running before
we broadcast the stop event to the public event listener. So it should
formally use the private state and not the public state for the Python
code environment.

This patch says that if we have not yet started up the private state
thread, then any thread that is servicing events is doing so on behalf
of the private state machinery, and should see the private state, not
the public state.

Most of the patch is getting a test that will actually reproduce the
error. Only the test `test_python_os_plugin_remote` actually reproduced
the error. In `test_python_os_plugin` we actually do start up the
private state thread before handling the event. `test_python_os_plugin`
is there for completeness sake.
2025-07-11 10:02:07 -07:00

53 lines
1.6 KiB
C++

//===-- HostThread.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Host/HostThread.h"
#include "lldb/Host/HostNativeThread.h"
using namespace lldb;
using namespace lldb_private;
HostThread::HostThread() : m_native_thread(new HostNativeThread) {}
HostThread::HostThread(lldb::thread_t thread)
: m_native_thread(new HostNativeThread(thread)) {}
Status HostThread::Join(lldb::thread_result_t *result) {
return m_native_thread->Join(result);
}
Status HostThread::Cancel() { return m_native_thread->Cancel(); }
void HostThread::Reset() { return m_native_thread->Reset(); }
lldb::thread_t HostThread::Release() { return m_native_thread->Release(); }
bool HostThread::IsJoinable() const { return m_native_thread->IsJoinable(); }
HostNativeThread &HostThread::GetNativeThread() {
return static_cast<HostNativeThread &>(*m_native_thread);
}
const HostNativeThread &HostThread::GetNativeThread() const {
return static_cast<const HostNativeThread &>(*m_native_thread);
}
lldb::thread_result_t HostThread::GetResult() const {
return m_native_thread->GetResult();
}
bool HostThread::EqualsThread(lldb::thread_t thread) const {
return m_native_thread->EqualsThread(thread);
}
bool HostThread::HasThread() const {
if (!m_native_thread)
return false;
return m_native_thread->GetSystemHandle() != LLDB_INVALID_HOST_THREAD;
}