xref: /freebsd/contrib/llvm-project/lldb/bindings/interface/SBBreakpointDocstrings.i (revision e1c4c8dd8d2d10b6104f06856a77bd5b4813a801)
1 %feature("docstring",
2 "Represents a logical breakpoint and its associated settings.
3 
4 For example (from test/functionalities/breakpoint/breakpoint_ignore_count/
5 TestBreakpointIgnoreCount.py),::
6 
7     def breakpoint_ignore_count_python(self):
8         '''Use Python APIs to set breakpoint ignore count.'''
9         exe = os.path.join(os.getcwd(), 'a.out')
10 
11         # Create a target by the debugger.
12         target = self.dbg.CreateTarget(exe)
13         self.assertTrue(target, VALID_TARGET)
14 
15         # Now create a breakpoint on main.c by name 'c'.
16         breakpoint = target.BreakpointCreateByName('c', 'a.out')
17         self.assertTrue(breakpoint and
18                         breakpoint.GetNumLocations() == 1,
19                         VALID_BREAKPOINT)
20 
21         # Get the breakpoint location from breakpoint after we verified that,
22         # indeed, it has one location.
23         location = breakpoint.GetLocationAtIndex(0)
24         self.assertTrue(location and
25                         location.IsEnabled(),
26                         VALID_BREAKPOINT_LOCATION)
27 
28         # Set the ignore count on the breakpoint location.
29         location.SetIgnoreCount(2)
30         self.assertTrue(location.GetIgnoreCount() == 2,
31                         'SetIgnoreCount() works correctly')
32 
33         # Now launch the process, and do not stop at entry point.
34         process = target.LaunchSimple(None, None, os.getcwd())
35         self.assertTrue(process, PROCESS_IS_VALID)
36 
37         # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and
38         # frame#2 should be on main.c:48.
39         #lldbutil.print_stacktraces(process)
40         from lldbutil import get_stopped_thread
41         thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
42         self.assertTrue(thread != None, 'There should be a thread stopped due to breakpoint')
43         frame0 = thread.GetFrameAtIndex(0)
44         frame1 = thread.GetFrameAtIndex(1)
45         frame2 = thread.GetFrameAtIndex(2)
46         self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and
47                         frame1.GetLineEntry().GetLine() == self.line3 and
48                         frame2.GetLineEntry().GetLine() == self.line4,
49                         STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT)
50 
51         # The hit count for the breakpoint should be 3.
52         self.assertTrue(breakpoint.GetHitCount() == 3)
53 
54         process.Continue()
55 
56 SBBreakpoint supports breakpoint location iteration, for example,::
57 
58     for bl in breakpoint:
59         print('breakpoint location load addr: %s' % hex(bl.GetLoadAddress()))
60         print('breakpoint location condition: %s' % hex(bl.GetCondition()))
61 
62 and rich comparison methods which allow the API program to use,::
63 
64     if aBreakpoint == bBreakpoint:
65         ...
66 
67 to compare two breakpoints for equality."
68 ) lldb::SBBreakpoint;
69 
70 %feature("docstring", "
71     The breakpoint stops only if the condition expression evaluates to true."
72 ) lldb::SBBreakpoint::SetCondition;
73 
74 %feature("docstring", "
75     Get the condition expression for the breakpoint."
76 ) lldb::SBBreakpoint::GetCondition;
77 
78 %feature("docstring", "
79     Set the name of the script function to be called when the breakpoint is hit."
80 ) lldb::SBBreakpoint::SetScriptCallbackFunction;
81 
82 %feature("docstring", "
83     Set the name of the script function to be called when the breakpoint is hit.
84     To use this variant, the function should take (frame, bp_loc, extra_args, internal_dict) and
85     when the breakpoint is hit the extra_args will be passed to the callback function."
86 ) lldb::SBBreakpoint::SetScriptCallbackFunction;
87 
88 %feature("docstring", "
89     Provide the body for the script function to be called when the breakpoint is hit.
90     The body will be wrapped in a function, which be passed two arguments:
91     'frame' - which holds the bottom-most SBFrame of the thread that hit the breakpoint
92     'bpno'  - which is the SBBreakpointLocation to which the callback was attached.
93 
94     The error parameter is currently ignored, but will at some point hold the Python
95     compilation diagnostics.
96     Returns true if the body compiles successfully, false if not."
97 ) lldb::SBBreakpoint::SetScriptCallbackBody;
98 
99 
100 %feature("docstring",
101 "Represents a list of :py:class:`SBBreakpoint`."
102 ) lldb::SBBreakpointList;
103