Author: labath Date: Fri Feb 17 05:48:34 2017 New Revision: 295440 URL: http://llvm.org/viewvc/llvm-project?rev=295440&view=rev Log: NPL: Fix one more bug in the single step workaround
In the case we are stepping over the thread creation instruction, we will end up calling Thread::SingleStep back-to-back twice (because of the intermediate PTRACE_EVENT_CLONE stop). This will cause the cpu mask to be set inappropriately (because the old SingleStepCheck object will be destroyed after we create the new one), and the single-step will fail. Before the refactor the code was still incorrect in this case, but in a different way (the thread was left with the incorrect mask after the stepping was complete), so this was not easy to spot. This fixes TestCreateDuringInstructionStep on the affected devices. Modified: lldb/trunk/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py?rev=295440&r1=295439&r2=295440&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py Fri Feb 17 05:48:34 2017 @@ -16,10 +16,7 @@ from lldbsuite.test import lldbutil class CreateDuringInstructionStepTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) + NO_DEBUG_INFO_TESTCASE = True @skipUnlessPlatform(['linux']) @expectedFailureAndroid('llvm.org/pr24737', archs=['arm']) Modified: lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp?rev=295440&r1=295439&r2=295440&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp Fri Feb 17 05:48:34 2017 @@ -225,7 +225,13 @@ Error NativeThreadLinux::SingleStep(uint MaybeLogStateChange(new_state); m_state = new_state; m_stop_info.reason = StopReason::eStopReasonNone; - m_step_workaround = SingleStepWorkaround::Get(m_tid); + + if(!m_step_workaround) { + // If we already hava a workaround inplace, don't reset it. Otherwise, the + // destructor of the existing instance will run after the new instance has + // fetched the cpu mask, and the thread will end up with the wrong mask. + m_step_workaround = SingleStepWorkaround::Get(m_tid); + } intptr_t data = 0; if (signo != LLDB_INVALID_SIGNAL_NUMBER) Modified: lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp?rev=295440&r1=295439&r2=295440&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp Fri Feb 17 05:48:34 2017 @@ -172,8 +172,9 @@ std::unique_ptr<SingleStepWorkaround> Si } SingleStepWorkaround::~SingleStepWorkaround() { + Log *log = ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD); + LLDB_LOG(log, "Removing workaround"); if (sched_setaffinity(m_tid, sizeof m_original_set, &m_original_set) != 0) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD)); LLDB_LOG(log, "Unable to reset cpu affinity for thread {0}: {1}", m_tid, Error(errno, eErrorTypePOSIX)); } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits