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
)
700 PyObject
*list
, *tuple
;
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 tuple
= PyList_AsTuple (list
);
724 /* Call the "stop" method (if implemented) in the breakpoint
725 class. If the method returns True, the inferior will be
726 stopped at the breakpoint. Otherwise the inferior will be
727 allowed to continue. */
730 gdbpy_should_stop (struct breakpoint_object
*bp_obj
)
734 PyObject
*py_bp
= (PyObject
*) bp_obj
;
735 struct breakpoint
*b
= bp_obj
->bp
;
736 struct gdbarch
*garch
= b
->gdbarch
? b
->gdbarch
: get_current_arch ();
737 struct cleanup
*cleanup
= ensure_python_env (garch
, current_language
);
739 if (PyObject_HasAttrString (py_bp
, stop_func
))
741 PyObject
*result
= PyObject_CallMethod (py_bp
, stop_func
, NULL
);
745 int evaluate
= PyObject_IsTrue (result
);
748 gdbpy_print_stack ();
750 /* If the "stop" function returns False that means
751 the Python breakpoint wants GDB to continue. */
758 gdbpy_print_stack ();
760 do_cleanups (cleanup
);
765 /* Checks if the "stop" method exists in this breakpoint.
766 Used by condition_command to ensure mutual exclusion of breakpoint
770 gdbpy_breakpoint_has_py_cond (struct breakpoint_object
*bp_obj
)
773 PyObject
*py_bp
= (PyObject
*) bp_obj
;
774 struct gdbarch
*garch
= bp_obj
->bp
->gdbarch
? bp_obj
->bp
->gdbarch
:
776 struct cleanup
*cleanup
= ensure_python_env (garch
, current_language
);
779 has_func
= PyObject_HasAttrString (py_bp
, stop_func
);
781 do_cleanups (cleanup
);
788 /* Event callback functions. */
790 /* Callback that is used when a breakpoint is created. This function
791 will create a new Python breakpoint object. */
793 gdbpy_breakpoint_created (struct breakpoint
*bp
)
795 breakpoint_object
*newbp
;
796 PyGILState_STATE state
;
798 if (bp
->number
< 0 && bppy_pending_object
== NULL
)
801 if (bp
->type
!= bp_breakpoint
802 && bp
->type
!= bp_watchpoint
803 && bp
->type
!= bp_hardware_watchpoint
804 && bp
->type
!= bp_read_watchpoint
805 && bp
->type
!= bp_access_watchpoint
)
808 state
= PyGILState_Ensure ();
810 if (bppy_pending_object
)
812 newbp
= bppy_pending_object
;
813 bppy_pending_object
= NULL
;
816 newbp
= PyObject_New (breakpoint_object
, &breakpoint_object_type
);
819 newbp
->number
= bp
->number
;
821 newbp
->bp
->py_bp_object
= newbp
;
827 PyErr_SetString (PyExc_RuntimeError
,
828 _("Error while creating breakpoint from GDB."));
829 gdbpy_print_stack ();
832 PyGILState_Release (state
);
835 /* Callback that is used when a breakpoint is deleted. This will
836 invalidate the corresponding Python object. */
838 gdbpy_breakpoint_deleted (struct breakpoint
*b
)
841 PyGILState_STATE state
;
842 struct breakpoint
*bp
= NULL
;
843 breakpoint_object
*bp_obj
;
845 state
= PyGILState_Ensure ();
846 bp
= get_breakpoint (num
);
849 bp_obj
= bp
->py_bp_object
;
857 PyGILState_Release (state
);
862 /* Initialize the Python breakpoint code. */
864 gdbpy_initialize_breakpoints (void)
868 breakpoint_object_type
.tp_new
= PyType_GenericNew
;
869 if (PyType_Ready (&breakpoint_object_type
) < 0)
872 Py_INCREF (&breakpoint_object_type
);
873 PyModule_AddObject (gdb_module
, "Breakpoint",
874 (PyObject
*) &breakpoint_object_type
);
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)
903 /* Helper function that overrides this Python object's
904 PyObject_GenericSetAttr to allow extra validation of the attribute
908 local_setattro (PyObject
*self
, PyObject
*name
, PyObject
*v
)
910 breakpoint_object
*obj
= (breakpoint_object
*) self
;
911 char *attr
= python_string_to_host_string (name
);
916 /* If the attribute trying to be set is the "stop" method,
917 but we already have a condition set in the CLI, disallow this
919 if (strcmp (attr
, stop_func
) == 0 && obj
->bp
->cond_string
)
922 PyErr_SetString (PyExc_RuntimeError
,
923 _("Cannot set 'stop' method. There is an " \
924 "existing GDB condition attached to the " \
931 return PyObject_GenericSetAttr ((PyObject
*)self
, name
, v
);
934 static PyGetSetDef breakpoint_object_getset
[] = {
935 { "enabled", bppy_get_enabled
, bppy_set_enabled
,
936 "Boolean telling whether the breakpoint is enabled.", NULL
},
937 { "silent", bppy_get_silent
, bppy_set_silent
,
938 "Boolean telling whether the breakpoint is silent.", NULL
},
939 { "thread", bppy_get_thread
, bppy_set_thread
,
940 "Thread ID for the breakpoint.\n\
941 If the value is a thread ID (integer), then this is a thread-specific breakpoint.\n\
942 If the value is None, then this breakpoint is not thread-specific.\n\
943 No other type of value can be used.", NULL
},
944 { "task", bppy_get_task
, bppy_set_task
,
945 "Thread ID for the breakpoint.\n\
946 If the value is a task ID (integer), then this is an Ada task-specific breakpoint.\n\
947 If the value is None, then this breakpoint is not task-specific.\n\
948 No other type of value can be used.", NULL
},
949 { "ignore_count", bppy_get_ignore_count
, bppy_set_ignore_count
,
950 "Number of times this breakpoint should be automatically continued.",
952 { "number", bppy_get_number
, NULL
,
953 "Breakpoint's number assigned by GDB.", NULL
},
954 { "hit_count", bppy_get_hit_count
, bppy_set_hit_count
,
955 "Number of times the breakpoint has been hit.\n\
956 Can be set to zero to clear the count. No other value is valid\n\
957 when setting this property.", NULL
},
958 { "location", bppy_get_location
, NULL
,
959 "Location of the breakpoint, as specified by the user.", NULL
},
960 { "expression", bppy_get_expression
, NULL
,
961 "Expression of the breakpoint, as specified by the user.", NULL
},
962 { "condition", bppy_get_condition
, bppy_set_condition
,
963 "Condition of the breakpoint, as specified by the user,\
964 or None if no condition set."},
965 { "commands", bppy_get_commands
, NULL
,
966 "Commands of the breakpoint, as specified by the user."},
967 { "type", bppy_get_type
, NULL
,
968 "Type of breakpoint."},
969 { "visible", bppy_get_visibility
, NULL
,
970 "Whether the breakpoint is visible to the user."},
971 { NULL
} /* Sentinel. */
974 static PyMethodDef breakpoint_object_methods
[] =
976 { "is_valid", bppy_is_valid
, METH_NOARGS
,
977 "Return true if this breakpoint is valid, false if not." },
978 { "delete", bppy_delete_breakpoint
, METH_NOARGS
,
979 "Delete the underlying GDB breakpoint." },
980 { NULL
} /* Sentinel. */
983 static PyTypeObject breakpoint_object_type
=
985 PyObject_HEAD_INIT (NULL
)
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 */