[Lldb-commits] [lldb] 6754caa - Add an SB API to get the SBTarget from an SBBreakpoint
Jim Ingham via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 15 14:28:53 PDT 2020
Author: Jim Ingham
Date: 2020-10-15T14:28:44-07:00
New Revision: 6754caa9bf21a759c4080a797f23e2b7a77a71e1
URL: https://github.com/llvm/llvm-project/commit/6754caa9bf21a759c4080a797f23e2b7a77a71e1
DIFF: https://github.com/llvm/llvm-project/commit/6754caa9bf21a759c4080a797f23e2b7a77a71e1.diff
LOG: Add an SB API to get the SBTarget from an SBBreakpoint
Differential Revision: https://reviews.llvm.org/D89358
Added:
Modified:
lldb/bindings/interface/SBBreakpoint.i
lldb/include/lldb/API/SBBreakpoint.h
lldb/source/API/SBBreakpoint.cpp
lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py
Removed:
################################################################################
diff --git a/lldb/bindings/interface/SBBreakpoint.i b/lldb/bindings/interface/SBBreakpoint.i
index e386ace9dee8..696795241b11 100644
--- a/lldb/bindings/interface/SBBreakpoint.i
+++ b/lldb/bindings/interface/SBBreakpoint.i
@@ -100,6 +100,9 @@ public:
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
index 39a021145fb7..e13dbc5c3516 100644
--- a/lldb/include/lldb/API/SBBreakpoint.h
+++ b/lldb/include/lldb/API/SBBreakpoint.h
@@ -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);
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index 96b77bd8539e..96ae305ffce5 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -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, ());
diff --git a/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py b/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py
index 1c0c334fbeeb..80324ee61b70 100644
--- a/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py
+++ b/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py
@@ -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())
More information about the lldb-commits
mailing list