Move detach to FreeBSD- and Linux-specific classes.
On Linux there is no separate notion of a process (vs. a thread) for ptrace(); each thread needs to be individually detached. On FreeBSD we have a separate process context, and we detach just it. Review: http://llvm-reviews.chandlerc.com/D1418 llvm-svn: 189666
This commit is contained in:
parent
e3963d0d79
commit
7dcb77de06
|
@ -122,6 +122,24 @@ ProcessFreeBSD::Terminate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Error
|
||||||
|
ProcessFreeBSD::DoDetach(bool keep_stopped)
|
||||||
|
{
|
||||||
|
Error error;
|
||||||
|
if (keep_stopped)
|
||||||
|
{
|
||||||
|
error.SetErrorString("Detaching with keep_stopped true is not currently supported on FreeBSD.");
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
error = m_monitor->Detach(GetID());
|
||||||
|
|
||||||
|
if (error.Success())
|
||||||
|
SetPrivateState(eStateDetached);
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ProcessFreeBSD::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
|
ProcessFreeBSD::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,6 +54,9 @@ public:
|
||||||
ProcessFreeBSD(lldb_private::Target& target,
|
ProcessFreeBSD(lldb_private::Target& target,
|
||||||
lldb_private::Listener &listener);
|
lldb_private::Listener &listener);
|
||||||
|
|
||||||
|
virtual lldb_private::Error
|
||||||
|
DoDetach(bool keep_stopped);
|
||||||
|
|
||||||
virtual bool
|
virtual bool
|
||||||
UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list);
|
UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list);
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,35 @@ ProcessLinux::EnablePluginLogging(Stream *strm, Args &command)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Error
|
||||||
|
ProcessLinux::DoDetach(bool keep_stopped)
|
||||||
|
{
|
||||||
|
Error error;
|
||||||
|
if (keep_stopped)
|
||||||
|
{
|
||||||
|
// FIXME: If you want to implement keep_stopped,
|
||||||
|
// this would be the place to do it.
|
||||||
|
error.SetErrorString("Detaching with keep_stopped true is not currently supported on Linux.");
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mutex::Locker lock(m_thread_list.GetMutex());
|
||||||
|
|
||||||
|
uint32_t thread_count = m_thread_list.GetSize(false);
|
||||||
|
for (uint32_t i = 0; i < thread_count; ++i)
|
||||||
|
{
|
||||||
|
POSIXThread *thread = static_cast<POSIXThread*>(
|
||||||
|
m_thread_list.GetThreadAtIndex(i, false).get());
|
||||||
|
error = m_monitor->Detach(thread->GetID());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error.Success())
|
||||||
|
SetPrivateState(eStateDetached);
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ProcessPOSIX override
|
// ProcessPOSIX override
|
||||||
void
|
void
|
||||||
ProcessLinux::StopAllThreads(lldb::tid_t stop_tid)
|
ProcessLinux::StopAllThreads(lldb::tid_t stop_tid)
|
||||||
|
|
|
@ -54,6 +54,9 @@ public:
|
||||||
lldb_private::Listener &listener,
|
lldb_private::Listener &listener,
|
||||||
lldb_private::FileSpec *core_file);
|
lldb_private::FileSpec *core_file);
|
||||||
|
|
||||||
|
virtual lldb_private::Error
|
||||||
|
DoDetach(bool keep_stopped);
|
||||||
|
|
||||||
virtual bool
|
virtual bool
|
||||||
UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list);
|
UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list);
|
||||||
|
|
||||||
|
|
|
@ -318,34 +318,6 @@ ProcessPOSIX::DoHalt(bool &caused_stop)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error
|
|
||||||
ProcessPOSIX::DoDetach(bool keep_stopped)
|
|
||||||
{
|
|
||||||
Error error;
|
|
||||||
if (keep_stopped)
|
|
||||||
{
|
|
||||||
// FIXME: If you want to implement keep_stopped,
|
|
||||||
// this would be the place to do it.
|
|
||||||
error.SetErrorString("Detaching with keep_stopped true is not currently supported on this platform.");
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
Mutex::Locker lock(m_thread_list.GetMutex());
|
|
||||||
|
|
||||||
uint32_t thread_count = m_thread_list.GetSize(false);
|
|
||||||
for (uint32_t i = 0; i < thread_count; ++i)
|
|
||||||
{
|
|
||||||
POSIXThread *thread = static_cast<POSIXThread*>(
|
|
||||||
m_thread_list.GetThreadAtIndex(i, false).get());
|
|
||||||
error = m_monitor->Detach(thread->GetID());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error.Success())
|
|
||||||
SetPrivateState(eStateDetached);
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
Error
|
Error
|
||||||
ProcessPOSIX::DoSignal(int signal)
|
ProcessPOSIX::DoSignal(int signal)
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
DoHalt(bool &caused_stop);
|
DoHalt(bool &caused_stop);
|
||||||
|
|
||||||
virtual lldb_private::Error
|
virtual lldb_private::Error
|
||||||
DoDetach(bool keep_stopped);
|
DoDetach(bool keep_stopped) = 0;
|
||||||
|
|
||||||
virtual lldb_private::Error
|
virtual lldb_private::Error
|
||||||
DoSignal(int signal);
|
DoSignal(int signal);
|
||||||
|
|
Loading…
Reference in New Issue