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
;
403 BPPY_REQUIRE_VALID (obj
);
405 if (obj
->bp
->type
!= bp_watchpoint
406 && obj
->bp
->type
!= bp_hardware_watchpoint
407 && obj
->bp
->type
!= bp_read_watchpoint
408 && obj
->bp
->type
!= bp_access_watchpoint
)
411 str
= obj
->bp
->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 (uiout
, string_file
);
496 TRY_CATCH (except
, RETURN_MASK_ALL
)
498 print_command_lines (uiout
, breakpoint_commands (bp
), 0);
500 ui_out_redirect (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
)
630 create_breakpoint (python_gdbarch
,
636 NULL
, 0, 1, internal_bp
);
641 if (access_type
== hw_write
)
642 watch_command_wrapper (spec
, 0, internal_bp
);
643 else if (access_type
== hw_access
)
644 awatch_command_wrapper (spec
, 0, internal_bp
);
645 else if (access_type
== hw_read
)
646 rwatch_command_wrapper (spec
, 0, internal_bp
);
648 error(_("Cannot understand watchpoint access type."));
652 error(_("Do not understand breakpoint type to set."));
655 if (except
.reason
< 0)
657 PyErr_Format (except
.reason
== RETURN_QUIT
658 ? PyExc_KeyboardInterrupt
: PyExc_RuntimeError
,
659 "%s", except
.message
);
663 BPPY_SET_REQUIRE_VALID ((breakpoint_object
*) self
);
670 build_bp_list (struct breakpoint
*b
, void *arg
)
672 PyObject
*list
= arg
;
673 PyObject
*bp
= (PyObject
*) b
->py_bp_object
;
676 /* Not all breakpoints will have a companion Python object.
677 Only breakpoints that were created via bppy_new, or
678 breakpoints that were created externally and are tracked by
679 the Python Scripting API. */
681 iserr
= PyList_Append (list
, bp
);
689 /* Static function to return a tuple holding all breakpoints. */
692 gdbpy_breakpoints (PyObject
*self
, PyObject
*args
)
699 list
= PyList_New (0);
703 /* If iteratre_over_breakpoints returns non NULL it signals an error
704 condition. In that case abandon building the list and return
706 if (iterate_over_breakpoints (build_bp_list
, list
) != NULL
)
712 return 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 (PyObject_HasAttrString (py_bp
, stop_func
))
732 PyObject
*result
= PyObject_CallMethod (py_bp
, stop_func
, NULL
);
736 int evaluate
= PyObject_IsTrue (result
);
739 gdbpy_print_stack ();
741 /* If the "stop" function returns False that means
742 the Python breakpoint wants GDB to continue. */
749 gdbpy_print_stack ();
751 do_cleanups (cleanup
);
756 /* Checks if the "stop" method exists in this breakpoint.
757 Used by condition_command to ensure mutual exclusion of breakpoint
761 gdbpy_breakpoint_has_py_cond (struct breakpoint_object
*bp_obj
)
764 PyObject
*py_bp
= (PyObject
*) bp_obj
;
765 struct gdbarch
*garch
= bp_obj
->bp
->gdbarch
? bp_obj
->bp
->gdbarch
:
767 struct cleanup
*cleanup
= ensure_python_env (garch
, current_language
);
772 has_func
= PyObject_HasAttrString (py_bp
, stop_func
);
773 do_cleanups (cleanup
);
780 /* Event callback functions. */
782 /* Callback that is used when a breakpoint is created. This function
783 will create a new Python breakpoint object. */
785 gdbpy_breakpoint_created (int num
)
787 breakpoint_object
*newbp
;
788 struct breakpoint
*bp
= NULL
;
789 PyGILState_STATE state
;
791 bp
= get_breakpoint (num
);
795 if (num
< 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
);
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 (int num
)
837 PyGILState_STATE state
;
838 struct breakpoint
*bp
= NULL
;
839 breakpoint_object
*bp_obj
;
841 state
= PyGILState_Ensure ();
842 bp
= get_breakpoint (num
);
846 bp_obj
= bp
->py_bp_object
;
853 PyGILState_Release (state
);
858 /* Initialize the Python breakpoint code. */
860 gdbpy_initialize_breakpoints (void)
864 if (PyType_Ready (&breakpoint_object_type
) < 0)
867 Py_INCREF (&breakpoint_object_type
);
868 PyModule_AddObject (gdb_module
, "Breakpoint",
869 (PyObject
*) &breakpoint_object_type
);
871 observer_attach_breakpoint_created (gdbpy_breakpoint_created
);
872 observer_attach_breakpoint_deleted (gdbpy_breakpoint_deleted
);
874 /* Add breakpoint types constants. */
875 for (i
= 0; pybp_codes
[i
].name
; ++i
)
877 if (PyModule_AddIntConstant (gdb_module
,
878 /* Cast needed for Python 2.4. */
879 (char *) pybp_codes
[i
].name
,
880 pybp_codes
[i
].code
) < 0)
884 /* Add watchpoint types constants. */
885 for (i
= 0; pybp_watch_types
[i
].name
; ++i
)
887 if (PyModule_AddIntConstant (gdb_module
,
888 /* Cast needed for Python 2.4. */
889 (char *) pybp_watch_types
[i
].name
,
890 pybp_watch_types
[i
].code
) < 0)
898 /* Helper function that overrides this Python object's
899 PyObject_GenericSetAttr to allow extra validation of the attribute
903 local_setattro (PyObject
*self
, PyObject
*name
, PyObject
*v
)
905 breakpoint_object
*obj
= (breakpoint_object
*) self
;
906 char *attr
= python_string_to_host_string (name
);
911 /* If the attribute trying to be set is the "stop" method,
912 but we already have a condition set in the CLI, disallow this
914 if (strcmp (attr
, stop_func
) == 0 && obj
->bp
->cond_string
)
917 PyErr_SetString (PyExc_RuntimeError
,
918 _("Cannot set 'stop' method. There is an " \
919 "existing GDB condition attached to the " \
926 return PyObject_GenericSetAttr ((PyObject
*)self
, name
, v
);
929 static PyGetSetDef breakpoint_object_getset
[] = {
930 { "enabled", bppy_get_enabled
, bppy_set_enabled
,
931 "Boolean telling whether the breakpoint is enabled.", NULL
},
932 { "silent", bppy_get_silent
, bppy_set_silent
,
933 "Boolean telling whether the breakpoint is silent.", NULL
},
934 { "thread", bppy_get_thread
, bppy_set_thread
,
935 "Thread ID for the breakpoint.\n\
936 If the value is a thread ID (integer), then this is a thread-specific breakpoint.\n\
937 If the value is None, then this breakpoint is not thread-specific.\n\
938 No other type of value can be used.", NULL
},
939 { "task", bppy_get_task
, bppy_set_task
,
940 "Thread ID for the breakpoint.\n\
941 If the value is a task ID (integer), then this is an Ada task-specific breakpoint.\n\
942 If the value is None, then this breakpoint is not task-specific.\n\
943 No other type of value can be used.", NULL
},
944 { "ignore_count", bppy_get_ignore_count
, bppy_set_ignore_count
,
945 "Number of times this breakpoint should be automatically continued.",
947 { "number", bppy_get_number
, NULL
,
948 "Breakpoint's number assigned by GDB.", NULL
},
949 { "hit_count", bppy_get_hit_count
, bppy_set_hit_count
,
950 "Number of times the breakpoint has been hit.\n\
951 Can be set to zero to clear the count. No other value is valid\n\
952 when setting this property.", NULL
},
953 { "location", bppy_get_location
, NULL
,
954 "Location of the breakpoint, as specified by the user.", NULL
},
955 { "expression", bppy_get_expression
, NULL
,
956 "Expression of the breakpoint, as specified by the user.", NULL
},
957 { "condition", bppy_get_condition
, bppy_set_condition
,
958 "Condition of the breakpoint, as specified by the user,\
959 or None if no condition set."},
960 { "commands", bppy_get_commands
, NULL
,
961 "Commands of the breakpoint, as specified by the user."},
962 { "type", bppy_get_type
, NULL
,
963 "Type of breakpoint."},
964 { "visible", bppy_get_visibility
, NULL
,
965 "Whether the breakpoint is visible to the user."},
966 { NULL
} /* Sentinel. */
969 static PyMethodDef breakpoint_object_methods
[] =
971 { "is_valid", bppy_is_valid
, METH_NOARGS
,
972 "Return true if this breakpoint is valid, false if not." },
973 { "delete", bppy_delete_breakpoint
, METH_NOARGS
,
974 "Delete the underlying GDB breakpoint." },
975 { NULL
} /* Sentinel. */
978 static PyTypeObject breakpoint_object_type
=
980 PyObject_HEAD_INIT (NULL
)
982 "gdb.Breakpoint", /*tp_name*/
983 sizeof (breakpoint_object
), /*tp_basicsize*/
992 0, /*tp_as_sequence*/
998 (setattrofunc
)local_setattro
, /*tp_setattro */
1000 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
1001 "GDB breakpoint object", /* tp_doc */
1002 0, /* tp_traverse */
1004 0, /* tp_richcompare */
1005 0, /* tp_weaklistoffset */
1007 0, /* tp_iternext */
1008 breakpoint_object_methods
, /* tp_methods */
1010 breakpoint_object_getset
, /* tp_getset */
1013 0, /* tp_descr_get */
1014 0, /* tp_descr_set */
1015 0, /* tp_dictoffset */
1016 bppy_init
, /* tp_init */
1018 PyType_GenericNew
/* tp_new */