Skip to content

Add an SB API to get the SBTarget from an SBBreakpoint #1987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lldb/bindings/interface/SBBreakpoint.i
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public:
void
ClearAllBreakpointSites ();

lldb::SBTarget
GetTarget() const;

lldb::SBBreakpointLocation
FindLocationByAddress (lldb::addr_t vm_addr);

Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBBreakpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class LLDB_API SBBreakpoint {

void ClearAllBreakpointSites();

lldb::SBTarget GetTarget() const;

lldb::SBBreakpointLocation FindLocationByAddress(lldb::addr_t vm_addr);

lldb::break_id_t FindLocationIDByAddress(lldb::addr_t vm_addr);
Expand Down
11 changes: 11 additions & 0 deletions lldb/source/API/SBBreakpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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, ());
Expand Down
3 changes: 3 additions & 0 deletions lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def test_target_delete(self):
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())