public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-pmuldoon-python-breakpoints: Implement (in rough) Eli and Pedro's review comments from 2010-12-13.
@ 2010-12-13 21:41 pmuldoon
0 siblings, 0 replies; only message in thread
From: pmuldoon @ 2010-12-13 21:41 UTC (permalink / raw)
To: archer-commits
The branch, archer-pmuldoon-python-breakpoints has been updated
via 909f9de2c19ee343816366c4a0bb78e15b5a5ad0 (commit)
from e0f80124bc5d3e4bbf965d49565cabe9d1e488f9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit 909f9de2c19ee343816366c4a0bb78e15b5a5ad0
Author: Phil Muldoon <pmuldoon@redhat.com>
Date: Mon Dec 13 21:40:42 2010 +0000
Implement (in rough) Eli and Pedro's review comments from 2010-12-13.
-----------------------------------------------------------------------
Summary of changes:
gdb/breakpoint.c | 34 +---------------------------------
gdb/doc/gdb.texinfo | 10 ++++------
gdb/python/py-breakpoint.c | 37 +++++++++++++++++++++++++++++++++++++
gdb/python/python.h | 4 ++++
4 files changed, 46 insertions(+), 39 deletions(-)
First 500 lines of diff:
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index bdfed89..8667e05 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1,4 +1,3 @@
-
/* Everything about breakpoints, for GDB.
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
@@ -75,7 +74,6 @@
#if HAVE_PYTHON
#include "python/python.h"
-#include "python/python-internal.h"
#endif
/* Arguments to pass as context to some catch command handlers. */
@@ -3932,38 +3930,8 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
/* Evaluate Python breakpoints that have an "evaluate"
function implemented. */
-#if HAVE_PYTHON
if (b->py_bp_object)
- {
- struct cleanup *cleanup = ensure_python_env (get_current_arch (),
- current_language);
- PyObject *gdbpy_bp_eval = PyString_FromString ("evaluate");
- PyObject *py_bp = (PyObject *) b->py_bp_object;
-
- if (PyObject_HasAttr (py_bp, gdbpy_bp_eval))
- {
- PyObject *result = PyObject_CallMethodObjArgs (py_bp,
- gdbpy_bp_eval,
- NULL);
-
- if (result)
- {
- int evaluate = PyObject_IsTrue (result);
-
- if (evaluate == -1)
- gdbpy_print_stack ();
-
- /* If the evaluate function returns False that means the
- Python breakpoint wants GDB to continue. */
- if (!evaluate)
- bs->stop = 0;
- }
- else
- gdbpy_print_stack ();
- }
- do_cleanups (cleanup);
- }
-#endif
+ bs->stop = gdbpy_bp_evaluate (b->py_bp_object);
if (is_watchpoint (b))
cond = b->cond_exp;
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 09a02b0..340ce3c 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -22874,13 +22874,11 @@ Return the symbol table's source absolute file name.
Python code can manipulate breakpoints via the @code{gdb.Breakpoint}
class. The @code{gdb.Breakpoint} class can be sub-classed and, in
particular, you may choose to implement the @code{evaluate} function.
-If this function is defined it will be called when the inferior reaches
-that breakpoint. If the @code{evaluate} function returns
+If this function is defined as a sub-class of @code{gdb.Breakpoint},
+it will be called when the inferior stops at any location of a
+breakpoint which instantiates that sub-class. If the function returns
@code{True}, the inferior will be stopped at the location of the
-breakpoint. Otherwise if the function returns @code{False} the
-inferior will continue. The @code{evaluate} function should not
-attempt to influence the state of the inferior (e.g., step) or
-otherwise alter its data.
+breakpoint, otherwise the inferior will continue.
If there are multiple breakpoints at the same location with an
@code{evaluate} function, each one will be called regardless of the
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 6752d83..a5f1aab 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -28,6 +28,8 @@
#include "observer.h"
#include "cli/cli-script.h"
#include "ada-lang.h"
+#include "arch-utils.h"
+#include "language.h"
/* From breakpoint.c. */
typedef struct breakpoint_object breakpoint_object;
@@ -695,6 +697,41 @@ gdbpy_breakpoints (PyObject *self, PyObject *args)
return PyList_AsTuple (list);
}
+int
+gdbpy_bp_evaluate (struct breakpoint_object *bp_obj)
+{
+ struct cleanup *cleanup = ensure_python_env (get_current_arch (),
+ current_language);
+ PyObject *gdbpy_bp_eval = PyString_FromString ("evaluate");
+ PyObject *py_bp = (PyObject *) bp_obj;
+ int should_stop = 1;
+
+ if (PyObject_HasAttr (py_bp, gdbpy_bp_eval))
+ {
+ PyObject *result = PyObject_CallMethodObjArgs (py_bp,
+ gdbpy_bp_eval,
+ NULL);
+
+ if (result)
+ {
+ int evaluate = PyObject_IsTrue (result);
+
+ if (evaluate == -1)
+ gdbpy_print_stack ();
+
+ /* If the evaluate function returns False that means the
+ Python breakpoint wants GDB to continue. */
+ if (!evaluate)
+ should_stop = 0;
+ }
+ else
+ gdbpy_print_stack ();
+ }
+ do_cleanups (cleanup);
+
+ return should_stop;
+}
+
\f
/* Event callback functions. */
diff --git a/gdb/python/python.h b/gdb/python/python.h
index 04d5c28..9b2298e 100644
--- a/gdb/python/python.h
+++ b/gdb/python/python.h
@@ -22,6 +22,8 @@
#include "value.h"
+struct breakpoint_object;
+
extern int gdbpy_global_auto_load;
extern void finish_python_initialization (void);
@@ -41,4 +43,6 @@ void preserve_python_values (struct objfile *objfile, htab_t copied_types);
void load_auto_scripts_for_objfile (struct objfile *objfile);
+int gdbpy_bp_evaluate (struct breakpoint_object *bp_obj);
+
#endif /* GDB_PYTHON_H */
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-12-13 21:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-13 21:41 [SCM] archer-pmuldoon-python-breakpoints: Implement (in rough) Eli and Pedro's review comments from 2010-12-13 pmuldoon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).