1 /* Python interface to breakpoints
3 Copyright (C) 2008-2016 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 "python-internal.h"
25 #include "breakpoint.h"
27 #include "gdbthread.h"
29 #include "cli/cli-script.h"
31 #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 gdbpy_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 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
86 /* Python function to test whether or not the breakpoint is enabled. */
88 bppy_get_enabled (PyObject
*self
, void *closure
)
90 gdbpy_breakpoint_object
*self_bp
= (gdbpy_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 gdbpy_breakpoint_object
*self_bp
= (gdbpy_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 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
119 BPPY_SET_REQUIRE_VALID (self_bp
);
121 if (newvalue
== NULL
)
123 PyErr_SetString (PyExc_TypeError
,
124 _("Cannot delete `enabled' attribute."));
128 else if (! PyBool_Check (newvalue
))
130 PyErr_SetString (PyExc_TypeError
,
131 _("The value of `enabled' must be a boolean."));
135 cmp
= PyObject_IsTrue (newvalue
);
142 enable_breakpoint (self_bp
->bp
);
144 disable_breakpoint (self_bp
->bp
);
146 CATCH (except
, RETURN_MASK_ALL
)
148 GDB_PY_SET_HANDLE_EXCEPTION (except
);
155 /* Python function to set the 'silent' state of a breakpoint. */
157 bppy_set_silent (PyObject
*self
, PyObject
*newvalue
, void *closure
)
159 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
162 BPPY_SET_REQUIRE_VALID (self_bp
);
164 if (newvalue
== NULL
)
166 PyErr_SetString (PyExc_TypeError
,
167 _("Cannot delete `silent' attribute."));
170 else if (! PyBool_Check (newvalue
))
172 PyErr_SetString (PyExc_TypeError
,
173 _("The value of `silent' must be a boolean."));
177 cmp
= PyObject_IsTrue (newvalue
);
181 breakpoint_set_silent (self_bp
->bp
, cmp
);
186 /* Python function to set the thread of a breakpoint. */
188 bppy_set_thread (PyObject
*self
, PyObject
*newvalue
, void *closure
)
190 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
193 BPPY_SET_REQUIRE_VALID (self_bp
);
195 if (newvalue
== NULL
)
197 PyErr_SetString (PyExc_TypeError
,
198 _("Cannot delete `thread' attribute."));
201 else if (PyInt_Check (newvalue
))
203 if (! gdb_py_int_as_long (newvalue
, &id
))
206 if (!valid_global_thread_id (id
))
208 PyErr_SetString (PyExc_RuntimeError
,
209 _("Invalid thread ID."));
213 else if (newvalue
== Py_None
)
217 PyErr_SetString (PyExc_TypeError
,
218 _("The value of `thread' must be an integer or None."));
222 breakpoint_set_thread (self_bp
->bp
, id
);
227 /* Python function to set the (Ada) task of a breakpoint. */
229 bppy_set_task (PyObject
*self
, PyObject
*newvalue
, void *closure
)
231 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
235 BPPY_SET_REQUIRE_VALID (self_bp
);
237 if (newvalue
== NULL
)
239 PyErr_SetString (PyExc_TypeError
,
240 _("Cannot delete `task' attribute."));
243 else if (PyInt_Check (newvalue
))
245 if (! gdb_py_int_as_long (newvalue
, &id
))
250 valid_id
= valid_task_id (id
);
252 CATCH (except
, RETURN_MASK_ALL
)
254 GDB_PY_SET_HANDLE_EXCEPTION (except
);
260 PyErr_SetString (PyExc_RuntimeError
,
261 _("Invalid task ID."));
265 else if (newvalue
== Py_None
)
269 PyErr_SetString (PyExc_TypeError
,
270 _("The value of `task' must be an integer or None."));
274 breakpoint_set_task (self_bp
->bp
, id
);
279 /* Python function which deletes the underlying GDB breakpoint. This
280 triggers the breakpoint_deleted observer which will call
281 gdbpy_breakpoint_deleted; that function cleans up the Python
285 bppy_delete_breakpoint (PyObject
*self
, PyObject
*args
)
287 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
289 BPPY_REQUIRE_VALID (self_bp
);
293 delete_breakpoint (self_bp
->bp
);
295 CATCH (except
, RETURN_MASK_ALL
)
297 GDB_PY_HANDLE_EXCEPTION (except
);
305 /* Python function to set the ignore count of a breakpoint. */
307 bppy_set_ignore_count (PyObject
*self
, PyObject
*newvalue
, void *closure
)
309 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
312 BPPY_SET_REQUIRE_VALID (self_bp
);
314 if (newvalue
== NULL
)
316 PyErr_SetString (PyExc_TypeError
,
317 _("Cannot delete `ignore_count' attribute."));
320 else if (! PyInt_Check (newvalue
))
322 PyErr_SetString (PyExc_TypeError
,
323 _("The value of `ignore_count' must be an integer."));
327 if (! gdb_py_int_as_long (newvalue
, &value
))
335 set_ignore_count (self_bp
->number
, (int) value
, 0);
337 CATCH (except
, RETURN_MASK_ALL
)
339 GDB_PY_SET_HANDLE_EXCEPTION (except
);
346 /* Python function to set the hit count of a breakpoint. */
348 bppy_set_hit_count (PyObject
*self
, PyObject
*newvalue
, void *closure
)
350 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
352 BPPY_SET_REQUIRE_VALID (self_bp
);
354 if (newvalue
== NULL
)
356 PyErr_SetString (PyExc_TypeError
,
357 _("Cannot delete `hit_count' attribute."));
364 if (! gdb_py_int_as_long (newvalue
, &value
))
369 PyErr_SetString (PyExc_AttributeError
,
370 _("The value of `hit_count' must be zero."));
375 self_bp
->bp
->hit_count
= 0;
380 /* Python function to get the location of a breakpoint. */
382 bppy_get_location (PyObject
*self
, void *closure
)
385 gdbpy_breakpoint_object
*obj
= (gdbpy_breakpoint_object
*) self
;
387 BPPY_REQUIRE_VALID (obj
);
389 if (obj
->bp
->type
!= bp_breakpoint
)
392 str
= event_location_to_string (obj
->bp
->location
);
395 return host_string_to_python_string (str
);
398 /* Python function to get the breakpoint expression. */
400 bppy_get_expression (PyObject
*self
, void *closure
)
403 gdbpy_breakpoint_object
*obj
= (gdbpy_breakpoint_object
*) self
;
404 struct watchpoint
*wp
;
406 BPPY_REQUIRE_VALID (obj
);
408 if (!is_watchpoint (obj
->bp
))
411 wp
= (struct watchpoint
*) obj
->bp
;
413 str
= wp
->exp_string
;
417 return host_string_to_python_string (str
);
420 /* Python function to get the condition expression of a breakpoint. */
422 bppy_get_condition (PyObject
*self
, void *closure
)
425 gdbpy_breakpoint_object
*obj
= (gdbpy_breakpoint_object
*) self
;
427 BPPY_REQUIRE_VALID (obj
);
429 str
= obj
->bp
->cond_string
;
433 return host_string_to_python_string (str
);
436 /* Returns 0 on success. Returns -1 on error, with a python exception set.
440 bppy_set_condition (PyObject
*self
, PyObject
*newvalue
, void *closure
)
443 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
444 struct gdb_exception except
= exception_none
;
446 BPPY_SET_REQUIRE_VALID (self_bp
);
448 if (newvalue
== NULL
)
450 PyErr_SetString (PyExc_TypeError
,
451 _("Cannot delete `condition' attribute."));
454 else if (newvalue
== Py_None
)
458 exp
= python_string_to_host_string (newvalue
);
465 set_breakpoint_condition (self_bp
->bp
, exp
, 0);
467 CATCH (ex
, RETURN_MASK_ALL
)
473 if (newvalue
!= Py_None
)
476 GDB_PY_SET_HANDLE_EXCEPTION (except
);
481 /* Python function to get the commands attached to a breakpoint. */
483 bppy_get_commands (PyObject
*self
, void *closure
)
485 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
486 struct breakpoint
*bp
= self_bp
->bp
;
488 struct ui_file
*string_file
;
489 struct cleanup
*chain
;
493 BPPY_REQUIRE_VALID (self_bp
);
495 if (! self_bp
->bp
->commands
)
498 string_file
= mem_fileopen ();
499 chain
= make_cleanup_ui_file_delete (string_file
);
501 ui_out_redirect (current_uiout
, string_file
);
504 print_command_lines (current_uiout
, breakpoint_commands (bp
), 0);
506 CATCH (except
, RETURN_MASK_ALL
)
508 ui_out_redirect (current_uiout
, NULL
);
510 gdbpy_convert_exception (except
);
515 ui_out_redirect (current_uiout
, NULL
);
516 cmdstr
= ui_file_xstrdup (string_file
, &length
);
517 make_cleanup (xfree
, cmdstr
);
518 result
= host_string_to_python_string (cmdstr
);
523 /* Python function to get the breakpoint type. */
525 bppy_get_type (PyObject
*self
, void *closure
)
527 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
529 BPPY_REQUIRE_VALID (self_bp
);
531 return PyInt_FromLong (self_bp
->bp
->type
);
534 /* Python function to get the visibility of the breakpoint. */
537 bppy_get_visibility (PyObject
*self
, void *closure
)
539 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
541 BPPY_REQUIRE_VALID (self_bp
);
543 if (self_bp
->bp
->number
< 0)
549 /* Python function to determine if the breakpoint is a temporary
553 bppy_get_temporary (PyObject
*self
, void *closure
)
555 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
557 BPPY_REQUIRE_VALID (self_bp
);
559 if (self_bp
->bp
->disposition
== disp_del
560 || self_bp
->bp
->disposition
== disp_del_at_next_stop
)
566 /* Python function to get the breakpoint's number. */
568 bppy_get_number (PyObject
*self
, void *closure
)
570 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
572 BPPY_REQUIRE_VALID (self_bp
);
574 return PyInt_FromLong (self_bp
->number
);
577 /* Python function to get the breakpoint's thread ID. */
579 bppy_get_thread (PyObject
*self
, void *closure
)
581 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
583 BPPY_REQUIRE_VALID (self_bp
);
585 if (self_bp
->bp
->thread
== -1)
588 return PyInt_FromLong (self_bp
->bp
->thread
);
591 /* Python function to get the breakpoint's task ID (in Ada). */
593 bppy_get_task (PyObject
*self
, void *closure
)
595 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
597 BPPY_REQUIRE_VALID (self_bp
);
599 if (self_bp
->bp
->task
== 0)
602 return PyInt_FromLong (self_bp
->bp
->task
);
605 /* Python function to get the breakpoint's hit count. */
607 bppy_get_hit_count (PyObject
*self
, void *closure
)
609 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
611 BPPY_REQUIRE_VALID (self_bp
);
613 return PyInt_FromLong (self_bp
->bp
->hit_count
);
616 /* Python function to get the breakpoint's ignore count. */
618 bppy_get_ignore_count (PyObject
*self
, void *closure
)
620 gdbpy_breakpoint_object
*self_bp
= (gdbpy_breakpoint_object
*) self
;
622 BPPY_REQUIRE_VALID (self_bp
);
624 return PyInt_FromLong (self_bp
->bp
->ignore_count
);
627 /* Python function to create a new breakpoint. */
629 bppy_init (PyObject
*self
, PyObject
*args
, PyObject
*kwargs
)
631 static char *keywords
[] = { "spec", "type", "wp_class", "internal",
634 int type
= bp_breakpoint
;
635 int access_type
= hw_write
;
636 PyObject
*internal
= NULL
;
637 PyObject
*temporary
= NULL
;
639 int temporary_bp
= 0;
641 if (! PyArg_ParseTupleAndKeywords (args
, kwargs
, "s|iiOO", keywords
,
642 &spec
, &type
, &access_type
,
643 &internal
, &temporary
))
648 internal_bp
= PyObject_IsTrue (internal
);
649 if (internal_bp
== -1)
653 if (temporary
!= NULL
)
655 temporary_bp
= PyObject_IsTrue (temporary
);
656 if (temporary_bp
== -1)
660 bppy_pending_object
= (gdbpy_breakpoint_object
*) self
;
661 bppy_pending_object
->number
= -1;
662 bppy_pending_object
->bp
= NULL
;
666 char *copy
= xstrdup (skip_spaces_const (spec
));
667 struct cleanup
*cleanup
= make_cleanup (xfree
, copy
);
673 struct event_location
*location
;
676 = string_to_event_location_basic (©
, current_language
);
677 make_cleanup_delete_event_location (location
);
678 create_breakpoint (python_gdbarch
,
679 location
, NULL
, -1, NULL
,
681 temporary_bp
, bp_breakpoint
,
684 &bkpt_breakpoint_ops
,
685 0, 1, internal_bp
, 0);
690 if (access_type
== hw_write
)
691 watch_command_wrapper (copy
, 0, internal_bp
);
692 else if (access_type
== hw_access
)
693 awatch_command_wrapper (copy
, 0, internal_bp
);
694 else if (access_type
== hw_read
)
695 rwatch_command_wrapper (copy
, 0, internal_bp
);
697 error(_("Cannot understand watchpoint access type."));
701 error(_("Do not understand breakpoint type to set."));
704 do_cleanups (cleanup
);
706 CATCH (except
, RETURN_MASK_ALL
)
708 bppy_pending_object
= NULL
;
709 PyErr_Format (except
.reason
== RETURN_QUIT
710 ? PyExc_KeyboardInterrupt
: PyExc_RuntimeError
,
711 "%s", except
.message
);
716 BPPY_SET_REQUIRE_VALID ((gdbpy_breakpoint_object
*) self
);
723 build_bp_list (struct breakpoint
*b
, void *arg
)
725 PyObject
*list
= (PyObject
*) arg
;
726 PyObject
*bp
= (PyObject
*) b
->py_bp_object
;
729 /* Not all breakpoints will have a companion Python object.
730 Only breakpoints that were created via bppy_new, or
731 breakpoints that were created externally and are tracked by
732 the Python Scripting API. */
734 iserr
= PyList_Append (list
, bp
);
742 /* Static function to return a tuple holding all breakpoints. */
745 gdbpy_breakpoints (PyObject
*self
, PyObject
*args
)
747 PyObject
*list
, *tuple
;
750 return PyTuple_New (0);
752 list
= PyList_New (0);
756 /* If iterate_over_breakpoints returns non NULL it signals an error
757 condition. In that case abandon building the list and return
759 if (iterate_over_breakpoints (build_bp_list
, list
) != NULL
)
765 tuple
= PyList_AsTuple (list
);
771 /* Call the "stop" method (if implemented) in the breakpoint
772 class. If the method returns True, the inferior will be
773 stopped at the breakpoint. Otherwise the inferior will be
774 allowed to continue. */
776 enum ext_lang_bp_stop
777 gdbpy_breakpoint_cond_says_stop (const struct extension_language_defn
*extlang
,
778 struct breakpoint
*b
)
781 struct gdbpy_breakpoint_object
*bp_obj
= b
->py_bp_object
;
782 PyObject
*py_bp
= (PyObject
*) bp_obj
;
783 struct gdbarch
*garch
;
784 struct cleanup
*cleanup
;
787 return EXT_LANG_BP_STOP_UNSET
;
790 garch
= b
->gdbarch
? b
->gdbarch
: get_current_arch ();
791 cleanup
= ensure_python_env (garch
, current_language
);
793 if (bp_obj
->is_finish_bp
)
794 bpfinishpy_pre_stop_hook (bp_obj
);
796 if (PyObject_HasAttrString (py_bp
, stop_func
))
798 PyObject
*result
= PyObject_CallMethod (py_bp
, stop_func
, NULL
);
803 int evaluate
= PyObject_IsTrue (result
);
806 gdbpy_print_stack ();
808 /* If the "stop" function returns False that means
809 the Python breakpoint wants GDB to continue. */
816 gdbpy_print_stack ();
819 if (bp_obj
->is_finish_bp
)
820 bpfinishpy_post_stop_hook (bp_obj
);
822 do_cleanups (cleanup
);
825 return EXT_LANG_BP_STOP_UNSET
;
826 return stop
? EXT_LANG_BP_STOP_YES
: EXT_LANG_BP_STOP_NO
;
829 /* Checks if the "stop" method exists in this breakpoint.
830 Used by condition_command to ensure mutual exclusion of breakpoint
834 gdbpy_breakpoint_has_cond (const struct extension_language_defn
*extlang
,
835 struct breakpoint
*b
)
839 struct gdbarch
*garch
;
840 struct cleanup
*cleanup
;
842 if (b
->py_bp_object
== NULL
)
845 py_bp
= (PyObject
*) b
->py_bp_object
;
846 garch
= b
->gdbarch
? b
->gdbarch
: get_current_arch ();
847 cleanup
= ensure_python_env (garch
, current_language
);
848 has_func
= PyObject_HasAttrString (py_bp
, stop_func
);
849 do_cleanups (cleanup
);
856 /* Event callback functions. */
858 /* Callback that is used when a breakpoint is created. This function
859 will create a new Python breakpoint object. */
861 gdbpy_breakpoint_created (struct breakpoint
*bp
)
863 gdbpy_breakpoint_object
*newbp
;
864 PyGILState_STATE state
;
866 if (bp
->number
< 0 && bppy_pending_object
== NULL
)
869 if (bp
->type
!= bp_breakpoint
870 && bp
->type
!= bp_watchpoint
871 && bp
->type
!= bp_hardware_watchpoint
872 && bp
->type
!= bp_read_watchpoint
873 && bp
->type
!= bp_access_watchpoint
)
876 state
= PyGILState_Ensure ();
878 if (bppy_pending_object
)
880 newbp
= bppy_pending_object
;
881 bppy_pending_object
= NULL
;
884 newbp
= PyObject_New (gdbpy_breakpoint_object
, &breakpoint_object_type
);
887 newbp
->number
= bp
->number
;
889 newbp
->bp
->py_bp_object
= newbp
;
890 newbp
->is_finish_bp
= 0;
896 PyErr_SetString (PyExc_RuntimeError
,
897 _("Error while creating breakpoint from GDB."));
898 gdbpy_print_stack ();
901 PyGILState_Release (state
);
904 /* Callback that is used when a breakpoint is deleted. This will
905 invalidate the corresponding Python object. */
907 gdbpy_breakpoint_deleted (struct breakpoint
*b
)
910 PyGILState_STATE state
;
911 struct breakpoint
*bp
= NULL
;
912 gdbpy_breakpoint_object
*bp_obj
;
914 state
= PyGILState_Ensure ();
915 bp
= get_breakpoint (num
);
918 bp_obj
= bp
->py_bp_object
;
926 PyGILState_Release (state
);
931 /* Initialize the Python breakpoint code. */
933 gdbpy_initialize_breakpoints (void)
937 breakpoint_object_type
.tp_new
= PyType_GenericNew
;
938 if (PyType_Ready (&breakpoint_object_type
) < 0)
941 if (gdb_pymodule_addobject (gdb_module
, "Breakpoint",
942 (PyObject
*) &breakpoint_object_type
) < 0)
945 observer_attach_breakpoint_created (gdbpy_breakpoint_created
);
946 observer_attach_breakpoint_deleted (gdbpy_breakpoint_deleted
);
948 /* Add breakpoint types constants. */
949 for (i
= 0; pybp_codes
[i
].name
; ++i
)
951 if (PyModule_AddIntConstant (gdb_module
,
952 /* Cast needed for Python 2.4. */
953 (char *) pybp_codes
[i
].name
,
954 pybp_codes
[i
].code
) < 0)
958 /* Add watchpoint types constants. */
959 for (i
= 0; pybp_watch_types
[i
].name
; ++i
)
961 if (PyModule_AddIntConstant (gdb_module
,
962 /* Cast needed for Python 2.4. */
963 (char *) pybp_watch_types
[i
].name
,
964 pybp_watch_types
[i
].code
) < 0)
973 /* Helper function that overrides this Python object's
974 PyObject_GenericSetAttr to allow extra validation of the attribute
978 local_setattro (PyObject
*self
, PyObject
*name
, PyObject
*v
)
980 gdbpy_breakpoint_object
*obj
= (gdbpy_breakpoint_object
*) self
;
981 char *attr
= python_string_to_host_string (name
);
986 /* If the attribute trying to be set is the "stop" method,
987 but we already have a condition set in the CLI or other extension
988 language, disallow this operation. */
989 if (strcmp (attr
, stop_func
) == 0)
991 const struct extension_language_defn
*extlang
= NULL
;
993 if (obj
->bp
->cond_string
!= NULL
)
994 extlang
= get_ext_lang_defn (EXT_LANG_GDB
);
996 extlang
= get_breakpoint_cond_ext_lang (obj
->bp
, EXT_LANG_PYTHON
);
1003 = xstrprintf (_("Only one stop condition allowed. There is"
1004 " currently a %s stop condition defined for"
1005 " this breakpoint."),
1006 ext_lang_capitalized_name (extlang
));
1007 PyErr_SetString (PyExc_RuntimeError
, error_text
);
1015 return PyObject_GenericSetAttr ((PyObject
*)self
, name
, v
);
1018 static PyGetSetDef breakpoint_object_getset
[] = {
1019 { "enabled", bppy_get_enabled
, bppy_set_enabled
,
1020 "Boolean telling whether the breakpoint is enabled.", NULL
},
1021 { "silent", bppy_get_silent
, bppy_set_silent
,
1022 "Boolean telling whether the breakpoint is silent.", NULL
},
1023 { "thread", bppy_get_thread
, bppy_set_thread
,
1024 "Thread ID for the breakpoint.\n\
1025 If the value is a thread ID (integer), then this is a thread-specific breakpoint.\n\
1026 If the value is None, then this breakpoint is not thread-specific.\n\
1027 No other type of value can be used.", NULL
},
1028 { "task", bppy_get_task
, bppy_set_task
,
1029 "Thread ID for the breakpoint.\n\
1030 If the value is a task ID (integer), then this is an Ada task-specific breakpoint.\n\
1031 If the value is None, then this breakpoint is not task-specific.\n\
1032 No other type of value can be used.", NULL
},
1033 { "ignore_count", bppy_get_ignore_count
, bppy_set_ignore_count
,
1034 "Number of times this breakpoint should be automatically continued.",
1036 { "number", bppy_get_number
, NULL
,
1037 "Breakpoint's number assigned by GDB.", NULL
},
1038 { "hit_count", bppy_get_hit_count
, bppy_set_hit_count
,
1039 "Number of times the breakpoint has been hit.\n\
1040 Can be set to zero to clear the count. No other value is valid\n\
1041 when setting this property.", NULL
},
1042 { "location", bppy_get_location
, NULL
,
1043 "Location of the breakpoint, as specified by the user.", NULL
},
1044 { "expression", bppy_get_expression
, NULL
,
1045 "Expression of the breakpoint, as specified by the user.", NULL
},
1046 { "condition", bppy_get_condition
, bppy_set_condition
,
1047 "Condition of the breakpoint, as specified by the user,\
1048 or None if no condition set."},
1049 { "commands", bppy_get_commands
, NULL
,
1050 "Commands of the breakpoint, as specified by the user."},
1051 { "type", bppy_get_type
, NULL
,
1052 "Type of breakpoint."},
1053 { "visible", bppy_get_visibility
, NULL
,
1054 "Whether the breakpoint is visible to the user."},
1055 { "temporary", bppy_get_temporary
, NULL
,
1056 "Whether this breakpoint is a temporary breakpoint."},
1057 { NULL
} /* Sentinel. */
1060 static PyMethodDef breakpoint_object_methods
[] =
1062 { "is_valid", bppy_is_valid
, METH_NOARGS
,
1063 "Return true if this breakpoint is valid, false if not." },
1064 { "delete", bppy_delete_breakpoint
, METH_NOARGS
,
1065 "Delete the underlying GDB breakpoint." },
1066 { NULL
} /* Sentinel. */
1069 PyTypeObject breakpoint_object_type
=
1071 PyVarObject_HEAD_INIT (NULL
, 0)
1072 "gdb.Breakpoint", /*tp_name*/
1073 sizeof (gdbpy_breakpoint_object
), /*tp_basicsize*/
1082 0, /*tp_as_sequence*/
1083 0, /*tp_as_mapping*/
1088 (setattrofunc
)local_setattro
, /*tp_setattro */
1090 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
1091 "GDB breakpoint object", /* tp_doc */
1092 0, /* tp_traverse */
1094 0, /* tp_richcompare */
1095 0, /* tp_weaklistoffset */
1097 0, /* tp_iternext */
1098 breakpoint_object_methods
, /* tp_methods */
1100 breakpoint_object_getset
, /* tp_getset */
1103 0, /* tp_descr_get */
1104 0, /* tp_descr_set */
1105 0, /* tp_dictoffset */
1106 bppy_init
, /* tp_init */