Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp =================================================================== --- source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -2260,62 +2260,25 @@ case (SIGTRAP | (PTRACE_EVENT_CLONE << 8)): { - lldb::tid_t tid = LLDB_INVALID_THREAD_ID; + // This is the notification on the parent thread which informs us of new thread + // creation. We are not interested in these events at this points (an interesting use + // case would be to stop the process upon thread creation), so we just resume the thread. + // We will pickup the new thread when we get its SIGSTOP notification. - // The main thread is stopped here. - if (thread_sp) - std::static_pointer_cast (thread_sp)->SetStoppedBySignal (SIGTRAP); - NotifyThreadStop (pid); - - unsigned long event_message = 0; - if (GetEventMessage (pid, &event_message).Success()) + if (log) { - tid = static_cast (event_message); - if (log) + unsigned long event_message = 0; + if (GetEventMessage (pid, &event_message).Success()) + { + lldb::tid_t tid = static_cast (event_message); log->Printf ("NativeProcessLinux::%s() pid %" PRIu64 " received thread creation event for tid %" PRIu64, __FUNCTION__, pid, tid); - // If we don't track the thread yet: create it, mark as stopped. - // If we do track it, this is the wait we needed. Now resume the new thread. - // In all cases, resume the current (i.e. main process) thread. - bool created_now = false; - NativeThreadProtocolSP new_thread_sp = GetOrCreateThread (tid, created_now); - assert (new_thread_sp.get() && "failed to get or create the tracking data for newly created inferior thread"); - - // If the thread was already tracked, it means the created thread already received its SI_USER notification of creation. - if (!created_now) - { - // We can now resume the newly created thread since it is fully created. - NotifyThreadCreateStopped (tid); - m_coordinator_up->RequestThreadResume (tid, - [=](lldb::tid_t tid_to_resume, bool supress_signal) - { - std::static_pointer_cast (new_thread_sp)->SetRunning (); - return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER); - }, - CoordinatorErrorHandler); } else - { - // Mark the thread as currently launching. Need to wait for SIGTRAP clone on the main thread before - // this thread is ready to go. - std::static_pointer_cast (new_thread_sp)->SetLaunching (); - } - } - else - { - if (log) log->Printf ("NativeProcessLinux::%s() pid %" PRIu64 " received thread creation event but GetEventMessage failed so we don't know the new tid", __FUNCTION__, pid); } - // In all cases, we can resume the main thread here. - m_coordinator_up->RequestThreadResume (pid, - [=](lldb::tid_t tid_to_resume, bool supress_signal) - { - std::static_pointer_cast (thread_sp)->SetRunning (); - return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER); - }, - CoordinatorErrorHandler); - + Resume (pid, LLDB_INVALID_SIGNAL_NUMBER); break; } @@ -2641,29 +2604,19 @@ __FUNCTION__, GetID (), pid); // Did we already create the thread? - bool created_now = false; - thread_sp = GetOrCreateThread (pid, created_now); + thread_sp = AddThread(pid); assert (thread_sp.get() && "failed to get or create the tracking data for newly created inferior thread"); - - // If the thread was already tracked, it means the main thread already received its SIGTRAP for the create. - if (!created_now) - { - // We can now resume the newly created thread since it is fully created. - NotifyThreadCreateStopped (pid); - m_coordinator_up->RequestThreadResume (pid, - [=](lldb::tid_t tid_to_resume, bool supress_signal) - { - std::static_pointer_cast (thread_sp)->SetRunning (); - return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER); - }, - CoordinatorErrorHandler); - } - else - { - // Mark the thread as currently launching. Need to wait for SIGTRAP clone on the main thread before - // this thread is ready to go. - std::static_pointer_cast (thread_sp)->SetLaunching (); - } + // We can now resume the newly created thread. + // TODO: There is a bug here that if we are in the process of stopping the process while + // this thread is being created, this new thread will continue to execute. + NotifyThreadCreateStopped (pid); + m_coordinator_up->RequestThreadResume (pid, + [=](lldb::tid_t tid_to_resume, bool supress_signal) + { + std::static_pointer_cast (thread_sp)->SetRunning (); + return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER); + }, + CoordinatorErrorHandler); // Done handling. return; Index: test/python_api/lldbutil/process/TestPrintStackTraces.py =================================================================== --- test/python_api/lldbutil/process/TestPrintStackTraces.py +++ test/python_api/lldbutil/process/TestPrintStackTraces.py @@ -19,7 +19,6 @@ self.line = line_number('main.cpp', '// Set break point at this line.') # fails on Linux i386 llvm.org/pr23043 - # fails 78/100 on Linux x86_64 when running against remote lldb-platform # failed 11/200 on the linux build bot @expectedFailureLinux @python_api_test