xref: /freebsd-src/contrib/llvm-project/lldb/bindings/interface/SBBreakpointExtensions.i (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1*06c3fb27SDimitry Andric STRING_EXTENSION_OUTSIDE(SBBreakpoint)
2*06c3fb27SDimitry Andric 
3*06c3fb27SDimitry Andric %extend lldb::SBBreakpoint {
4*06c3fb27SDimitry Andric #ifdef SWIGPYTHON
5*06c3fb27SDimitry Andric     %pythoncode %{
6*06c3fb27SDimitry Andric 
7*06c3fb27SDimitry Andric         class locations_access(object):
8*06c3fb27SDimitry Andric             '''A helper object that will lazily hand out locations for a breakpoint when supplied an index.'''
9*06c3fb27SDimitry Andric             def __init__(self, sbbreakpoint):
10*06c3fb27SDimitry Andric                 self.sbbreakpoint = sbbreakpoint
11*06c3fb27SDimitry Andric 
12*06c3fb27SDimitry Andric             def __len__(self):
13*06c3fb27SDimitry Andric                 if self.sbbreakpoint:
14*06c3fb27SDimitry Andric                     return int(self.sbbreakpoint.GetNumLocations())
15*06c3fb27SDimitry Andric                 return 0
16*06c3fb27SDimitry Andric 
17*06c3fb27SDimitry Andric             def __getitem__(self, key):
18*06c3fb27SDimitry Andric                 if isinstance(key, int):
19*06c3fb27SDimitry Andric                     count = len(self)
20*06c3fb27SDimitry Andric                     if -count <= key < count:
21*06c3fb27SDimitry Andric                         key %= count
22*06c3fb27SDimitry Andric                         return self.sbbreakpoint.GetLocationAtIndex(key)
23*06c3fb27SDimitry Andric                 return None
24*06c3fb27SDimitry Andric 
25*06c3fb27SDimitry Andric         def get_locations_access_object(self):
26*06c3fb27SDimitry Andric             '''An accessor function that returns a locations_access() object which allows lazy location access from a lldb.SBBreakpoint object.'''
27*06c3fb27SDimitry Andric             return self.locations_access (self)
28*06c3fb27SDimitry Andric 
29*06c3fb27SDimitry Andric         def get_breakpoint_location_list(self):
30*06c3fb27SDimitry Andric             '''An accessor function that returns a list() that contains all locations in a lldb.SBBreakpoint object.'''
31*06c3fb27SDimitry Andric             locations = []
32*06c3fb27SDimitry Andric             accessor = self.get_locations_access_object()
33*06c3fb27SDimitry Andric             for idx in range(len(accessor)):
34*06c3fb27SDimitry Andric                 locations.append(accessor[idx])
35*06c3fb27SDimitry Andric             return locations
36*06c3fb27SDimitry Andric 
37*06c3fb27SDimitry Andric         def __iter__(self):
38*06c3fb27SDimitry Andric             '''Iterate over all breakpoint locations in a lldb.SBBreakpoint
39*06c3fb27SDimitry Andric             object.'''
40*06c3fb27SDimitry Andric             return lldb_iter(self, 'GetNumLocations', 'GetLocationAtIndex')
41*06c3fb27SDimitry Andric 
42*06c3fb27SDimitry Andric         def __len__(self):
43*06c3fb27SDimitry Andric             '''Return the number of breakpoint locations in a lldb.SBBreakpoint
44*06c3fb27SDimitry Andric             object.'''
45*06c3fb27SDimitry Andric             return self.GetNumLocations()
46*06c3fb27SDimitry Andric 
47*06c3fb27SDimitry Andric         locations = property(get_breakpoint_location_list, None, doc='''A read only property that returns a list() of lldb.SBBreakpointLocation objects for this breakpoint.''')
48*06c3fb27SDimitry Andric         location = property(get_locations_access_object, None, doc='''A read only property that returns an object that can access locations by index (not location ID) (location = bkpt.location[12]).''')
49*06c3fb27SDimitry Andric         id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''')
50*06c3fb27SDimitry Andric         enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''')
51*06c3fb27SDimitry Andric         one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''')
52*06c3fb27SDimitry Andric         num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''')
53*06c3fb27SDimitry Andric     %}
54*06c3fb27SDimitry Andric #endif
55*06c3fb27SDimitry Andric }
56