Add an SB API to get the SBTarget from an SBBreakpoint

Differential Revision: https://reviews.llvm.org/D89358
This commit is contained in:
Jim Ingham 2020-10-15 14:28:06 -07:00
parent a91dd3d37d
commit 6754caa9bf
4 changed files with 19 additions and 0 deletions

View File

@ -100,6 +100,9 @@ public:
void
ClearAllBreakpointSites ();
lldb::SBTarget
GetTarget() const;
lldb::SBBreakpointLocation
FindLocationByAddress (lldb::addr_t vm_addr);

View File

@ -42,6 +42,8 @@ public:
void ClearAllBreakpointSites();
lldb::SBTarget GetTarget() const;
lldb::SBBreakpointLocation FindLocationByAddress(lldb::addr_t vm_addr);
lldb::break_id_t FindLocationIDByAddress(lldb::addr_t vm_addr);

View File

@ -81,6 +81,16 @@ bool SBBreakpoint::operator!=(const lldb::SBBreakpoint &rhs) {
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 @@ void RegisterMethods<SBBreakpoint>(Registry &R) {
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, ());

View File

@ -66,6 +66,9 @@ class BreakpointAPITestCase(TestBase):
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())