blob: 3c2920a5f4113b604fc12a884802056b7c560f57 [file] [log] [blame]
Johnny Chen3cfd5e82011-07-18 21:30:21 +00001//===-- SWIG Interface for SBBreakpoint -------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10namespace lldb {
11
12%feature("docstring",
13"Represents a logical breakpoint and its associated settings.
14
15For example (from test/functionalities/breakpoint/breakpoint_ignore_count/
16TestBreakpointIgnoreCount.py),
17
18 def breakpoint_ignore_count_python(self):
19 '''Use Python APIs to set breakpoint ignore count.'''
20 exe = os.path.join(os.getcwd(), 'a.out')
21
22 # Create a target by the debugger.
23 target = self.dbg.CreateTarget(exe)
24 self.assertTrue(target, VALID_TARGET)
25
26 # Now create a breakpoint on main.c by name 'c'.
27 breakpoint = target.BreakpointCreateByName('c', 'a.out')
28 self.assertTrue(breakpoint and
29 breakpoint.GetNumLocations() == 1,
30 VALID_BREAKPOINT)
31
32 # Get the breakpoint location from breakpoint after we verified that,
33 # indeed, it has one location.
34 location = breakpoint.GetLocationAtIndex(0)
35 self.assertTrue(location and
36 location.IsEnabled(),
37 VALID_BREAKPOINT_LOCATION)
38
39 # Set the ignore count on the breakpoint location.
40 location.SetIgnoreCount(2)
41 self.assertTrue(location.GetIgnoreCount() == 2,
42 'SetIgnoreCount() works correctly')
43
44 # Now launch the process, and do not stop at entry point.
45 process = target.LaunchSimple(None, None, os.getcwd())
46 self.assertTrue(process, PROCESS_IS_VALID)
47
48 # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and
49 # frame#2 should be on main.c:48.
50 #lldbutil.print_stacktraces(process)
51 from lldbutil import get_stopped_thread
52 thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
53 self.assertTrue(thread != None, 'There should be a thread stopped due to breakpoint')
54 frame0 = thread.GetFrameAtIndex(0)
55 frame1 = thread.GetFrameAtIndex(1)
56 frame2 = thread.GetFrameAtIndex(2)
57 self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and
58 frame1.GetLineEntry().GetLine() == self.line3 and
59 frame2.GetLineEntry().GetLine() == self.line4,
60 STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT)
61
62 # The hit count for the breakpoint should be 3.
63 self.assertTrue(breakpoint.GetHitCount() == 3)
64
65 process.Continue()
66
67SBBreakpoint supports breakpoint location iteration. For example,
68
69 for bl in breakpoint:
70 print 'breakpoint location load addr: %s' % hex(bl.GetLoadAddress())
71 print 'breakpoint location condition: %s' % hex(bl.GetCondition())
72") SBBreakpoint;
73class SBBreakpoint
74{
75public:
76
77 typedef bool (*BreakpointHitCallback) (void *baton,
78 SBProcess &process,
79 SBThread &thread,
80 lldb::SBBreakpointLocation &location);
81
82 SBBreakpoint ();
83
84 SBBreakpoint (const lldb::SBBreakpoint& rhs);
85
86 ~SBBreakpoint();
87
88 break_id_t
89 GetID () const;
90
91 bool
92 IsValid() const;
93
94 void
95 ClearAllBreakpointSites ();
96
97 lldb::SBBreakpointLocation
98 FindLocationByAddress (lldb::addr_t vm_addr);
99
100 lldb::break_id_t
101 FindLocationIDByAddress (lldb::addr_t vm_addr);
102
103 lldb::SBBreakpointLocation
104 FindLocationByID (lldb::break_id_t bp_loc_id);
105
106 lldb::SBBreakpointLocation
107 GetLocationAtIndex (uint32_t index);
108
109 void
110 SetEnabled (bool enable);
111
112 bool
113 IsEnabled ();
114
115 uint32_t
116 GetHitCount () const;
117
118 void
119 SetIgnoreCount (uint32_t count);
120
121 uint32_t
122 GetIgnoreCount () const;
123
124 void
125 SetCondition (const char *condition);
126
127 const char *
128 GetCondition ();
129
130 void
131 SetThreadID (lldb::tid_t sb_thread_id);
132
133 lldb::tid_t
134 GetThreadID ();
135
136 void
137 SetThreadIndex (uint32_t index);
138
139 uint32_t
140 GetThreadIndex() const;
141
142 void
143 SetThreadName (const char *thread_name);
144
145 const char *
146 GetThreadName () const;
147
148 void
149 SetQueueName (const char *queue_name);
150
151 const char *
152 GetQueueName () const;
153
154 void
155 SetCallback (BreakpointHitCallback callback, void *baton);
156
157 size_t
158 GetNumResolvedLocations() const;
159
160 size_t
161 GetNumLocations() const;
162
163 bool
164 GetDescription (lldb::SBStream &description);
165
166 static lldb::BreakpointEventType
167 GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event);
168
169 static lldb::SBBreakpoint
170 GetBreakpointFromEvent (const lldb::SBEvent& event);
171
172 static lldb::SBBreakpointLocation
173 GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx);
174};
175
176} // namespace lldb