diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp index 238229c5108c..8954683ebbab 100644 --- a/lldb/source/API/SBBreakpoint.cpp +++ b/lldb/source/API/SBBreakpoint.cpp @@ -314,14 +314,14 @@ SBBreakpoint::GetThreadIndex() const if (m_opaque_sp) { const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec(); - if (thread_spec == NULL) + if (thread_spec != NULL) thread_idx = thread_spec->GetIndex(); } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u", m_opaque_sp.get(), thread_idx); - return UINT32_MAX; + return thread_idx; } @@ -343,7 +343,7 @@ SBBreakpoint::GetThreadName () const if (m_opaque_sp) { const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec(); - if (thread_spec == NULL) + if (thread_spec != NULL) name = thread_spec->GetName(); } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); diff --git a/lldb/test/breakpoint_conditions/TestBreakpointConditions.py b/lldb/test/breakpoint_conditions/TestBreakpointConditions.py index 55c65c91f738..f4ae5269574d 100644 --- a/lldb/test/breakpoint_conditions/TestBreakpointConditions.py +++ b/lldb/test/breakpoint_conditions/TestBreakpointConditions.py @@ -113,6 +113,19 @@ class BreakpointConditionsTestCase(TestBase): breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) + # We didn't associate a thread index with the breakpoint, so it should be invalid. + self.assertTrue(breakpoint.GetThreadIndex() == lldb.UINT32_MAX, + "The thread index should be invalid") + # The thread name should be invalid, too. + self.assertTrue(breakpoint.GetThreadName() is None, + "The thread name should be invalid") + + # Let's set the thread index for this breakpoint and verify that it is, + # indeed, being set correctly. + breakpoint.SetThreadIndex(1) # There's only one thread for the process. + self.assertTrue(breakpoint.GetThreadIndex() == 1, + "The thread index has been set correctly") + # Get the breakpoint location from breakpoint after we verified that, # indeed, it has one location. location = breakpoint.GetLocationAtIndex(0)