aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-breakpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python/py-breakpoint.c')
-rw-r--r--gdb/python/py-breakpoint.c82
1 files changed, 55 insertions, 27 deletions
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index aa404b7..125c6fd 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -750,15 +750,22 @@ gdbpy_breakpoints (PyObject *self, PyObject *args)
stopped at the breakpoint. Otherwise the inferior will be
allowed to continue. */
-int
-gdbpy_should_stop (struct gdbpy_breakpoint_object *bp_obj)
+enum ext_lang_bp_stop
+gdbpy_breakpoint_cond_says_stop (const struct extension_language_defn *extlang,
+ struct breakpoint *b)
{
- int stop = 1;
-
+ int stop;
+ struct gdbpy_breakpoint_object *bp_obj = b->py_bp_object;
PyObject *py_bp = (PyObject *) bp_obj;
- struct breakpoint *b = bp_obj->bp;
- struct gdbarch *garch = b->gdbarch ? b->gdbarch : get_current_arch ();
- struct cleanup *cleanup = ensure_python_env (garch, current_language);
+ struct gdbarch *garch;
+ struct cleanup *cleanup;
+
+ if (bp_obj == NULL)
+ return EXT_LANG_BP_STOP_UNSET;
+
+ stop = -1;
+ garch = b->gdbarch ? b->gdbarch : get_current_arch ();
+ cleanup = ensure_python_env (garch, current_language);
if (bp_obj->is_finish_bp)
bpfinishpy_pre_stop_hook (bp_obj);
@@ -767,6 +774,7 @@ gdbpy_should_stop (struct gdbpy_breakpoint_object *bp_obj)
{
PyObject *result = PyObject_CallMethod (py_bp, stop_func, NULL);
+ stop = 1;
if (result)
{
int evaluate = PyObject_IsTrue (result);
@@ -790,7 +798,9 @@ gdbpy_should_stop (struct gdbpy_breakpoint_object *bp_obj)
do_cleanups (cleanup);
- return stop;
+ if (stop < 0)
+ return EXT_LANG_BP_STOP_UNSET;
+ return stop ? EXT_LANG_BP_STOP_YES : EXT_LANG_BP_STOP_NO;
}
/* Checks if the "stop" method exists in this breakpoint.
@@ -798,17 +808,21 @@ gdbpy_should_stop (struct gdbpy_breakpoint_object *bp_obj)
conditions. */
int
-gdbpy_breakpoint_has_py_cond (struct gdbpy_breakpoint_object *bp_obj)
+gdbpy_breakpoint_has_cond (const struct extension_language_defn *extlang,
+ struct breakpoint *b)
{
- int has_func = 0;
- PyObject *py_bp = (PyObject *) bp_obj;
- struct gdbarch *garch = bp_obj->bp->gdbarch ? bp_obj->bp->gdbarch :
- get_current_arch ();
- struct cleanup *cleanup = ensure_python_env (garch, current_language);
-
- if (py_bp != NULL)
- has_func = PyObject_HasAttrString (py_bp, stop_func);
-
+ int has_func;
+ PyObject *py_bp;
+ struct gdbarch *garch;
+ struct cleanup *cleanup;
+
+ if (b->py_bp_object == NULL)
+ return 0;
+
+ py_bp = (PyObject *) b->py_bp_object;
+ garch = b->gdbarch ? b->gdbarch : get_current_arch ();
+ cleanup = ensure_python_env (garch, current_language);
+ has_func = PyObject_HasAttrString (py_bp, stop_func);
do_cleanups (cleanup);
return has_func;
@@ -947,16 +961,30 @@ local_setattro (PyObject *self, PyObject *name, PyObject *v)
return -1;
/* If the attribute trying to be set is the "stop" method,
- but we already have a condition set in the CLI, disallow this
- operation. */
- if (strcmp (attr, stop_func) == 0 && obj->bp->cond_string)
+ but we already have a condition set in the CLI or other extension
+ language, disallow this operation. */
+ if (strcmp (attr, stop_func) == 0)
{
- xfree (attr);
- PyErr_SetString (PyExc_RuntimeError,
- _("Cannot set 'stop' method. There is an " \
- "existing GDB condition attached to the " \
- "breakpoint."));
- return -1;
+ const struct extension_language_defn *extlang = NULL;
+
+ if (obj->bp->cond_string != NULL)
+ extlang = get_ext_lang_defn (EXT_LANG_GDB);
+ if (extlang == NULL)
+ extlang = get_breakpoint_cond_ext_lang (obj->bp, EXT_LANG_PYTHON);
+ if (extlang != NULL)
+ {
+ char *error_text;
+
+ xfree (attr);
+ error_text
+ = xstrprintf (_("Only one stop condition allowed. There is"
+ " currently a %s stop condition defined for"
+ " this breakpoint."),
+ ext_lang_capitalized_name (extlang));
+ PyErr_SetString (PyExc_RuntimeError, error_text);
+ xfree (error_text);
+ return -1;
+ }
}
xfree (attr);