Skip to content

Commit 20ca895

Browse files
authored
[lldb] Add Python properties to SBBreakpoint and similar (#142215)
Update `SBBreakpoint`, `SBBreakpointLocation`, and `SBBreakpointName` to add Python properties for many of their getters/setters.
1 parent b76b3f3 commit 20ca895

File tree

6 files changed

+47
-17
lines changed

6 files changed

+47
-17
lines changed

lldb/bindings/interface/SBBreakpointExtensions.i

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ STRING_EXTENSION_OUTSIDE(SBBreakpoint)
5050
enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''')
5151
one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''')
5252
num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''')
53+
auto_continue = property(GetAutoContinue, SetAutoContinue, doc='A read/write property that configures the auto-continue property of this breakpoint.')
54+
condition = property(GetCondition, SetCondition, doc='A read/write property that configures the condition of this breakpoint.')
55+
hit_count = property(GetHitCount, doc='A read only property that returns the hit count of this breakpoint.')
56+
ignore_count = property(GetIgnoreCount, SetIgnoreCount, doc='A read/write property that configures the ignore count of this breakpoint.')
57+
queue_name = property(GetQueueName, SetQueueName, doc='A read/write property that configures the queue name criteria of this breakpoint.')
58+
target = property(GetTarget, doc='A read only property that returns the target of this breakpoint.')
59+
thread_id = property(GetThreadID, SetThreadID, doc='A read/write property that configures the thread id criteria of this breakpoint.')
60+
thread_index = property(GetThreadIndex, SetThreadIndex, doc='A read/write property that configures the thread index criteria of this breakpoint.')
61+
thread_name = property(GetThreadName, SetThreadName, doc='A read/write property that configures the thread name criteria of this breakpoint.')
5362
%}
5463
#endif
5564
}

lldb/bindings/interface/SBBreakpointLocationExtensions.i

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ STRING_EXTENSION_LEVEL_OUTSIDE(SBBreakpointLocation, lldb::eDescriptionLevelFull
77
# our own equality operator here
88
def __eq__(self, other):
99
return not self.__ne__(other)
10+
11+
addr = property(GetAddress, doc='A read only property that returns the address of this breakpoint location.')
12+
auto_continue = property(GetAutoContinue, SetAutoContinue, doc='A read/write property that configures the auto-continue property of this breakpoint location.')
13+
breakpoint = property(GetBreakpoint, doc='A read only property that returns the parent breakpoint of this breakpoint location.')
14+
condition = property(GetCondition, SetCondition, doc='A read/write property that configures the condition of this breakpoint location.')
15+
hit_count = property(GetHitCount, doc='A read only property that returns the hit count of this breakpoint location.')
16+
id = property(GetID, doc='A read only property that returns the id of this breakpoint location.')
17+
ignore_count = property(GetIgnoreCount, SetIgnoreCount, doc='A read/write property that configures the ignore count of this breakpoint location.')
18+
load_addr = property(GetLoadAddress, doc='A read only property that returns the load address of this breakpoint location.')
19+
queue_name = property(GetQueueName, SetQueueName, doc='A read/write property that configures the queue name criteria of this breakpoint location.')
20+
thread_id = property(GetThreadID, SetThreadID, doc='A read/write property that configures the thread id criteria of this breakpoint location.')
21+
thread_index = property(GetThreadIndex, SetThreadIndex, doc='A read/write property that configures the thread index criteria of this breakpoint location.')
22+
thread_name = property(GetThreadName, SetThreadName, doc='A read/write property that configures the thread name criteria of this breakpoint location.')
1023
%}
1124
#endif
1225
}

lldb/bindings/interface/SBBreakpointNameExtensions.i

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ STRING_EXTENSION_OUTSIDE(SBBreakpointName)
77
# our own equality operator here
88
def __eq__(self, other):
99
return not self.__ne__(other)
10+
11+
auto_continue = property(GetAutoContinue, SetAutoContinue, doc='A read/write property that configures the auto-continue property of this breakpoint name.')
12+
condition = property(GetCondition, SetCondition, doc='A read/write property that configures the condition of this breakpoint name.')
13+
enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint name is enabled or not.''')
14+
ignore_count = property(GetIgnoreCount, SetIgnoreCount, doc='A read/write property that configures the ignore count of this breakpoint name.')
15+
one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint name is one-shot (deleted when hit) or not.''')
16+
queue_name = property(GetQueueName, SetQueueName, doc='A read/write property that configures the queue name criteria of this breakpoint name.')
17+
thread_id = property(GetThreadID, SetThreadID, doc='A read/write property that configures the thread id criteria of this breakpoint name.')
18+
thread_index = property(GetThreadIndex, SetThreadIndex, doc='A read/write property that configures the thread index criteria of this breakpoint name.')
19+
thread_name = property(GetThreadName, SetThreadName, doc='A read/write property that configures the thread name criteria of this breakpoint name.')
1020
%}
1121
#endif
1222
}

lldb/test/API/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ def ignore_vrs_condition(self, use_location):
175175
if use_location:
176176
loc = bkpt.location[0]
177177
self.assertTrue(loc.IsValid(), "Got a valid location")
178-
loc.SetIgnoreCount(2)
179-
loc.SetCondition("i >= 3")
178+
loc.ignore_count = 2
179+
loc.condition = "i >= 3"
180180
else:
181-
bkpt.SetIgnoreCount(2)
182-
bkpt.SetCondition("i >= 3")
181+
bkpt.ignore_count = 2
182+
bkpt.condition = "i >= 3"
183183

184184
threads = lldbutil.continue_to_breakpoint(process, bkpt)
185185
self.assertEqual(len(threads), 1, "Hit the breakpoint")
@@ -188,4 +188,4 @@ def ignore_vrs_condition(self, use_location):
188188
val = var.GetValueAsUnsigned(10000)
189189
self.assertNotEqual(val, 10000, "Got the fail value for i")
190190
self.assertEqual(val, 5, "We didn't stop the right number of times")
191-
self.assertEqual(bkpt.GetHitCount(), 3, "Hit count is not right")
191+
self.assertEqual(bkpt.hit_count, 3, "Hit count is not right")

lldb/test/API/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,14 @@ def do_check_using_names(self):
216216
)
217217

218218
def check_option_values(self, bp_object):
219-
self.assertEqual(bp_object.IsOneShot(), self.is_one_shot, "IsOneShot")
220-
self.assertEqual(bp_object.GetIgnoreCount(), self.ignore_count, "IgnoreCount")
221-
self.assertEqual(bp_object.GetCondition(), self.condition, "Condition")
222-
self.assertEqual(
223-
bp_object.GetAutoContinue(), self.auto_continue, "AutoContinue"
224-
)
225-
self.assertEqual(bp_object.GetThreadID(), self.tid, "Thread ID")
226-
self.assertEqual(bp_object.GetThreadIndex(), self.tidx, "Thread Index")
227-
self.assertEqual(bp_object.GetThreadName(), self.thread_name, "Thread Name")
228-
self.assertEqual(bp_object.GetQueueName(), self.queue_name, "Queue Name")
219+
self.assertEqual(bp_object.one_shot, self.is_one_shot, "IsOneShot")
220+
self.assertEqual(bp_object.ignore_count, self.ignore_count, "IgnoreCount")
221+
self.assertEqual(bp_object.condition, self.condition, "Condition")
222+
self.assertEqual(bp_object.auto_continue, self.auto_continue, "AutoContinue")
223+
self.assertEqual(bp_object.thread_id, self.tid, "Thread ID")
224+
self.assertEqual(bp_object.thread_index, self.tidx, "Thread Index")
225+
self.assertEqual(bp_object.thread_name, self.thread_name, "Thread Name")
226+
self.assertEqual(bp_object.queue_name, self.queue_name, "Queue Name")
229227
set_cmds = lldb.SBStringList()
230228
bp_object.GetCommandLineCommands(set_cmds)
231229
self.assertEqual(

lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_stopping_breakpoints(self):
1717
@no_debug_info_test
1818
def test_auto_continue(self):
1919
def auto_continue(bkpt):
20-
bkpt.SetAutoContinue(True)
20+
bkpt.auto_continue = True
2121

2222
self.do_test(auto_continue)
2323

@@ -26,7 +26,7 @@ def auto_continue(bkpt):
2626
@no_debug_info_test
2727
def test_failing_condition(self):
2828
def condition(bkpt):
29-
bkpt.SetCondition("1 == 2")
29+
bkpt.condition = "1 == 2"
3030

3131
self.do_test(condition)
3232

0 commit comments

Comments
 (0)