diff --git a/lldb/bindings/interface/SBBreakpoint.i b/lldb/bindings/interface/SBBreakpoint.i --- a/lldb/bindings/interface/SBBreakpoint.i +++ b/lldb/bindings/interface/SBBreakpoint.i @@ -100,6 +100,9 @@ void ClearAllBreakpointSites (); + lldb::SBTarget + GetTarget() const; + lldb::SBBreakpointLocation FindLocationByAddress (lldb::addr_t vm_addr); diff --git a/lldb/include/lldb/API/SBBreakpoint.h b/lldb/include/lldb/API/SBBreakpoint.h --- a/lldb/include/lldb/API/SBBreakpoint.h +++ b/lldb/include/lldb/API/SBBreakpoint.h @@ -42,6 +42,8 @@ void ClearAllBreakpointSites(); + lldb::SBTarget GetTarget() const; + lldb::SBBreakpointLocation FindLocationByAddress(lldb::addr_t vm_addr); lldb::break_id_t FindLocationIDByAddress(lldb::addr_t vm_addr); diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp --- a/lldb/source/API/SBBreakpoint.cpp +++ b/lldb/source/API/SBBreakpoint.cpp @@ -81,6 +81,16 @@ return m_opaque_wp.lock() != rhs.m_opaque_wp.lock(); } +SBTarget SBBreakpoint::GetTarget() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBTarget, SBBreakpoint, GetTarget); + + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) + return LLDB_RECORD_RESULT(SBTarget(bkpt_sp->GetTargetSP())); + + return LLDB_RECORD_RESULT(SBTarget()); +} + break_id_t SBBreakpoint::GetID() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::break_id_t, SBBreakpoint, GetID); @@ -987,6 +997,7 @@ SBBreakpoint, operator==,(const lldb::SBBreakpoint &)); LLDB_REGISTER_METHOD(bool, SBBreakpoint, operator!=,(const lldb::SBBreakpoint &)); + LLDB_REGISTER_METHOD_CONST(lldb::SBTarget, SBBreakpoint, GetTarget, ()); LLDB_REGISTER_METHOD_CONST(lldb::break_id_t, SBBreakpoint, GetID, ()); LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsValid, ()); LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, operator bool, ()); diff --git a/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py b/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py --- a/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py +++ b/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py @@ -66,6 +66,9 @@ location = breakpoint.GetLocationAtIndex(0) self.assertTrue(location.IsValid()) + # Make sure the breakpoint's target is right: + self.assertEqual(target, breakpoint.GetTarget(), "Breakpoint reports its target correctly") + self.assertTrue(self.dbg.DeleteTarget(target)) self.assertFalse(breakpoint.IsValid()) self.assertFalse(location.IsValid())