1 /* Python interface to breakpoints
3 Copyright (C) 2008-2013 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #include "exceptions.h"
23 #include "python-internal.h"
26 #include "breakpoint.h"
28 #include "gdbthread.h"
30 #include "cli/cli-script.h"
32 #include "arch-utils.h"
35 /* Number of live breakpoints. */
38 /* Variables used to pass information between the Breakpoint
39 constructor and the breakpoint-created hook function. */
40 breakpoint_object
*bppy_pending_object
;
42 /* Function that is called when a Python condition is evaluated. */
43 static char * const stop_func
= "stop";
45 /* This is used to initialize various gdb.bp_* constants. */
54 /* Entries related to the type of user set breakpoints. */
55 static struct pybp_code pybp_codes
[] =
57 { "BP_NONE", bp_none
},
58 { "BP_BREAKPOINT", bp_breakpoint
},
59 { "BP_WATCHPOINT", bp_watchpoint
},
60 { "BP_HARDWARE_WATCHPOINT", bp_hardware_watchpoint
},
61 { "BP_READ_WATCHPOINT", bp_read_watchpoint
},
62 { "BP_ACCESS_WATCHPOINT", bp_access_watchpoint
},
63 {NULL
} /* Sentinel. */
66 /* Entries related to the type of watchpoint. */
67 static struct pybp_code pybp_watch_types
[] =
69 { "WP_READ", hw_read
},
70 { "WP_WRITE", hw_write
},
71 { "WP_ACCESS", hw_access
},
72 {NULL
} /* Sentinel. */
75 /* Python function which checks the validity of a breakpoint object. */
77 bppy_is_valid (PyObject
*self
, PyObject
*args
)
79 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
86 /* Python function to test whether or not the breakpoint is enabled. */
88 bppy_get_enabled (PyObject
*self
, void *closure
)
90 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
92 BPPY_REQUIRE_VALID (self_bp
);
95 if (self_bp
->bp
->enable_state
== bp_enabled
)
100 /* Python function to test whether or not the breakpoint is silent. */
102 bppy_get_silent (PyObject
*self
, void *closure
)
104 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
106 BPPY_REQUIRE_VALID (self_bp
);
107 if (self_bp
->bp
->silent
)
112 /* Python function to set the enabled state of a breakpoint. */
114 bppy_set_enabled (PyObject
*self
, PyObject
*newvalue
, void *closure
)
116 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
118 volatile struct gdb_exception except
;
120 BPPY_SET_REQUIRE_VALID (self_bp
);
122 if (newvalue
== NULL
)
124 PyErr_SetString (PyExc_TypeError
,
125 _("Cannot delete `enabled' attribute."));
129 else if (! PyBool_Check (newvalue
))
131 PyErr_SetString (PyExc_TypeError
,
132 _("The value of `enabled' must be a boolean."));
136 cmp
= PyObject_IsTrue (newvalue
);
140 TRY_CATCH (except
, RETURN_MASK_ALL
)
143 enable_breakpoint (self_bp
->bp
);
145 disable_breakpoint (self_bp
->bp
);
147 GDB_PY_SET_HANDLE_EXCEPTION (except
);
152 /* Python function to set the 'silent' state of a breakpoint. */
154 bppy_set_silent (PyObject
*self
, PyObject
*newvalue
, void *closure
)
156 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
159 BPPY_SET_REQUIRE_VALID (self_bp
);
161 if (newvalue
== NULL
)
163 PyErr_SetString (PyExc_TypeError
,
164 _("Cannot delete `silent' attribute."));
167 else if (! PyBool_Check (newvalue
))
169 PyErr_SetString (PyExc_TypeError
,
170 _("The value of `silent' must be a boolean."));
174 cmp
= PyObject_IsTrue (newvalue
);
178 breakpoint_set_silent (self_bp
->bp
, cmp
);
183 /* Python function to set the thread of a breakpoint. */
185 bppy_set_thread (PyObject
*self
, PyObject
*newvalue
, void *closure
)
187 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
190 BPPY_SET_REQUIRE_VALID (self_bp
);
192 if (newvalue
== NULL
)
194 PyErr_SetString (PyExc_TypeError
,
195 _("Cannot delete `thread' attribute."));
198 else if (PyInt_Check (newvalue
))
200 if (! gdb_py_int_as_long (newvalue
, &id
))
203 if (! valid_thread_id (id
))
205 PyErr_SetString (PyExc_RuntimeError
,
206 _("Invalid thread ID."));
210 else if (newvalue
== Py_None
)
214 PyErr_SetString (PyExc_TypeError
,
215 _("The value of `thread' must be an integer or None."));
219 breakpoint_set_thread (self_bp
->bp
, id
);
224 /* Python function to set the (Ada) task of a breakpoint. */
226 bppy_set_task (PyObject
*self
, PyObject
*newvalue
, void *closure
)
228 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
231 volatile struct gdb_exception except
;
233 BPPY_SET_REQUIRE_VALID (self_bp
);
235 if (newvalue
== NULL
)
237 PyErr_SetString (PyExc_TypeError
,
238 _("Cannot delete `task' attribute."));
241 else if (PyInt_Check (newvalue
))
243 if (! gdb_py_int_as_long (newvalue
, &id
))
246 TRY_CATCH (except
, RETURN_MASK_ALL
)
248 valid_id
= valid_task_id (id
);
250 GDB_PY_SET_HANDLE_EXCEPTION (except
);
254 PyErr_SetString (PyExc_RuntimeError
,
255 _("Invalid task ID."));
259 else if (newvalue
== Py_None
)
263 PyErr_SetString (PyExc_TypeError
,
264 _("The value of `task' must be an integer or None."));
268 breakpoint_set_task (self_bp
->bp
, id
);
273 /* Python function which deletes the underlying GDB breakpoint. This
274 triggers the breakpoint_deleted observer which will call
275 gdbpy_breakpoint_deleted; that function cleans up the Python
279 bppy_delete_breakpoint (PyObject
*self
, PyObject
*args
)
281 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
282 volatile struct gdb_exception except
;
284 BPPY_REQUIRE_VALID (self_bp
);
286 TRY_CATCH (except
, RETURN_MASK_ALL
)
288 delete_breakpoint (self_bp
->bp
);
290 GDB_PY_HANDLE_EXCEPTION (except
);
296 /* Python function to set the ignore count of a breakpoint. */
298 bppy_set_ignore_count (PyObject
*self
, PyObject
*newvalue
, void *closure
)
300 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
302 volatile struct gdb_exception except
;
304 BPPY_SET_REQUIRE_VALID (self_bp
);
306 if (newvalue
== NULL
)
308 PyErr_SetString (PyExc_TypeError
,
309 _("Cannot delete `ignore_count' attribute."));
312 else if (! PyInt_Check (newvalue
))
314 PyErr_SetString (PyExc_TypeError
,
315 _("The value of `ignore_count' must be an integer."));
319 if (! gdb_py_int_as_long (newvalue
, &value
))
325 TRY_CATCH (except
, RETURN_MASK_ALL
)
327 set_ignore_count (self_bp
->number
, (int) value
, 0);
329 GDB_PY_SET_HANDLE_EXCEPTION (except
);
334 /* Python function to set the hit count of a breakpoint. */
336 bppy_set_hit_count (PyObject
*self
, PyObject
*newvalue
, void *closure
)
338 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
340 BPPY_SET_REQUIRE_VALID (self_bp
);
342 if (newvalue
== NULL
)
344 PyErr_SetString (PyExc_TypeError
,
345 _("Cannot delete `hit_count' attribute."));
352 if (! gdb_py_int_as_long (newvalue
, &value
))
357 PyErr_SetString (PyExc_AttributeError
,
358 _("The value of `hit_count' must be zero."));
363 self_bp
->bp
->hit_count
= 0;
368 /* Python function to get the location of a breakpoint. */
370 bppy_get_location (PyObject
*self
, void *closure
)
373 breakpoint_object
*obj
= (breakpoint_object
*) self
;
375 BPPY_REQUIRE_VALID (obj
);
377 if (obj
->bp
->type
!= bp_breakpoint
)
380 str
= obj
->bp
->addr_string
;
384 return PyString_Decode (str
, strlen (str
), host_charset (), NULL
);
387 /* Python function to get the breakpoint expression. */
389 bppy_get_expression (PyObject
*self
, void *closure
)
392 breakpoint_object
*obj
= (breakpoint_object
*) self
;
393 struct watchpoint
*wp
;
395 BPPY_REQUIRE_VALID (obj
);
397 if (!is_watchpoint (obj
->bp
))
400 wp
= (struct watchpoint
*) obj
->bp
;
402 str
= wp
->exp_string
;
406 return PyString_Decode (str
, strlen (str
), host_charset (), NULL
);
409 /* Python function to get the condition expression of a breakpoint. */
411 bppy_get_condition (PyObject
*self
, void *closure
)
414 breakpoint_object
*obj
= (breakpoint_object
*) self
;
416 BPPY_REQUIRE_VALID (obj
);
418 str
= obj
->bp
->cond_string
;
422 return PyString_Decode (str
, strlen (str
), host_charset (), NULL
);
425 /* Returns 0 on success. Returns -1 on error, with a python exception set.
429 bppy_set_condition (PyObject
*self
, PyObject
*newvalue
, void *closure
)
432 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
433 volatile struct gdb_exception except
;
435 BPPY_SET_REQUIRE_VALID (self_bp
);
437 if (newvalue
== NULL
)
439 PyErr_SetString (PyExc_TypeError
,
440 _("Cannot delete `condition' attribute."));
443 else if (newvalue
== Py_None
)
447 exp
= python_string_to_host_string (newvalue
);
452 TRY_CATCH (except
, RETURN_MASK_ALL
)
454 set_breakpoint_condition (self_bp
->bp
, exp
, 0);
457 if (newvalue
!= Py_None
)
460 GDB_PY_SET_HANDLE_EXCEPTION (except
);
465 /* Python function to get the commands attached to a breakpoint. */
467 bppy_get_commands (PyObject
*self
, void *closure
)
469 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
470 struct breakpoint
*bp
= self_bp
->bp
;
472 volatile struct gdb_exception except
;
473 struct ui_file
*string_file
;
474 struct cleanup
*chain
;
478 BPPY_REQUIRE_VALID (self_bp
);
480 if (! self_bp
->bp
->commands
)
483 string_file
= mem_fileopen ();
484 chain
= make_cleanup_ui_file_delete (string_file
);
486 ui_out_redirect (current_uiout
, string_file
);
487 TRY_CATCH (except
, RETURN_MASK_ALL
)
489 print_command_lines (current_uiout
, breakpoint_commands (bp
), 0);
491 ui_out_redirect (current_uiout
, NULL
);
492 GDB_PY_HANDLE_EXCEPTION (except
);
494 cmdstr
= ui_file_xstrdup (string_file
, &length
);
495 make_cleanup (xfree
, cmdstr
);
496 result
= PyString_Decode (cmdstr
, strlen (cmdstr
), host_charset (), NULL
);
501 /* Python function to get the breakpoint type. */
503 bppy_get_type (PyObject
*self
, void *closure
)
505 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
507 BPPY_REQUIRE_VALID (self_bp
);
509 return PyInt_FromLong (self_bp
->bp
->type
);
512 /* Python function to get the visibility of the breakpoint. */
515 bppy_get_visibility (PyObject
*self
, void *closure
)
517 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
519 BPPY_REQUIRE_VALID (self_bp
);
521 if (self_bp
->bp
->number
< 0)
527 /* Python function to get the breakpoint's number. */
529 bppy_get_number (PyObject
*self
, void *closure
)
531 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
533 BPPY_REQUIRE_VALID (self_bp
);
535 return PyInt_FromLong (self_bp
->number
);
538 /* Python function to get the breakpoint's thread ID. */
540 bppy_get_thread (PyObject
*self
, void *closure
)
542 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
544 BPPY_REQUIRE_VALID (self_bp
);
546 if (self_bp
->bp
->thread
== -1)
549 return PyInt_FromLong (self_bp
->bp
->thread
);
552 /* Python function to get the breakpoint's task ID (in Ada). */
554 bppy_get_task (PyObject
*self
, void *closure
)
556 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
558 BPPY_REQUIRE_VALID (self_bp
);
560 if (self_bp
->bp
->task
== 0)
563 return PyInt_FromLong (self_bp
->bp
->task
);
566 /* Python function to get the breakpoint's hit count. */
568 bppy_get_hit_count (PyObject
*self
, void *closure
)
570 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
572 BPPY_REQUIRE_VALID (self_bp
);
574 return PyInt_FromLong (self_bp
->bp
->hit_count
);
577 /* Python function to get the breakpoint's ignore count. */
579 bppy_get_ignore_count (PyObject
*self
, void *closure
)
581 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
583 BPPY_REQUIRE_VALID (self_bp
);
585 return PyInt_FromLong (self_bp
->bp
->ignore_count
);
588 /* Python function to create a new breakpoint. */
590 bppy_init (PyObject
*self
, PyObject
*args
, PyObject
*kwargs
)
592 static char *keywords
[] = { "spec", "type", "wp_class", "internal", NULL
};
594 int type
= bp_breakpoint
;
595 int access_type
= hw_write
;
596 PyObject
*internal
= NULL
;
598 volatile struct gdb_exception except
;
600 if (! PyArg_ParseTupleAndKeywords (args
, kwargs
, "s|iiO", keywords
,
601 &spec
, &type
, &access_type
, &internal
))
606 internal_bp
= PyObject_IsTrue (internal
);
607 if (internal_bp
== -1)
611 bppy_pending_object
= (breakpoint_object
*) self
;
612 bppy_pending_object
->number
= -1;
613 bppy_pending_object
->bp
= NULL
;
615 TRY_CATCH (except
, RETURN_MASK_ALL
)
617 char *copy
= xstrdup (spec
);
618 struct cleanup
*cleanup
= make_cleanup (xfree
, copy
);
624 create_breakpoint (python_gdbarch
,
625 copy
, NULL
, -1, NULL
,
630 &bkpt_breakpoint_ops
,
631 0, 1, internal_bp
, 0);
636 if (access_type
== hw_write
)
637 watch_command_wrapper (copy
, 0, internal_bp
);
638 else if (access_type
== hw_access
)
639 awatch_command_wrapper (copy
, 0, internal_bp
);
640 else if (access_type
== hw_read
)
641 rwatch_command_wrapper (copy
, 0, internal_bp
);
643 error(_("Cannot understand watchpoint access type."));
647 error(_("Do not understand breakpoint type to set."));
650 do_cleanups (cleanup
);
652 if (except
.reason
< 0)
654 PyErr_Format (except
.reason
== RETURN_QUIT
655 ? PyExc_KeyboardInterrupt
: PyExc_RuntimeError
,
656 "%s", except
.message
);
660 BPPY_SET_REQUIRE_VALID ((breakpoint_object
*) self
);
667 build_bp_list (struct breakpoint
*b
, void *arg
)
669 PyObject
*list
= arg
;
670 PyObject
*bp
= (PyObject
*) b
->py_bp_object
;
673 /* Not all breakpoints will have a companion Python object.
674 Only breakpoints that were created via bppy_new, or
675 breakpoints that were created externally and are tracked by
676 the Python Scripting API. */
678 iserr
= PyList_Append (list
, bp
);
686 /* Static function to return a tuple holding all breakpoints. */
689 gdbpy_breakpoints (PyObject
*self
, PyObject
*args
)
691 PyObject
*list
, *tuple
;
696 list
= PyList_New (0);
700 /* If iteratre_over_breakpoints returns non NULL it signals an error
701 condition. In that case abandon building the list and return
703 if (iterate_over_breakpoints (build_bp_list
, list
) != NULL
)
709 tuple
= PyList_AsTuple (list
);
715 /* Call the "stop" method (if implemented) in the breakpoint
716 class. If the method returns True, the inferior will be
717 stopped at the breakpoint. Otherwise the inferior will be
718 allowed to continue. */
721 gdbpy_should_stop (struct breakpoint_object
*bp_obj
)
725 PyObject
*py_bp
= (PyObject
*) bp_obj
;
726 struct breakpoint
*b
= bp_obj
->bp
;
727 struct gdbarch
*garch
= b
->gdbarch
? b
->gdbarch
: get_current_arch ();
728 struct cleanup
*cleanup
= ensure_python_env (garch
, current_language
);
730 if (bp_obj
->is_finish_bp
)
731 bpfinishpy_pre_stop_hook (bp_obj
);
733 if (PyObject_HasAttrString (py_bp
, stop_func
))
735 PyObject
*result
= PyObject_CallMethod (py_bp
, stop_func
, NULL
);
739 int evaluate
= PyObject_IsTrue (result
);
742 gdbpy_print_stack ();
744 /* If the "stop" function returns False that means
745 the Python breakpoint wants GDB to continue. */
752 gdbpy_print_stack ();
755 if (bp_obj
->is_finish_bp
)
756 bpfinishpy_post_stop_hook (bp_obj
);
758 do_cleanups (cleanup
);
763 /* Checks if the "stop" method exists in this breakpoint.
764 Used by condition_command to ensure mutual exclusion of breakpoint
768 gdbpy_breakpoint_has_py_cond (struct breakpoint_object
*bp_obj
)
771 PyObject
*py_bp
= (PyObject
*) bp_obj
;
772 struct gdbarch
*garch
= bp_obj
->bp
->gdbarch
? bp_obj
->bp
->gdbarch
:
774 struct cleanup
*cleanup
= ensure_python_env (garch
, current_language
);
777 has_func
= PyObject_HasAttrString (py_bp
, stop_func
);
779 do_cleanups (cleanup
);
786 /* Event callback functions. */
788 /* Callback that is used when a breakpoint is created. This function
789 will create a new Python breakpoint object. */
791 gdbpy_breakpoint_created (struct breakpoint
*bp
)
793 breakpoint_object
*newbp
;
794 PyGILState_STATE state
;
796 if (bp
->number
< 0 && bppy_pending_object
== NULL
)
799 if (bp
->type
!= bp_breakpoint
800 && bp
->type
!= bp_watchpoint
801 && bp
->type
!= bp_hardware_watchpoint
802 && bp
->type
!= bp_read_watchpoint
803 && bp
->type
!= bp_access_watchpoint
)
806 state
= PyGILState_Ensure ();
808 if (bppy_pending_object
)
810 newbp
= bppy_pending_object
;
811 bppy_pending_object
= NULL
;
814 newbp
= PyObject_New (breakpoint_object
, &breakpoint_object_type
);
817 newbp
->number
= bp
->number
;
819 newbp
->bp
->py_bp_object
= newbp
;
820 newbp
->is_finish_bp
= 0;
826 PyErr_SetString (PyExc_RuntimeError
,
827 _("Error while creating breakpoint from GDB."));
828 gdbpy_print_stack ();
831 PyGILState_Release (state
);
834 /* Callback that is used when a breakpoint is deleted. This will
835 invalidate the corresponding Python object. */
837 gdbpy_breakpoint_deleted (struct breakpoint
*b
)
840 PyGILState_STATE state
;
841 struct breakpoint
*bp
= NULL
;
842 breakpoint_object
*bp_obj
;
844 state
= PyGILState_Ensure ();
845 bp
= get_breakpoint (num
);
848 bp_obj
= bp
->py_bp_object
;
856 PyGILState_Release (state
);
861 /* Initialize the Python breakpoint code. */
863 gdbpy_initialize_breakpoints (void)
867 breakpoint_object_type
.tp_new
= PyType_GenericNew
;
868 if (PyType_Ready (&breakpoint_object_type
) < 0)
871 Py_INCREF (&breakpoint_object_type
);
872 if (PyModule_AddObject (gdb_module
, "Breakpoint",
873 (PyObject
*) &breakpoint_object_type
) < 0)
876 observer_attach_breakpoint_created (gdbpy_breakpoint_created
);
877 observer_attach_breakpoint_deleted (gdbpy_breakpoint_deleted
);
879 /* Add breakpoint types constants. */
880 for (i
= 0; pybp_codes
[i
].name
; ++i
)
882 if (PyModule_AddIntConstant (gdb_module
,
883 /* Cast needed for Python 2.4. */
884 (char *) pybp_codes
[i
].name
,
885 pybp_codes
[i
].code
) < 0)
889 /* Add watchpoint types constants. */
890 for (i
= 0; pybp_watch_types
[i
].name
; ++i
)
892 if (PyModule_AddIntConstant (gdb_module
,
893 /* Cast needed for Python 2.4. */
894 (char *) pybp_watch_types
[i
].name
,
895 pybp_watch_types
[i
].code
) < 0)
904 /* Helper function that overrides this Python object's
905 PyObject_GenericSetAttr to allow extra validation of the attribute
909 local_setattro (PyObject
*self
, PyObject
*name
, PyObject
*v
)
911 breakpoint_object
*obj
= (breakpoint_object
*) self
;
912 char *attr
= python_string_to_host_string (name
);
917 /* If the attribute trying to be set is the "stop" method,
918 but we already have a condition set in the CLI, disallow this
920 if (strcmp (attr
, stop_func
) == 0 && obj
->bp
->cond_string
)
923 PyErr_SetString (PyExc_RuntimeError
,
924 _("Cannot set 'stop' method. There is an " \
925 "existing GDB condition attached to the " \
932 return PyObject_GenericSetAttr ((PyObject
*)self
, name
, v
);
935 static PyGetSetDef breakpoint_object_getset
[] = {
936 { "enabled", bppy_get_enabled
, bppy_set_enabled
,
937 "Boolean telling whether the breakpoint is enabled.", NULL
},
938 { "silent", bppy_get_silent
, bppy_set_silent
,
939 "Boolean telling whether the breakpoint is silent.", NULL
},
940 { "thread", bppy_get_thread
, bppy_set_thread
,
941 "Thread ID for the breakpoint.\n\
942 If the value is a thread ID (integer), then this is a thread-specific breakpoint.\n\
943 If the value is None, then this breakpoint is not thread-specific.\n\
944 No other type of value can be used.", NULL
},
945 { "task", bppy_get_task
, bppy_set_task
,
946 "Thread ID for the breakpoint.\n\
947 If the value is a task ID (integer), then this is an Ada task-specific breakpoint.\n\
948 If the value is None, then this breakpoint is not task-specific.\n\
949 No other type of value can be used.", NULL
},
950 { "ignore_count", bppy_get_ignore_count
, bppy_set_ignore_count
,
951 "Number of times this breakpoint should be automatically continued.",
953 { "number", bppy_get_number
, NULL
,
954 "Breakpoint's number assigned by GDB.", NULL
},
955 { "hit_count", bppy_get_hit_count
, bppy_set_hit_count
,
956 "Number of times the breakpoint has been hit.\n\
957 Can be set to zero to clear the count. No other value is valid\n\
958 when setting this property.", NULL
},
959 { "location", bppy_get_location
, NULL
,
960 "Location of the breakpoint, as specified by the user.", NULL
},
961 { "expression", bppy_get_expression
, NULL
,
962 "Expression of the breakpoint, as specified by the user.", NULL
},
963 { "condition", bppy_get_condition
, bppy_set_condition
,
964 "Condition of the breakpoint, as specified by the user,\
965 or None if no condition set."},
966 { "commands", bppy_get_commands
, NULL
,
967 "Commands of the breakpoint, as specified by the user."},
968 { "type", bppy_get_type
, NULL
,
969 "Type of breakpoint."},
970 { "visible", bppy_get_visibility
, NULL
,
971 "Whether the breakpoint is visible to the user."},
972 { NULL
} /* Sentinel. */
975 static PyMethodDef breakpoint_object_methods
[] =
977 { "is_valid", bppy_is_valid
, METH_NOARGS
,
978 "Return true if this breakpoint is valid, false if not." },
979 { "delete", bppy_delete_breakpoint
, METH_NOARGS
,
980 "Delete the underlying GDB breakpoint." },
981 { NULL
} /* Sentinel. */
984 PyTypeObject breakpoint_object_type
=
986 PyVarObject_HEAD_INIT (NULL
, 0)
987 "gdb.Breakpoint", /*tp_name*/
988 sizeof (breakpoint_object
), /*tp_basicsize*/
997 0, /*tp_as_sequence*/
1003 (setattrofunc
)local_setattro
, /*tp_setattro */
1005 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
1006 "GDB breakpoint object", /* tp_doc */
1007 0, /* tp_traverse */
1009 0, /* tp_richcompare */
1010 0, /* tp_weaklistoffset */
1012 0, /* tp_iternext */
1013 breakpoint_object_methods
, /* tp_methods */
1015 breakpoint_object_getset
, /* tp_getset */
1018 0, /* tp_descr_get */
1019 0, /* tp_descr_set */
1020 0, /* tp_dictoffset */
1021 bppy_init
, /* tp_init */