py-breakpoint.c revision 1.1.1.1 1 1.1 christos /* Python interface to breakpoints
2 1.1 christos
3 1.1 christos Copyright (C) 2008-2014 Free Software Foundation, Inc.
4 1.1 christos
5 1.1 christos This file is part of GDB.
6 1.1 christos
7 1.1 christos This program is free software; you can redistribute it and/or modify
8 1.1 christos it under the terms of the GNU General Public License as published by
9 1.1 christos the Free Software Foundation; either version 3 of the License, or
10 1.1 christos (at your option) any later version.
11 1.1 christos
12 1.1 christos This program is distributed in the hope that it will be useful,
13 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
14 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 1.1 christos GNU General Public License for more details.
16 1.1 christos
17 1.1 christos You should have received a copy of the GNU General Public License
18 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 1.1 christos
20 1.1 christos #include "defs.h"
21 1.1 christos #include "value.h"
22 1.1 christos #include "exceptions.h"
23 1.1 christos #include "python-internal.h"
24 1.1 christos #include "python.h"
25 1.1 christos #include "charset.h"
26 1.1 christos #include "breakpoint.h"
27 1.1 christos #include "gdbcmd.h"
28 1.1 christos #include "gdbthread.h"
29 1.1 christos #include "observer.h"
30 1.1 christos #include "cli/cli-script.h"
31 1.1 christos #include "ada-lang.h"
32 1.1 christos #include "arch-utils.h"
33 1.1 christos #include "language.h"
34 1.1 christos
35 1.1 christos /* Number of live breakpoints. */
36 1.1 christos static int bppy_live;
37 1.1 christos
38 1.1 christos /* Variables used to pass information between the Breakpoint
39 1.1 christos constructor and the breakpoint-created hook function. */
40 1.1 christos gdbpy_breakpoint_object *bppy_pending_object;
41 1.1 christos
42 1.1 christos /* Function that is called when a Python condition is evaluated. */
43 1.1 christos static char * const stop_func = "stop";
44 1.1 christos
45 1.1 christos /* This is used to initialize various gdb.bp_* constants. */
46 1.1 christos struct pybp_code
47 1.1 christos {
48 1.1 christos /* The name. */
49 1.1 christos const char *name;
50 1.1 christos /* The code. */
51 1.1 christos int code;
52 1.1 christos };
53 1.1 christos
54 1.1 christos /* Entries related to the type of user set breakpoints. */
55 1.1 christos static struct pybp_code pybp_codes[] =
56 1.1 christos {
57 1.1 christos { "BP_NONE", bp_none},
58 1.1 christos { "BP_BREAKPOINT", bp_breakpoint},
59 1.1 christos { "BP_WATCHPOINT", bp_watchpoint},
60 1.1 christos { "BP_HARDWARE_WATCHPOINT", bp_hardware_watchpoint},
61 1.1 christos { "BP_READ_WATCHPOINT", bp_read_watchpoint},
62 1.1 christos { "BP_ACCESS_WATCHPOINT", bp_access_watchpoint},
63 1.1 christos {NULL} /* Sentinel. */
64 1.1 christos };
65 1.1 christos
66 1.1 christos /* Entries related to the type of watchpoint. */
67 1.1 christos static struct pybp_code pybp_watch_types[] =
68 1.1 christos {
69 1.1 christos { "WP_READ", hw_read},
70 1.1 christos { "WP_WRITE", hw_write},
71 1.1 christos { "WP_ACCESS", hw_access},
72 1.1 christos {NULL} /* Sentinel. */
73 1.1 christos };
74 1.1 christos
75 1.1 christos /* Python function which checks the validity of a breakpoint object. */
76 1.1 christos static PyObject *
77 1.1 christos bppy_is_valid (PyObject *self, PyObject *args)
78 1.1 christos {
79 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
80 1.1 christos
81 1.1 christos if (self_bp->bp)
82 1.1 christos Py_RETURN_TRUE;
83 1.1 christos Py_RETURN_FALSE;
84 1.1 christos }
85 1.1 christos
86 1.1 christos /* Python function to test whether or not the breakpoint is enabled. */
87 1.1 christos static PyObject *
88 1.1 christos bppy_get_enabled (PyObject *self, void *closure)
89 1.1 christos {
90 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
91 1.1 christos
92 1.1 christos BPPY_REQUIRE_VALID (self_bp);
93 1.1 christos if (! self_bp->bp)
94 1.1 christos Py_RETURN_FALSE;
95 1.1 christos if (self_bp->bp->enable_state == bp_enabled)
96 1.1 christos Py_RETURN_TRUE;
97 1.1 christos Py_RETURN_FALSE;
98 1.1 christos }
99 1.1 christos
100 1.1 christos /* Python function to test whether or not the breakpoint is silent. */
101 1.1 christos static PyObject *
102 1.1 christos bppy_get_silent (PyObject *self, void *closure)
103 1.1 christos {
104 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
105 1.1 christos
106 1.1 christos BPPY_REQUIRE_VALID (self_bp);
107 1.1 christos if (self_bp->bp->silent)
108 1.1 christos Py_RETURN_TRUE;
109 1.1 christos Py_RETURN_FALSE;
110 1.1 christos }
111 1.1 christos
112 1.1 christos /* Python function to set the enabled state of a breakpoint. */
113 1.1 christos static int
114 1.1 christos bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure)
115 1.1 christos {
116 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
117 1.1 christos int cmp;
118 1.1 christos volatile struct gdb_exception except;
119 1.1 christos
120 1.1 christos BPPY_SET_REQUIRE_VALID (self_bp);
121 1.1 christos
122 1.1 christos if (newvalue == NULL)
123 1.1 christos {
124 1.1 christos PyErr_SetString (PyExc_TypeError,
125 1.1 christos _("Cannot delete `enabled' attribute."));
126 1.1 christos
127 1.1 christos return -1;
128 1.1 christos }
129 1.1 christos else if (! PyBool_Check (newvalue))
130 1.1 christos {
131 1.1 christos PyErr_SetString (PyExc_TypeError,
132 1.1 christos _("The value of `enabled' must be a boolean."));
133 1.1 christos return -1;
134 1.1 christos }
135 1.1 christos
136 1.1 christos cmp = PyObject_IsTrue (newvalue);
137 1.1 christos if (cmp < 0)
138 1.1 christos return -1;
139 1.1 christos
140 1.1 christos TRY_CATCH (except, RETURN_MASK_ALL)
141 1.1 christos {
142 1.1 christos if (cmp == 1)
143 1.1 christos enable_breakpoint (self_bp->bp);
144 1.1 christos else
145 1.1 christos disable_breakpoint (self_bp->bp);
146 1.1 christos }
147 1.1 christos GDB_PY_SET_HANDLE_EXCEPTION (except);
148 1.1 christos
149 1.1 christos return 0;
150 1.1 christos }
151 1.1 christos
152 1.1 christos /* Python function to set the 'silent' state of a breakpoint. */
153 1.1 christos static int
154 1.1 christos bppy_set_silent (PyObject *self, PyObject *newvalue, void *closure)
155 1.1 christos {
156 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
157 1.1 christos int cmp;
158 1.1 christos
159 1.1 christos BPPY_SET_REQUIRE_VALID (self_bp);
160 1.1 christos
161 1.1 christos if (newvalue == NULL)
162 1.1 christos {
163 1.1 christos PyErr_SetString (PyExc_TypeError,
164 1.1 christos _("Cannot delete `silent' attribute."));
165 1.1 christos return -1;
166 1.1 christos }
167 1.1 christos else if (! PyBool_Check (newvalue))
168 1.1 christos {
169 1.1 christos PyErr_SetString (PyExc_TypeError,
170 1.1 christos _("The value of `silent' must be a boolean."));
171 1.1 christos return -1;
172 1.1 christos }
173 1.1 christos
174 1.1 christos cmp = PyObject_IsTrue (newvalue);
175 1.1 christos if (cmp < 0)
176 1.1 christos return -1;
177 1.1 christos else
178 1.1 christos breakpoint_set_silent (self_bp->bp, cmp);
179 1.1 christos
180 1.1 christos return 0;
181 1.1 christos }
182 1.1 christos
183 1.1 christos /* Python function to set the thread of a breakpoint. */
184 1.1 christos static int
185 1.1 christos bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure)
186 1.1 christos {
187 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
188 1.1 christos long id;
189 1.1 christos
190 1.1 christos BPPY_SET_REQUIRE_VALID (self_bp);
191 1.1 christos
192 1.1 christos if (newvalue == NULL)
193 1.1 christos {
194 1.1 christos PyErr_SetString (PyExc_TypeError,
195 1.1 christos _("Cannot delete `thread' attribute."));
196 1.1 christos return -1;
197 1.1 christos }
198 1.1 christos else if (PyInt_Check (newvalue))
199 1.1 christos {
200 1.1 christos if (! gdb_py_int_as_long (newvalue, &id))
201 1.1 christos return -1;
202 1.1 christos
203 1.1 christos if (! valid_thread_id (id))
204 1.1 christos {
205 1.1 christos PyErr_SetString (PyExc_RuntimeError,
206 1.1 christos _("Invalid thread ID."));
207 1.1 christos return -1;
208 1.1 christos }
209 1.1 christos }
210 1.1 christos else if (newvalue == Py_None)
211 1.1 christos id = -1;
212 1.1 christos else
213 1.1 christos {
214 1.1 christos PyErr_SetString (PyExc_TypeError,
215 1.1 christos _("The value of `thread' must be an integer or None."));
216 1.1 christos return -1;
217 1.1 christos }
218 1.1 christos
219 1.1 christos breakpoint_set_thread (self_bp->bp, id);
220 1.1 christos
221 1.1 christos return 0;
222 1.1 christos }
223 1.1 christos
224 1.1 christos /* Python function to set the (Ada) task of a breakpoint. */
225 1.1 christos static int
226 1.1 christos bppy_set_task (PyObject *self, PyObject *newvalue, void *closure)
227 1.1 christos {
228 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
229 1.1 christos long id;
230 1.1 christos int valid_id = 0;
231 1.1 christos volatile struct gdb_exception except;
232 1.1 christos
233 1.1 christos BPPY_SET_REQUIRE_VALID (self_bp);
234 1.1 christos
235 1.1 christos if (newvalue == NULL)
236 1.1 christos {
237 1.1 christos PyErr_SetString (PyExc_TypeError,
238 1.1 christos _("Cannot delete `task' attribute."));
239 1.1 christos return -1;
240 1.1 christos }
241 1.1 christos else if (PyInt_Check (newvalue))
242 1.1 christos {
243 1.1 christos if (! gdb_py_int_as_long (newvalue, &id))
244 1.1 christos return -1;
245 1.1 christos
246 1.1 christos TRY_CATCH (except, RETURN_MASK_ALL)
247 1.1 christos {
248 1.1 christos valid_id = valid_task_id (id);
249 1.1 christos }
250 1.1 christos GDB_PY_SET_HANDLE_EXCEPTION (except);
251 1.1 christos
252 1.1 christos if (! valid_id)
253 1.1 christos {
254 1.1 christos PyErr_SetString (PyExc_RuntimeError,
255 1.1 christos _("Invalid task ID."));
256 1.1 christos return -1;
257 1.1 christos }
258 1.1 christos }
259 1.1 christos else if (newvalue == Py_None)
260 1.1 christos id = 0;
261 1.1 christos else
262 1.1 christos {
263 1.1 christos PyErr_SetString (PyExc_TypeError,
264 1.1 christos _("The value of `task' must be an integer or None."));
265 1.1 christos return -1;
266 1.1 christos }
267 1.1 christos
268 1.1 christos breakpoint_set_task (self_bp->bp, id);
269 1.1 christos
270 1.1 christos return 0;
271 1.1 christos }
272 1.1 christos
273 1.1 christos /* Python function which deletes the underlying GDB breakpoint. This
274 1.1 christos triggers the breakpoint_deleted observer which will call
275 1.1 christos gdbpy_breakpoint_deleted; that function cleans up the Python
276 1.1 christos sections. */
277 1.1 christos
278 1.1 christos static PyObject *
279 1.1 christos bppy_delete_breakpoint (PyObject *self, PyObject *args)
280 1.1 christos {
281 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
282 1.1 christos volatile struct gdb_exception except;
283 1.1 christos
284 1.1 christos BPPY_REQUIRE_VALID (self_bp);
285 1.1 christos
286 1.1 christos TRY_CATCH (except, RETURN_MASK_ALL)
287 1.1 christos {
288 1.1 christos delete_breakpoint (self_bp->bp);
289 1.1 christos }
290 1.1 christos GDB_PY_HANDLE_EXCEPTION (except);
291 1.1 christos
292 1.1 christos Py_RETURN_NONE;
293 1.1 christos }
294 1.1 christos
295 1.1 christos
296 1.1 christos /* Python function to set the ignore count of a breakpoint. */
297 1.1 christos static int
298 1.1 christos bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure)
299 1.1 christos {
300 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
301 1.1 christos long value;
302 1.1 christos volatile struct gdb_exception except;
303 1.1 christos
304 1.1 christos BPPY_SET_REQUIRE_VALID (self_bp);
305 1.1 christos
306 1.1 christos if (newvalue == NULL)
307 1.1 christos {
308 1.1 christos PyErr_SetString (PyExc_TypeError,
309 1.1 christos _("Cannot delete `ignore_count' attribute."));
310 1.1 christos return -1;
311 1.1 christos }
312 1.1 christos else if (! PyInt_Check (newvalue))
313 1.1 christos {
314 1.1 christos PyErr_SetString (PyExc_TypeError,
315 1.1 christos _("The value of `ignore_count' must be an integer."));
316 1.1 christos return -1;
317 1.1 christos }
318 1.1 christos
319 1.1 christos if (! gdb_py_int_as_long (newvalue, &value))
320 1.1 christos return -1;
321 1.1 christos
322 1.1 christos if (value < 0)
323 1.1 christos value = 0;
324 1.1 christos
325 1.1 christos TRY_CATCH (except, RETURN_MASK_ALL)
326 1.1 christos {
327 1.1 christos set_ignore_count (self_bp->number, (int) value, 0);
328 1.1 christos }
329 1.1 christos GDB_PY_SET_HANDLE_EXCEPTION (except);
330 1.1 christos
331 1.1 christos return 0;
332 1.1 christos }
333 1.1 christos
334 1.1 christos /* Python function to set the hit count of a breakpoint. */
335 1.1 christos static int
336 1.1 christos bppy_set_hit_count (PyObject *self, PyObject *newvalue, void *closure)
337 1.1 christos {
338 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
339 1.1 christos
340 1.1 christos BPPY_SET_REQUIRE_VALID (self_bp);
341 1.1 christos
342 1.1 christos if (newvalue == NULL)
343 1.1 christos {
344 1.1 christos PyErr_SetString (PyExc_TypeError,
345 1.1 christos _("Cannot delete `hit_count' attribute."));
346 1.1 christos return -1;
347 1.1 christos }
348 1.1 christos else
349 1.1 christos {
350 1.1 christos long value;
351 1.1 christos
352 1.1 christos if (! gdb_py_int_as_long (newvalue, &value))
353 1.1 christos return -1;
354 1.1 christos
355 1.1 christos if (value != 0)
356 1.1 christos {
357 1.1 christos PyErr_SetString (PyExc_AttributeError,
358 1.1 christos _("The value of `hit_count' must be zero."));
359 1.1 christos return -1;
360 1.1 christos }
361 1.1 christos }
362 1.1 christos
363 1.1 christos self_bp->bp->hit_count = 0;
364 1.1 christos
365 1.1 christos return 0;
366 1.1 christos }
367 1.1 christos
368 1.1 christos /* Python function to get the location of a breakpoint. */
369 1.1 christos static PyObject *
370 1.1 christos bppy_get_location (PyObject *self, void *closure)
371 1.1 christos {
372 1.1 christos char *str;
373 1.1 christos gdbpy_breakpoint_object *obj = (gdbpy_breakpoint_object *) self;
374 1.1 christos
375 1.1 christos BPPY_REQUIRE_VALID (obj);
376 1.1 christos
377 1.1 christos if (obj->bp->type != bp_breakpoint)
378 1.1 christos Py_RETURN_NONE;
379 1.1 christos
380 1.1 christos str = obj->bp->addr_string;
381 1.1 christos
382 1.1 christos if (! str)
383 1.1 christos str = "";
384 1.1 christos return PyString_Decode (str, strlen (str), host_charset (), NULL);
385 1.1 christos }
386 1.1 christos
387 1.1 christos /* Python function to get the breakpoint expression. */
388 1.1 christos static PyObject *
389 1.1 christos bppy_get_expression (PyObject *self, void *closure)
390 1.1 christos {
391 1.1 christos char *str;
392 1.1 christos gdbpy_breakpoint_object *obj = (gdbpy_breakpoint_object *) self;
393 1.1 christos struct watchpoint *wp;
394 1.1 christos
395 1.1 christos BPPY_REQUIRE_VALID (obj);
396 1.1 christos
397 1.1 christos if (!is_watchpoint (obj->bp))
398 1.1 christos Py_RETURN_NONE;
399 1.1 christos
400 1.1 christos wp = (struct watchpoint *) obj->bp;
401 1.1 christos
402 1.1 christos str = wp->exp_string;
403 1.1 christos if (! str)
404 1.1 christos str = "";
405 1.1 christos
406 1.1 christos return PyString_Decode (str, strlen (str), host_charset (), NULL);
407 1.1 christos }
408 1.1 christos
409 1.1 christos /* Python function to get the condition expression of a breakpoint. */
410 1.1 christos static PyObject *
411 1.1 christos bppy_get_condition (PyObject *self, void *closure)
412 1.1 christos {
413 1.1 christos char *str;
414 1.1 christos gdbpy_breakpoint_object *obj = (gdbpy_breakpoint_object *) self;
415 1.1 christos
416 1.1 christos BPPY_REQUIRE_VALID (obj);
417 1.1 christos
418 1.1 christos str = obj->bp->cond_string;
419 1.1 christos if (! str)
420 1.1 christos Py_RETURN_NONE;
421 1.1 christos
422 1.1 christos return PyString_Decode (str, strlen (str), host_charset (), NULL);
423 1.1 christos }
424 1.1 christos
425 1.1 christos /* Returns 0 on success. Returns -1 on error, with a python exception set.
426 1.1 christos */
427 1.1 christos
428 1.1 christos static int
429 1.1 christos bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure)
430 1.1 christos {
431 1.1 christos char *exp;
432 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
433 1.1 christos volatile struct gdb_exception except;
434 1.1 christos
435 1.1 christos BPPY_SET_REQUIRE_VALID (self_bp);
436 1.1 christos
437 1.1 christos if (newvalue == NULL)
438 1.1 christos {
439 1.1 christos PyErr_SetString (PyExc_TypeError,
440 1.1 christos _("Cannot delete `condition' attribute."));
441 1.1 christos return -1;
442 1.1 christos }
443 1.1 christos else if (newvalue == Py_None)
444 1.1 christos exp = "";
445 1.1 christos else
446 1.1 christos {
447 1.1 christos exp = python_string_to_host_string (newvalue);
448 1.1 christos if (exp == NULL)
449 1.1 christos return -1;
450 1.1 christos }
451 1.1 christos
452 1.1 christos TRY_CATCH (except, RETURN_MASK_ALL)
453 1.1 christos {
454 1.1 christos set_breakpoint_condition (self_bp->bp, exp, 0);
455 1.1 christos }
456 1.1 christos
457 1.1 christos if (newvalue != Py_None)
458 1.1 christos xfree (exp);
459 1.1 christos
460 1.1 christos GDB_PY_SET_HANDLE_EXCEPTION (except);
461 1.1 christos
462 1.1 christos return 0;
463 1.1 christos }
464 1.1 christos
465 1.1 christos /* Python function to get the commands attached to a breakpoint. */
466 1.1 christos static PyObject *
467 1.1 christos bppy_get_commands (PyObject *self, void *closure)
468 1.1 christos {
469 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
470 1.1 christos struct breakpoint *bp = self_bp->bp;
471 1.1 christos long length;
472 1.1 christos volatile struct gdb_exception except;
473 1.1 christos struct ui_file *string_file;
474 1.1 christos struct cleanup *chain;
475 1.1 christos PyObject *result;
476 1.1 christos char *cmdstr;
477 1.1 christos
478 1.1 christos BPPY_REQUIRE_VALID (self_bp);
479 1.1 christos
480 1.1 christos if (! self_bp->bp->commands)
481 1.1 christos Py_RETURN_NONE;
482 1.1 christos
483 1.1 christos string_file = mem_fileopen ();
484 1.1 christos chain = make_cleanup_ui_file_delete (string_file);
485 1.1 christos
486 1.1 christos ui_out_redirect (current_uiout, string_file);
487 1.1 christos TRY_CATCH (except, RETURN_MASK_ALL)
488 1.1 christos {
489 1.1 christos print_command_lines (current_uiout, breakpoint_commands (bp), 0);
490 1.1 christos }
491 1.1 christos ui_out_redirect (current_uiout, NULL);
492 1.1 christos if (except.reason < 0)
493 1.1 christos {
494 1.1 christos do_cleanups (chain);
495 1.1 christos gdbpy_convert_exception (except);
496 1.1 christos return NULL;
497 1.1 christos }
498 1.1 christos
499 1.1 christos cmdstr = ui_file_xstrdup (string_file, &length);
500 1.1 christos make_cleanup (xfree, cmdstr);
501 1.1 christos result = PyString_Decode (cmdstr, strlen (cmdstr), host_charset (), NULL);
502 1.1 christos do_cleanups (chain);
503 1.1 christos return result;
504 1.1 christos }
505 1.1 christos
506 1.1 christos /* Python function to get the breakpoint type. */
507 1.1 christos static PyObject *
508 1.1 christos bppy_get_type (PyObject *self, void *closure)
509 1.1 christos {
510 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
511 1.1 christos
512 1.1 christos BPPY_REQUIRE_VALID (self_bp);
513 1.1 christos
514 1.1 christos return PyInt_FromLong (self_bp->bp->type);
515 1.1 christos }
516 1.1 christos
517 1.1 christos /* Python function to get the visibility of the breakpoint. */
518 1.1 christos
519 1.1 christos static PyObject *
520 1.1 christos bppy_get_visibility (PyObject *self, void *closure)
521 1.1 christos {
522 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
523 1.1 christos
524 1.1 christos BPPY_REQUIRE_VALID (self_bp);
525 1.1 christos
526 1.1 christos if (self_bp->bp->number < 0)
527 1.1 christos Py_RETURN_FALSE;
528 1.1 christos
529 1.1 christos Py_RETURN_TRUE;
530 1.1 christos }
531 1.1 christos
532 1.1 christos /* Python function to determine if the breakpoint is a temporary
533 1.1 christos breakpoint. */
534 1.1 christos
535 1.1 christos static PyObject *
536 1.1 christos bppy_get_temporary (PyObject *self, void *closure)
537 1.1 christos {
538 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
539 1.1 christos
540 1.1 christos BPPY_REQUIRE_VALID (self_bp);
541 1.1 christos
542 1.1 christos if (self_bp->bp->disposition == disp_del
543 1.1 christos || self_bp->bp->disposition == disp_del_at_next_stop)
544 1.1 christos Py_RETURN_TRUE;
545 1.1 christos
546 1.1 christos Py_RETURN_FALSE;
547 1.1 christos }
548 1.1 christos
549 1.1 christos /* Python function to get the breakpoint's number. */
550 1.1 christos static PyObject *
551 1.1 christos bppy_get_number (PyObject *self, void *closure)
552 1.1 christos {
553 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
554 1.1 christos
555 1.1 christos BPPY_REQUIRE_VALID (self_bp);
556 1.1 christos
557 1.1 christos return PyInt_FromLong (self_bp->number);
558 1.1 christos }
559 1.1 christos
560 1.1 christos /* Python function to get the breakpoint's thread ID. */
561 1.1 christos static PyObject *
562 1.1 christos bppy_get_thread (PyObject *self, void *closure)
563 1.1 christos {
564 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
565 1.1 christos
566 1.1 christos BPPY_REQUIRE_VALID (self_bp);
567 1.1 christos
568 1.1 christos if (self_bp->bp->thread == -1)
569 1.1 christos Py_RETURN_NONE;
570 1.1 christos
571 1.1 christos return PyInt_FromLong (self_bp->bp->thread);
572 1.1 christos }
573 1.1 christos
574 1.1 christos /* Python function to get the breakpoint's task ID (in Ada). */
575 1.1 christos static PyObject *
576 1.1 christos bppy_get_task (PyObject *self, void *closure)
577 1.1 christos {
578 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
579 1.1 christos
580 1.1 christos BPPY_REQUIRE_VALID (self_bp);
581 1.1 christos
582 1.1 christos if (self_bp->bp->task == 0)
583 1.1 christos Py_RETURN_NONE;
584 1.1 christos
585 1.1 christos return PyInt_FromLong (self_bp->bp->task);
586 1.1 christos }
587 1.1 christos
588 1.1 christos /* Python function to get the breakpoint's hit count. */
589 1.1 christos static PyObject *
590 1.1 christos bppy_get_hit_count (PyObject *self, void *closure)
591 1.1 christos {
592 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
593 1.1 christos
594 1.1 christos BPPY_REQUIRE_VALID (self_bp);
595 1.1 christos
596 1.1 christos return PyInt_FromLong (self_bp->bp->hit_count);
597 1.1 christos }
598 1.1 christos
599 1.1 christos /* Python function to get the breakpoint's ignore count. */
600 1.1 christos static PyObject *
601 1.1 christos bppy_get_ignore_count (PyObject *self, void *closure)
602 1.1 christos {
603 1.1 christos gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
604 1.1 christos
605 1.1 christos BPPY_REQUIRE_VALID (self_bp);
606 1.1 christos
607 1.1 christos return PyInt_FromLong (self_bp->bp->ignore_count);
608 1.1 christos }
609 1.1 christos
610 1.1 christos /* Python function to create a new breakpoint. */
611 1.1 christos static int
612 1.1 christos bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
613 1.1 christos {
614 1.1 christos static char *keywords[] = { "spec", "type", "wp_class", "internal",
615 1.1 christos "temporary", NULL };
616 1.1 christos const char *spec;
617 1.1 christos int type = bp_breakpoint;
618 1.1 christos int access_type = hw_write;
619 1.1 christos PyObject *internal = NULL;
620 1.1 christos PyObject *temporary = NULL;
621 1.1 christos int internal_bp = 0;
622 1.1 christos int temporary_bp = 0;
623 1.1 christos volatile struct gdb_exception except;
624 1.1 christos
625 1.1 christos if (! PyArg_ParseTupleAndKeywords (args, kwargs, "s|iiOO", keywords,
626 1.1 christos &spec, &type, &access_type,
627 1.1 christos &internal, &temporary))
628 1.1 christos return -1;
629 1.1 christos
630 1.1 christos if (internal)
631 1.1 christos {
632 1.1 christos internal_bp = PyObject_IsTrue (internal);
633 1.1 christos if (internal_bp == -1)
634 1.1 christos return -1;
635 1.1 christos }
636 1.1 christos
637 1.1 christos if (temporary != NULL)
638 1.1 christos {
639 1.1 christos temporary_bp = PyObject_IsTrue (temporary);
640 1.1 christos if (temporary_bp == -1)
641 1.1 christos return -1;
642 1.1 christos }
643 1.1 christos
644 1.1 christos bppy_pending_object = (gdbpy_breakpoint_object *) self;
645 1.1 christos bppy_pending_object->number = -1;
646 1.1 christos bppy_pending_object->bp = NULL;
647 1.1 christos
648 1.1 christos TRY_CATCH (except, RETURN_MASK_ALL)
649 1.1 christos {
650 1.1 christos char *copy = xstrdup (spec);
651 1.1 christos struct cleanup *cleanup = make_cleanup (xfree, copy);
652 1.1 christos
653 1.1 christos switch (type)
654 1.1 christos {
655 1.1 christos case bp_breakpoint:
656 1.1 christos {
657 1.1 christos create_breakpoint (python_gdbarch,
658 1.1 christos copy, NULL, -1, NULL,
659 1.1 christos 0,
660 1.1 christos temporary_bp, bp_breakpoint,
661 1.1 christos 0,
662 1.1 christos AUTO_BOOLEAN_TRUE,
663 1.1 christos &bkpt_breakpoint_ops,
664 1.1 christos 0, 1, internal_bp, 0);
665 1.1 christos break;
666 1.1 christos }
667 1.1 christos case bp_watchpoint:
668 1.1 christos {
669 1.1 christos if (access_type == hw_write)
670 1.1 christos watch_command_wrapper (copy, 0, internal_bp);
671 1.1 christos else if (access_type == hw_access)
672 1.1 christos awatch_command_wrapper (copy, 0, internal_bp);
673 1.1 christos else if (access_type == hw_read)
674 1.1 christos rwatch_command_wrapper (copy, 0, internal_bp);
675 1.1 christos else
676 1.1 christos error(_("Cannot understand watchpoint access type."));
677 1.1 christos break;
678 1.1 christos }
679 1.1 christos default:
680 1.1 christos error(_("Do not understand breakpoint type to set."));
681 1.1 christos }
682 1.1 christos
683 1.1 christos do_cleanups (cleanup);
684 1.1 christos }
685 1.1 christos if (except.reason < 0)
686 1.1 christos {
687 1.1 christos PyErr_Format (except.reason == RETURN_QUIT
688 1.1 christos ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
689 1.1 christos "%s", except.message);
690 1.1 christos return -1;
691 1.1 christos }
692 1.1 christos
693 1.1 christos BPPY_SET_REQUIRE_VALID ((gdbpy_breakpoint_object *) self);
694 1.1 christos return 0;
695 1.1 christos }
696 1.1 christos
697 1.1 christos
698 1.1 christos
700 1.1 christos static int
701 1.1 christos build_bp_list (struct breakpoint *b, void *arg)
702 1.1 christos {
703 1.1 christos PyObject *list = arg;
704 1.1 christos PyObject *bp = (PyObject *) b->py_bp_object;
705 1.1 christos int iserr = 0;
706 1.1 christos
707 1.1 christos /* Not all breakpoints will have a companion Python object.
708 1.1 christos Only breakpoints that were created via bppy_new, or
709 1.1 christos breakpoints that were created externally and are tracked by
710 1.1 christos the Python Scripting API. */
711 1.1 christos if (bp)
712 1.1 christos iserr = PyList_Append (list, bp);
713 1.1 christos
714 1.1 christos if (iserr == -1)
715 1.1 christos return 1;
716 1.1 christos
717 1.1 christos return 0;
718 1.1 christos }
719 1.1 christos
720 1.1 christos /* Static function to return a tuple holding all breakpoints. */
721 1.1 christos
722 1.1 christos PyObject *
723 1.1 christos gdbpy_breakpoints (PyObject *self, PyObject *args)
724 1.1 christos {
725 1.1 christos PyObject *list, *tuple;
726 1.1 christos
727 1.1 christos if (bppy_live == 0)
728 1.1 christos Py_RETURN_NONE;
729 1.1 christos
730 1.1 christos list = PyList_New (0);
731 1.1 christos if (!list)
732 1.1 christos return NULL;
733 1.1 christos
734 1.1 christos /* If iteratre_over_breakpoints returns non NULL it signals an error
735 1.1 christos condition. In that case abandon building the list and return
736 1.1 christos NULL. */
737 1.1 christos if (iterate_over_breakpoints (build_bp_list, list) != NULL)
738 1.1 christos {
739 1.1 christos Py_DECREF (list);
740 1.1 christos return NULL;
741 1.1 christos }
742 1.1 christos
743 1.1 christos tuple = PyList_AsTuple (list);
744 1.1 christos Py_DECREF (list);
745 1.1 christos
746 1.1 christos return tuple;
747 1.1 christos }
748 1.1 christos
749 1.1 christos /* Call the "stop" method (if implemented) in the breakpoint
750 1.1 christos class. If the method returns True, the inferior will be
751 1.1 christos stopped at the breakpoint. Otherwise the inferior will be
752 1.1 christos allowed to continue. */
753 1.1 christos
754 1.1 christos int
755 1.1 christos gdbpy_should_stop (struct gdbpy_breakpoint_object *bp_obj)
756 1.1 christos {
757 1.1 christos int stop = 1;
758 1.1 christos
759 1.1 christos PyObject *py_bp = (PyObject *) bp_obj;
760 1.1 christos struct breakpoint *b = bp_obj->bp;
761 1.1 christos struct gdbarch *garch = b->gdbarch ? b->gdbarch : get_current_arch ();
762 1.1 christos struct cleanup *cleanup = ensure_python_env (garch, current_language);
763 1.1 christos
764 1.1 christos if (bp_obj->is_finish_bp)
765 1.1 christos bpfinishpy_pre_stop_hook (bp_obj);
766 1.1 christos
767 1.1 christos if (PyObject_HasAttrString (py_bp, stop_func))
768 1.1 christos {
769 1.1 christos PyObject *result = PyObject_CallMethod (py_bp, stop_func, NULL);
770 1.1 christos
771 1.1 christos if (result)
772 1.1 christos {
773 1.1 christos int evaluate = PyObject_IsTrue (result);
774 1.1 christos
775 1.1 christos if (evaluate == -1)
776 1.1 christos gdbpy_print_stack ();
777 1.1 christos
778 1.1 christos /* If the "stop" function returns False that means
779 1.1 christos the Python breakpoint wants GDB to continue. */
780 1.1 christos if (! evaluate)
781 1.1 christos stop = 0;
782 1.1 christos
783 1.1 christos Py_DECREF (result);
784 1.1 christos }
785 1.1 christos else
786 1.1 christos gdbpy_print_stack ();
787 1.1 christos }
788 1.1 christos
789 1.1 christos if (bp_obj->is_finish_bp)
790 1.1 christos bpfinishpy_post_stop_hook (bp_obj);
791 1.1 christos
792 1.1 christos do_cleanups (cleanup);
793 1.1 christos
794 1.1 christos return stop;
795 1.1 christos }
796 1.1 christos
797 1.1 christos /* Checks if the "stop" method exists in this breakpoint.
798 1.1 christos Used by condition_command to ensure mutual exclusion of breakpoint
799 1.1 christos conditions. */
800 1.1 christos
801 1.1 christos int
802 1.1 christos gdbpy_breakpoint_has_py_cond (struct gdbpy_breakpoint_object *bp_obj)
803 1.1 christos {
804 1.1 christos int has_func = 0;
805 1.1 christos PyObject *py_bp = (PyObject *) bp_obj;
806 1.1 christos struct gdbarch *garch = bp_obj->bp->gdbarch ? bp_obj->bp->gdbarch :
807 1.1 christos get_current_arch ();
808 1.1 christos struct cleanup *cleanup = ensure_python_env (garch, current_language);
809 1.1 christos
810 1.1 christos if (py_bp != NULL)
811 1.1 christos has_func = PyObject_HasAttrString (py_bp, stop_func);
812 1.1 christos
813 1.1 christos do_cleanups (cleanup);
814 1.1 christos
815 1.1 christos return has_func;
816 1.1 christos }
817 1.1 christos
818 1.1 christos
819 1.1 christos
821 1.1 christos /* Event callback functions. */
822 1.1 christos
823 1.1 christos /* Callback that is used when a breakpoint is created. This function
824 1.1 christos will create a new Python breakpoint object. */
825 1.1 christos static void
826 1.1 christos gdbpy_breakpoint_created (struct breakpoint *bp)
827 1.1 christos {
828 1.1 christos gdbpy_breakpoint_object *newbp;
829 1.1 christos PyGILState_STATE state;
830 1.1 christos
831 1.1 christos if (bp->number < 0 && bppy_pending_object == NULL)
832 1.1 christos return;
833 1.1 christos
834 1.1 christos if (bp->type != bp_breakpoint
835 1.1 christos && bp->type != bp_watchpoint
836 1.1 christos && bp->type != bp_hardware_watchpoint
837 1.1 christos && bp->type != bp_read_watchpoint
838 1.1 christos && bp->type != bp_access_watchpoint)
839 1.1 christos return;
840 1.1 christos
841 1.1 christos state = PyGILState_Ensure ();
842 1.1 christos
843 1.1 christos if (bppy_pending_object)
844 1.1 christos {
845 1.1 christos newbp = bppy_pending_object;
846 1.1 christos bppy_pending_object = NULL;
847 1.1 christos }
848 1.1 christos else
849 1.1 christos newbp = PyObject_New (gdbpy_breakpoint_object, &breakpoint_object_type);
850 1.1 christos if (newbp)
851 1.1 christos {
852 1.1 christos newbp->number = bp->number;
853 1.1 christos newbp->bp = bp;
854 1.1 christos newbp->bp->py_bp_object = newbp;
855 1.1 christos newbp->is_finish_bp = 0;
856 1.1 christos Py_INCREF (newbp);
857 1.1 christos ++bppy_live;
858 1.1 christos }
859 1.1 christos else
860 1.1 christos {
861 1.1 christos PyErr_SetString (PyExc_RuntimeError,
862 1.1 christos _("Error while creating breakpoint from GDB."));
863 1.1 christos gdbpy_print_stack ();
864 1.1 christos }
865 1.1 christos
866 1.1 christos PyGILState_Release (state);
867 1.1 christos }
868 1.1 christos
869 1.1 christos /* Callback that is used when a breakpoint is deleted. This will
870 1.1 christos invalidate the corresponding Python object. */
871 1.1 christos static void
872 1.1 christos gdbpy_breakpoint_deleted (struct breakpoint *b)
873 1.1 christos {
874 1.1 christos int num = b->number;
875 1.1 christos PyGILState_STATE state;
876 1.1 christos struct breakpoint *bp = NULL;
877 1.1 christos gdbpy_breakpoint_object *bp_obj;
878 1.1 christos
879 1.1 christos state = PyGILState_Ensure ();
880 1.1 christos bp = get_breakpoint (num);
881 1.1 christos if (bp)
882 1.1 christos {
883 1.1 christos bp_obj = bp->py_bp_object;
884 1.1 christos if (bp_obj)
885 1.1 christos {
886 1.1 christos bp_obj->bp = NULL;
887 1.1 christos --bppy_live;
888 1.1 christos Py_DECREF (bp_obj);
889 1.1 christos }
890 1.1 christos }
891 1.1 christos PyGILState_Release (state);
892 1.1 christos }
893 1.1 christos
894 1.1 christos
895 1.1 christos
897 1.1 christos /* Initialize the Python breakpoint code. */
898 1.1 christos int
899 1.1 christos gdbpy_initialize_breakpoints (void)
900 1.1 christos {
901 1.1 christos int i;
902 1.1 christos
903 1.1 christos breakpoint_object_type.tp_new = PyType_GenericNew;
904 1.1 christos if (PyType_Ready (&breakpoint_object_type) < 0)
905 1.1 christos return -1;
906 1.1 christos
907 1.1 christos if (gdb_pymodule_addobject (gdb_module, "Breakpoint",
908 1.1 christos (PyObject *) &breakpoint_object_type) < 0)
909 1.1 christos return -1;
910 1.1 christos
911 1.1 christos observer_attach_breakpoint_created (gdbpy_breakpoint_created);
912 1.1 christos observer_attach_breakpoint_deleted (gdbpy_breakpoint_deleted);
913 1.1 christos
914 1.1 christos /* Add breakpoint types constants. */
915 1.1 christos for (i = 0; pybp_codes[i].name; ++i)
916 1.1 christos {
917 1.1 christos if (PyModule_AddIntConstant (gdb_module,
918 1.1 christos /* Cast needed for Python 2.4. */
919 1.1 christos (char *) pybp_codes[i].name,
920 1.1 christos pybp_codes[i].code) < 0)
921 1.1 christos return -1;
922 1.1 christos }
923 1.1 christos
924 1.1 christos /* Add watchpoint types constants. */
925 1.1 christos for (i = 0; pybp_watch_types[i].name; ++i)
926 1.1 christos {
927 1.1 christos if (PyModule_AddIntConstant (gdb_module,
928 1.1 christos /* Cast needed for Python 2.4. */
929 1.1 christos (char *) pybp_watch_types[i].name,
930 1.1 christos pybp_watch_types[i].code) < 0)
931 1.1 christos return -1;
932 1.1 christos }
933 1.1 christos
934 1.1 christos return 0;
935 1.1 christos }
936 1.1 christos
937 1.1 christos
938 1.1 christos
940 1.1 christos /* Helper function that overrides this Python object's
941 1.1 christos PyObject_GenericSetAttr to allow extra validation of the attribute
942 1.1 christos being set. */
943 1.1 christos
944 1.1 christos static int
945 1.1 christos local_setattro (PyObject *self, PyObject *name, PyObject *v)
946 1.1 christos {
947 1.1 christos gdbpy_breakpoint_object *obj = (gdbpy_breakpoint_object *) self;
948 1.1 christos char *attr = python_string_to_host_string (name);
949 1.1 christos
950 1.1 christos if (attr == NULL)
951 1.1 christos return -1;
952 1.1 christos
953 1.1 christos /* If the attribute trying to be set is the "stop" method,
954 1.1 christos but we already have a condition set in the CLI, disallow this
955 1.1 christos operation. */
956 1.1 christos if (strcmp (attr, stop_func) == 0 && obj->bp->cond_string)
957 1.1 christos {
958 1.1 christos xfree (attr);
959 1.1 christos PyErr_SetString (PyExc_RuntimeError,
960 1.1 christos _("Cannot set 'stop' method. There is an " \
961 1.1 christos "existing GDB condition attached to the " \
962 1.1 christos "breakpoint."));
963 1.1 christos return -1;
964 1.1 christos }
965 1.1 christos
966 1.1 christos xfree (attr);
967 1.1 christos
968 1.1 christos return PyObject_GenericSetAttr ((PyObject *)self, name, v);
969 1.1 christos }
970 1.1 christos
971 1.1 christos static PyGetSetDef breakpoint_object_getset[] = {
972 1.1 christos { "enabled", bppy_get_enabled, bppy_set_enabled,
973 1.1 christos "Boolean telling whether the breakpoint is enabled.", NULL },
974 1.1 christos { "silent", bppy_get_silent, bppy_set_silent,
975 1.1 christos "Boolean telling whether the breakpoint is silent.", NULL },
976 1.1 christos { "thread", bppy_get_thread, bppy_set_thread,
977 1.1 christos "Thread ID for the breakpoint.\n\
978 1.1 christos If the value is a thread ID (integer), then this is a thread-specific breakpoint.\n\
979 1.1 christos If the value is None, then this breakpoint is not thread-specific.\n\
980 1.1 christos No other type of value can be used.", NULL },
981 1.1 christos { "task", bppy_get_task, bppy_set_task,
982 1.1 christos "Thread ID for the breakpoint.\n\
983 1.1 christos If the value is a task ID (integer), then this is an Ada task-specific breakpoint.\n\
984 1.1 christos If the value is None, then this breakpoint is not task-specific.\n\
985 1.1 christos No other type of value can be used.", NULL },
986 1.1 christos { "ignore_count", bppy_get_ignore_count, bppy_set_ignore_count,
987 1.1 christos "Number of times this breakpoint should be automatically continued.",
988 1.1 christos NULL },
989 1.1 christos { "number", bppy_get_number, NULL,
990 1.1 christos "Breakpoint's number assigned by GDB.", NULL },
991 1.1 christos { "hit_count", bppy_get_hit_count, bppy_set_hit_count,
992 1.1 christos "Number of times the breakpoint has been hit.\n\
993 1.1 christos Can be set to zero to clear the count. No other value is valid\n\
994 1.1 christos when setting this property.", NULL },
995 1.1 christos { "location", bppy_get_location, NULL,
996 1.1 christos "Location of the breakpoint, as specified by the user.", NULL},
997 1.1 christos { "expression", bppy_get_expression, NULL,
998 1.1 christos "Expression of the breakpoint, as specified by the user.", NULL},
999 1.1 christos { "condition", bppy_get_condition, bppy_set_condition,
1000 1.1 christos "Condition of the breakpoint, as specified by the user,\
1001 1.1 christos or None if no condition set."},
1002 1.1 christos { "commands", bppy_get_commands, NULL,
1003 1.1 christos "Commands of the breakpoint, as specified by the user."},
1004 1.1 christos { "type", bppy_get_type, NULL,
1005 1.1 christos "Type of breakpoint."},
1006 1.1 christos { "visible", bppy_get_visibility, NULL,
1007 1.1 christos "Whether the breakpoint is visible to the user."},
1008 1.1 christos { "temporary", bppy_get_temporary, NULL,
1009 1.1 christos "Whether this breakpoint is a temporary breakpoint."},
1010 1.1 christos { NULL } /* Sentinel. */
1011 1.1 christos };
1012 1.1 christos
1013 1.1 christos static PyMethodDef breakpoint_object_methods[] =
1014 1.1 christos {
1015 1.1 christos { "is_valid", bppy_is_valid, METH_NOARGS,
1016 1.1 christos "Return true if this breakpoint is valid, false if not." },
1017 1.1 christos { "delete", bppy_delete_breakpoint, METH_NOARGS,
1018 1.1 christos "Delete the underlying GDB breakpoint." },
1019 1.1 christos { NULL } /* Sentinel. */
1020 1.1 christos };
1021 1.1 christos
1022 1.1 christos PyTypeObject breakpoint_object_type =
1023 1.1 christos {
1024 1.1 christos PyVarObject_HEAD_INIT (NULL, 0)
1025 1.1 christos "gdb.Breakpoint", /*tp_name*/
1026 1.1 christos sizeof (gdbpy_breakpoint_object), /*tp_basicsize*/
1027 1.1 christos 0, /*tp_itemsize*/
1028 1.1 christos 0, /*tp_dealloc*/
1029 1.1 christos 0, /*tp_print*/
1030 1.1 christos 0, /*tp_getattr*/
1031 1.1 christos 0, /*tp_setattr*/
1032 1.1 christos 0, /*tp_compare*/
1033 1.1 christos 0, /*tp_repr*/
1034 1.1 christos 0, /*tp_as_number*/
1035 1.1 christos 0, /*tp_as_sequence*/
1036 1.1 christos 0, /*tp_as_mapping*/
1037 1.1 christos 0, /*tp_hash */
1038 1.1 christos 0, /*tp_call*/
1039 1.1 christos 0, /*tp_str*/
1040 1.1 christos 0, /*tp_getattro*/
1041 1.1 christos (setattrofunc)local_setattro, /*tp_setattro */
1042 1.1 christos 0, /*tp_as_buffer*/
1043 1.1 christos Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
1044 1.1 christos "GDB breakpoint object", /* tp_doc */
1045 1.1 christos 0, /* tp_traverse */
1046 1.1 christos 0, /* tp_clear */
1047 1.1 christos 0, /* tp_richcompare */
1048 1.1 christos 0, /* tp_weaklistoffset */
1049 1.1 christos 0, /* tp_iter */
1050 1.1 christos 0, /* tp_iternext */
1051 1.1 christos breakpoint_object_methods, /* tp_methods */
1052 1.1 christos 0, /* tp_members */
1053 1.1 christos breakpoint_object_getset, /* tp_getset */
1054 1.1 christos 0, /* tp_base */
1055 1.1 christos 0, /* tp_dict */
1056 1.1 christos 0, /* tp_descr_get */
1057 1.1 christos 0, /* tp_descr_set */
1058 0, /* tp_dictoffset */
1059 bppy_init, /* tp_init */
1060 0, /* tp_alloc */
1061 };
1062