1 /* Python interface to breakpoints
3 Copyright (C) 2008, 2009, 2010, 2011 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"
25 #include "breakpoint.h"
27 #include "gdbthread.h"
29 #include "cli/cli-script.h"
31 #include "arch-utils.h"
34 static PyTypeObject breakpoint_object_type
;
36 /* Number of live breakpoints. */
39 /* Variables used to pass information between the Breakpoint
40 constructor and the breakpoint-created hook function. */
41 static breakpoint_object
*bppy_pending_object
;
43 /* Function that is called when a Python condition is evaluated. */
44 static char * const stop_func
= "stop";
46 struct breakpoint_object
50 /* The breakpoint number according to gdb. */
53 /* The gdb breakpoint object, or NULL if the breakpoint has been
55 struct breakpoint
*bp
;
58 /* Require that BREAKPOINT be a valid breakpoint ID; throw a Python
59 exception if it is invalid. */
60 #define BPPY_REQUIRE_VALID(Breakpoint) \
62 if ((Breakpoint)->bp == NULL) \
63 return PyErr_Format (PyExc_RuntimeError, \
64 _("Breakpoint %d is invalid."), \
65 (Breakpoint)->number); \
68 /* Require that BREAKPOINT be a valid breakpoint ID; throw a Python
69 exception if it is invalid. This macro is for use in setter functions. */
70 #define BPPY_SET_REQUIRE_VALID(Breakpoint) \
72 if ((Breakpoint)->bp == NULL) \
74 PyErr_Format (PyExc_RuntimeError, _("Breakpoint %d is invalid."), \
75 (Breakpoint)->number); \
80 /* This is used to initialize various gdb.bp_* constants. */
89 /* Entries related to the type of user set breakpoints. */
90 static struct pybp_code pybp_codes
[] =
92 { "BP_NONE", bp_none
},
93 { "BP_BREAKPOINT", bp_breakpoint
},
94 { "BP_WATCHPOINT", bp_watchpoint
},
95 { "BP_HARDWARE_WATCHPOINT", bp_hardware_watchpoint
},
96 { "BP_READ_WATCHPOINT", bp_read_watchpoint
},
97 { "BP_ACCESS_WATCHPOINT", bp_access_watchpoint
},
98 {NULL
} /* Sentinel. */
101 /* Entries related to the type of watchpoint. */
102 static struct pybp_code pybp_watch_types
[] =
104 { "WP_READ", hw_read
},
105 { "WP_WRITE", hw_write
},
106 { "WP_ACCESS", hw_access
},
107 {NULL
} /* Sentinel. */
110 /* Python function which checks the validity of a breakpoint object. */
112 bppy_is_valid (PyObject
*self
, PyObject
*args
)
114 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
121 /* Python function to test whether or not the breakpoint is enabled. */
123 bppy_get_enabled (PyObject
*self
, void *closure
)
125 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
127 BPPY_REQUIRE_VALID (self_bp
);
130 if (self_bp
->bp
->enable_state
== bp_enabled
)
135 /* Python function to test whether or not the breakpoint is silent. */
137 bppy_get_silent (PyObject
*self
, void *closure
)
139 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
141 BPPY_REQUIRE_VALID (self_bp
);
142 if (self_bp
->bp
->silent
)
147 /* Python function to set the enabled state of a breakpoint. */
149 bppy_set_enabled (PyObject
*self
, PyObject
*newvalue
, void *closure
)
151 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
154 BPPY_SET_REQUIRE_VALID (self_bp
);
156 if (newvalue
== NULL
)
158 PyErr_SetString (PyExc_TypeError
,
159 _("Cannot delete `enabled' attribute."));
163 else if (! PyBool_Check (newvalue
))
165 PyErr_SetString (PyExc_TypeError
,
166 _("The value of `enabled' must be a boolean."));
170 cmp
= PyObject_IsTrue (newvalue
);
174 enable_breakpoint (self_bp
->bp
);
176 disable_breakpoint (self_bp
->bp
);
180 /* Python function to set the 'silent' state of a breakpoint. */
182 bppy_set_silent (PyObject
*self
, PyObject
*newvalue
, void *closure
)
184 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
187 BPPY_SET_REQUIRE_VALID (self_bp
);
189 if (newvalue
== NULL
)
191 PyErr_SetString (PyExc_TypeError
,
192 _("Cannot delete `silent' attribute."));
195 else if (! PyBool_Check (newvalue
))
197 PyErr_SetString (PyExc_TypeError
,
198 _("The value of `silent' must be a boolean."));
202 cmp
= PyObject_IsTrue (newvalue
);
206 breakpoint_set_silent (self_bp
->bp
, cmp
);
211 /* Python function to set the thread of a breakpoint. */
213 bppy_set_thread (PyObject
*self
, PyObject
*newvalue
, void *closure
)
215 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
218 BPPY_SET_REQUIRE_VALID (self_bp
);
220 if (newvalue
== NULL
)
222 PyErr_SetString (PyExc_TypeError
,
223 _("Cannot delete `thread' attribute."));
226 else if (PyInt_Check (newvalue
))
228 if (! gdb_py_int_as_long (newvalue
, &id
))
231 if (! valid_thread_id (id
))
233 PyErr_SetString (PyExc_RuntimeError
,
234 _("Invalid thread ID."));
238 else if (newvalue
== Py_None
)
242 PyErr_SetString (PyExc_TypeError
,
243 _("The value of `thread' must be an integer or None."));
247 breakpoint_set_thread (self_bp
->bp
, id
);
252 /* Python function to set the (Ada) task of a breakpoint. */
254 bppy_set_task (PyObject
*self
, PyObject
*newvalue
, void *closure
)
256 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
259 BPPY_SET_REQUIRE_VALID (self_bp
);
261 if (newvalue
== NULL
)
263 PyErr_SetString (PyExc_TypeError
,
264 _("Cannot delete `task' attribute."));
267 else if (PyInt_Check (newvalue
))
269 if (! gdb_py_int_as_long (newvalue
, &id
))
272 if (! valid_task_id (id
))
274 PyErr_SetString (PyExc_RuntimeError
,
275 _("Invalid task ID."));
279 else if (newvalue
== Py_None
)
283 PyErr_SetString (PyExc_TypeError
,
284 _("The value of `task' must be an integer or None."));
288 breakpoint_set_task (self_bp
->bp
, id
);
293 /* Python function which deletes the underlying GDB breakpoint. This
294 triggers the breakpoint_deleted observer which will call
295 gdbpy_breakpoint_deleted; that function cleans up the Python
299 bppy_delete_breakpoint (PyObject
*self
, PyObject
*args
)
301 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
303 BPPY_REQUIRE_VALID (self_bp
);
305 delete_breakpoint (self_bp
->bp
);
311 /* Python function to set the ignore count of a breakpoint. */
313 bppy_set_ignore_count (PyObject
*self
, PyObject
*newvalue
, void *closure
)
315 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
318 BPPY_SET_REQUIRE_VALID (self_bp
);
320 if (newvalue
== NULL
)
322 PyErr_SetString (PyExc_TypeError
,
323 _("Cannot delete `ignore_count' attribute."));
326 else if (! PyInt_Check (newvalue
))
328 PyErr_SetString (PyExc_TypeError
,
329 _("The value of `ignore_count' must be an integer."));
333 if (! gdb_py_int_as_long (newvalue
, &value
))
338 set_ignore_count (self_bp
->number
, (int) value
, 0);
343 /* Python function to set the hit count of a breakpoint. */
345 bppy_set_hit_count (PyObject
*self
, PyObject
*newvalue
, void *closure
)
347 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
349 BPPY_SET_REQUIRE_VALID (self_bp
);
351 if (newvalue
== NULL
)
353 PyErr_SetString (PyExc_TypeError
,
354 _("Cannot delete `hit_count' attribute."));
361 if (! gdb_py_int_as_long (newvalue
, &value
))
366 PyErr_SetString (PyExc_AttributeError
,
367 _("The value of `hit_count' must be zero."));
372 self_bp
->bp
->hit_count
= 0;
377 /* Python function to get the location of a breakpoint. */
379 bppy_get_location (PyObject
*self
, void *closure
)
382 breakpoint_object
*obj
= (breakpoint_object
*) self
;
384 BPPY_REQUIRE_VALID (obj
);
386 if (obj
->bp
->type
!= bp_breakpoint
)
389 str
= obj
->bp
->addr_string
;
393 return PyString_Decode (str
, strlen (str
), host_charset (), NULL
);
396 /* Python function to get the breakpoint expression. */
398 bppy_get_expression (PyObject
*self
, void *closure
)
401 breakpoint_object
*obj
= (breakpoint_object
*) self
;
402 struct watchpoint
*wp
;
404 BPPY_REQUIRE_VALID (obj
);
406 if (!is_watchpoint (obj
->bp
))
409 wp
= (struct watchpoint
*) obj
->bp
;
411 str
= wp
->exp_string
;
415 return PyString_Decode (str
, strlen (str
), host_charset (), NULL
);
418 /* Python function to get the condition expression of a breakpoint. */
420 bppy_get_condition (PyObject
*self
, void *closure
)
423 breakpoint_object
*obj
= (breakpoint_object
*) self
;
425 BPPY_REQUIRE_VALID (obj
);
427 str
= obj
->bp
->cond_string
;
431 return PyString_Decode (str
, strlen (str
), host_charset (), NULL
);
434 /* Returns 0 on success. Returns -1 on error, with a python exception set.
438 bppy_set_condition (PyObject
*self
, PyObject
*newvalue
, void *closure
)
441 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
442 volatile struct gdb_exception except
;
444 BPPY_SET_REQUIRE_VALID (self_bp
);
446 if (newvalue
== NULL
)
448 PyErr_SetString (PyExc_TypeError
,
449 _("Cannot delete `condition' attribute."));
452 else if (newvalue
== Py_None
)
456 exp
= python_string_to_host_string (newvalue
);
461 TRY_CATCH (except
, RETURN_MASK_ALL
)
463 set_breakpoint_condition (self_bp
->bp
, exp
, 0);
466 if (newvalue
!= Py_None
)
469 GDB_PY_SET_HANDLE_EXCEPTION (except
);
474 /* Python function to get the commands attached to a breakpoint. */
476 bppy_get_commands (PyObject
*self
, void *closure
)
478 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
479 struct breakpoint
*bp
= self_bp
->bp
;
481 volatile struct gdb_exception except
;
482 struct ui_file
*string_file
;
483 struct cleanup
*chain
;
487 BPPY_REQUIRE_VALID (self_bp
);
489 if (! self_bp
->bp
->commands
)
492 string_file
= mem_fileopen ();
493 chain
= make_cleanup_ui_file_delete (string_file
);
495 ui_out_redirect (current_uiout
, string_file
);
496 TRY_CATCH (except
, RETURN_MASK_ALL
)
498 print_command_lines (current_uiout
, breakpoint_commands (bp
), 0);
500 ui_out_redirect (current_uiout
, NULL
);
501 GDB_PY_HANDLE_EXCEPTION (except
);
503 cmdstr
= ui_file_xstrdup (string_file
, &length
);
504 make_cleanup (xfree
, cmdstr
);
505 result
= PyString_Decode (cmdstr
, strlen (cmdstr
), host_charset (), NULL
);
510 /* Python function to get the breakpoint type. */
512 bppy_get_type (PyObject
*self
, void *closure
)
514 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
516 BPPY_REQUIRE_VALID (self_bp
);
518 return PyInt_FromLong (self_bp
->bp
->type
);
521 /* Python function to get the visibility of the breakpoint. */
524 bppy_get_visibility (PyObject
*self
, void *closure
)
526 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
528 BPPY_REQUIRE_VALID (self_bp
);
530 if (self_bp
->bp
->number
< 0)
536 /* Python function to get the breakpoint's number. */
538 bppy_get_number (PyObject
*self
, void *closure
)
540 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
542 BPPY_REQUIRE_VALID (self_bp
);
544 return PyInt_FromLong (self_bp
->number
);
547 /* Python function to get the breakpoint's thread ID. */
549 bppy_get_thread (PyObject
*self
, void *closure
)
551 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
553 BPPY_REQUIRE_VALID (self_bp
);
555 if (self_bp
->bp
->thread
== -1)
558 return PyInt_FromLong (self_bp
->bp
->thread
);
561 /* Python function to get the breakpoint's task ID (in Ada). */
563 bppy_get_task (PyObject
*self
, void *closure
)
565 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
567 BPPY_REQUIRE_VALID (self_bp
);
569 if (self_bp
->bp
->task
== 0)
572 return PyInt_FromLong (self_bp
->bp
->task
);
575 /* Python function to get the breakpoint's hit count. */
577 bppy_get_hit_count (PyObject
*self
, void *closure
)
579 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
581 BPPY_REQUIRE_VALID (self_bp
);
583 return PyInt_FromLong (self_bp
->bp
->hit_count
);
586 /* Python function to get the breakpoint's ignore count. */
588 bppy_get_ignore_count (PyObject
*self
, void *closure
)
590 breakpoint_object
*self_bp
= (breakpoint_object
*) self
;
592 BPPY_REQUIRE_VALID (self_bp
);
594 return PyInt_FromLong (self_bp
->bp
->ignore_count
);
597 /* Python function to create a new breakpoint. */
599 bppy_init (PyObject
*self
, PyObject
*args
, PyObject
*kwargs
)
601 static char *keywords
[] = { "spec", "type", "wp_class", "internal", NULL
};
603 int type
= bp_breakpoint
;
604 int access_type
= hw_write
;
605 PyObject
*internal
= NULL
;
607 volatile struct gdb_exception except
;
609 if (! PyArg_ParseTupleAndKeywords (args
, kwargs
, "s|iiO", keywords
,
610 &spec
, &type
, &access_type
, &internal
))
615 internal_bp
= PyObject_IsTrue (internal
);
616 if (internal_bp
== -1)
620 bppy_pending_object
= (breakpoint_object
*) self
;
621 bppy_pending_object
->number
= -1;
622 bppy_pending_object
->bp
= NULL
;
624 TRY_CATCH (except
, RETURN_MASK_ALL
)
626 char *copy
= xstrdup (spec
);
627 struct cleanup
*cleanup
= make_cleanup (xfree
, copy
);
633 create_breakpoint (python_gdbarch
,
639 &bkpt_breakpoint_ops
,
645 if (access_type
== hw_write
)
646 watch_command_wrapper (copy
, 0, internal_bp
);
647 else if (access_type
== hw_access
)
648 awatch_command_wrapper (copy
, 0, internal_bp
);
649 else if (access_type
== hw_read
)
650 rwatch_command_wrapper (copy
, 0, internal_bp
);
652 error(_("Cannot understand watchpoint access type."));
656 error(_("Do not understand breakpoint type to set."));
659 do_cleanups (cleanup
);
661 if (except
.reason
< 0)
663 PyErr_Format (except
.reason
== RETURN_QUIT
664 ? PyExc_KeyboardInterrupt
: PyExc_RuntimeError
,
665 "%s", except
.message
);
669 BPPY_SET_REQUIRE_VALID ((breakpoint_object
*) self
);
676 build_bp_list (struct breakpoint
*b
, void *arg
)
678 PyObject
*list
= arg
;
679 PyObject
*bp
= (PyObject
*) b
->py_bp_object
;
682 /* Not all breakpoints will have a companion Python object.
683 Only breakpoints that were created via bppy_new, or
684 breakpoints that were created externally and are tracked by
685 the Python Scripting API. */
687 iserr
= PyList_Append (list
, bp
);
695 /* Static function to return a tuple holding all breakpoints. */
698 gdbpy_breakpoints (PyObject
*self
, PyObject
*args
)
705 list
= PyList_New (0);
709 /* If iteratre_over_breakpoints returns non NULL it signals an error
710 condition. In that case abandon building the list and return
712 if (iterate_over_breakpoints (build_bp_list
, list
) != NULL
)
718 return PyList_AsTuple (list
);
721 /* Call the "stop" method (if implemented) in the breakpoint
722 class. If the method returns True, the inferior will be
723 stopped at the breakpoint. Otherwise the inferior will be
724 allowed to continue. */
727 gdbpy_should_stop (struct breakpoint_object
*bp_obj
)
731 PyObject
*py_bp
= (PyObject
*) bp_obj
;
732 struct breakpoint
*b
= bp_obj
->bp
;
733 struct gdbarch
*garch
= b
->gdbarch
? b
->gdbarch
: get_current_arch ();
734 struct cleanup
*cleanup
= ensure_python_env (garch
, current_language
);
736 if (PyObject_HasAttrString (py_bp
, stop_func
))
738 PyObject
*result
= PyObject_CallMethod (py_bp
, stop_func
, NULL
);
742 int evaluate
= PyObject_IsTrue (result
);
745 gdbpy_print_stack ();
747 /* If the "stop" function returns False that means
748 the Python breakpoint wants GDB to continue. */
755 gdbpy_print_stack ();
757 do_cleanups (cleanup
);
762 /* Checks if the "stop" method exists in this breakpoint.
763 Used by condition_command to ensure mutual exclusion of breakpoint
767 gdbpy_breakpoint_has_py_cond (struct breakpoint_object
*bp_obj
)
770 PyObject
*py_bp
= (PyObject
*) bp_obj
;
771 struct gdbarch
*garch
= bp_obj
->bp
->gdbarch
? bp_obj
->bp
->gdbarch
:
773 struct cleanup
*cleanup
= ensure_python_env (garch
, current_language
);
776 has_func
= PyObject_HasAttrString (py_bp
, stop_func
);
778 do_cleanups (cleanup
);
785 /* Event callback functions. */
787 /* Callback that is used when a breakpoint is created. This function
788 will create a new Python breakpoint object. */
790 gdbpy_breakpoint_created (struct breakpoint
*bp
)
792 breakpoint_object
*newbp
;
793 PyGILState_STATE state
;
795 if (bp
->number
< 0 && bppy_pending_object
== NULL
)
798 if (bp
->type
!= bp_breakpoint
799 && bp
->type
!= bp_watchpoint
800 && bp
->type
!= bp_hardware_watchpoint
801 && bp
->type
!= bp_read_watchpoint
802 && bp
->type
!= bp_access_watchpoint
)
805 state
= PyGILState_Ensure ();
807 if (bppy_pending_object
)
809 newbp
= bppy_pending_object
;
810 bppy_pending_object
= NULL
;
813 newbp
= PyObject_New (breakpoint_object
, &breakpoint_object_type
);
816 newbp
->number
= bp
->number
;
818 newbp
->bp
->py_bp_object
= newbp
;
824 PyErr_SetString (PyExc_RuntimeError
,
825 _("Error while creating breakpoint from GDB."));
826 gdbpy_print_stack ();
829 PyGILState_Release (state
);
832 /* Callback that is used when a breakpoint is deleted. This will
833 invalidate the corresponding Python object. */
835 gdbpy_breakpoint_deleted (struct breakpoint
*b
)
838 PyGILState_STATE state
;
839 struct breakpoint
*bp
= NULL
;
840 breakpoint_object
*bp_obj
;
842 state
= PyGILState_Ensure ();
843 bp
= get_breakpoint (num
);
846 bp_obj
= bp
->py_bp_object
;
854 PyGILState_Release (state
);
859 /* Initialize the Python breakpoint code. */
861 gdbpy_initialize_breakpoints (void)
865 breakpoint_object_type
.tp_new
= PyType_GenericNew
;
866 if (PyType_Ready (&breakpoint_object_type
) < 0)
869 Py_INCREF (&breakpoint_object_type
);
870 PyModule_AddObject (gdb_module
, "Breakpoint",
871 (PyObject
*) &breakpoint_object_type
);
873 observer_attach_breakpoint_created (gdbpy_breakpoint_created
);
874 observer_attach_breakpoint_deleted (gdbpy_breakpoint_deleted
);
876 /* Add breakpoint types constants. */
877 for (i
= 0; pybp_codes
[i
].name
; ++i
)
879 if (PyModule_AddIntConstant (gdb_module
,
880 /* Cast needed for Python 2.4. */
881 (char *) pybp_codes
[i
].name
,
882 pybp_codes
[i
].code
) < 0)
886 /* Add watchpoint types constants. */
887 for (i
= 0; pybp_watch_types
[i
].name
; ++i
)
889 if (PyModule_AddIntConstant (gdb_module
,
890 /* Cast needed for Python 2.4. */
891 (char *) pybp_watch_types
[i
].name
,
892 pybp_watch_types
[i
].code
) < 0)
900 /* Helper function that overrides this Python object's
901 PyObject_GenericSetAttr to allow extra validation of the attribute
905 local_setattro (PyObject
*self
, PyObject
*name
, PyObject
*v
)
907 breakpoint_object
*obj
= (breakpoint_object
*) self
;
908 char *attr
= python_string_to_host_string (name
);
913 /* If the attribute trying to be set is the "stop" method,
914 but we already have a condition set in the CLI, disallow this
916 if (strcmp (attr
, stop_func
) == 0 && obj
->bp
->cond_string
)
919 PyErr_SetString (PyExc_RuntimeError
,
920 _("Cannot set 'stop' method. There is an " \
921 "existing GDB condition attached to the " \
928 return PyObject_GenericSetAttr ((PyObject
*)self
, name
, v
);
931 static PyGetSetDef breakpoint_object_getset
[] = {
932 { "enabled", bppy_get_enabled
, bppy_set_enabled
,
933 "Boolean telling whether the breakpoint is enabled.", NULL
},
934 { "silent", bppy_get_silent
, bppy_set_silent
,
935 "Boolean telling whether the breakpoint is silent.", NULL
},
936 { "thread", bppy_get_thread
, bppy_set_thread
,
937 "Thread ID for the breakpoint.\n\
938 If the value is a thread ID (integer), then this is a thread-specific breakpoint.\n\
939 If the value is None, then this breakpoint is not thread-specific.\n\
940 No other type of value can be used.", NULL
},
941 { "task", bppy_get_task
, bppy_set_task
,
942 "Thread ID for the breakpoint.\n\
943 If the value is a task ID (integer), then this is an Ada task-specific breakpoint.\n\
944 If the value is None, then this breakpoint is not task-specific.\n\
945 No other type of value can be used.", NULL
},
946 { "ignore_count", bppy_get_ignore_count
, bppy_set_ignore_count
,
947 "Number of times this breakpoint should be automatically continued.",
949 { "number", bppy_get_number
, NULL
,
950 "Breakpoint's number assigned by GDB.", NULL
},
951 { "hit_count", bppy_get_hit_count
, bppy_set_hit_count
,
952 "Number of times the breakpoint has been hit.\n\
953 Can be set to zero to clear the count. No other value is valid\n\
954 when setting this property.", NULL
},
955 { "location", bppy_get_location
, NULL
,
956 "Location of the breakpoint, as specified by the user.", NULL
},
957 { "expression", bppy_get_expression
, NULL
,
958 "Expression of the breakpoint, as specified by the user.", NULL
},
959 { "condition", bppy_get_condition
, bppy_set_condition
,
960 "Condition of the breakpoint, as specified by the user,\
961 or None if no condition set."},
962 { "commands", bppy_get_commands
, NULL
,
963 "Commands of the breakpoint, as specified by the user."},
964 { "type", bppy_get_type
, NULL
,
965 "Type of breakpoint."},
966 { "visible", bppy_get_visibility
, NULL
,
967 "Whether the breakpoint is visible to the user."},
968 { NULL
} /* Sentinel. */
971 static PyMethodDef breakpoint_object_methods
[] =
973 { "is_valid", bppy_is_valid
, METH_NOARGS
,
974 "Return true if this breakpoint is valid, false if not." },
975 { "delete", bppy_delete_breakpoint
, METH_NOARGS
,
976 "Delete the underlying GDB breakpoint." },
977 { NULL
} /* Sentinel. */
980 static PyTypeObject breakpoint_object_type
=
982 PyObject_HEAD_INIT (NULL
)
984 "gdb.Breakpoint", /*tp_name*/
985 sizeof (breakpoint_object
), /*tp_basicsize*/
994 0, /*tp_as_sequence*/
1000 (setattrofunc
)local_setattro
, /*tp_setattro */
1002 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
1003 "GDB breakpoint object", /* tp_doc */
1004 0, /* tp_traverse */
1006 0, /* tp_richcompare */
1007 0, /* tp_weaklistoffset */
1009 0, /* tp_iternext */
1010 breakpoint_object_methods
, /* tp_methods */
1012 breakpoint_object_getset
, /* tp_getset */
1015 0, /* tp_descr_get */
1016 0, /* tp_descr_set */
1017 0, /* tp_dictoffset */
1018 bppy_init
, /* tp_init */