diff options
author | Kevin Pouget <kpouget@sourceware.org> | 2011-09-15 12:27:20 +0000 |
---|---|---|
committer | Kevin Pouget <kpouget@sourceware.org> | 2011-09-15 12:27:20 +0000 |
commit | 6839b47f2b1cd56c90dc38da7bb612df7e052d90 (patch) | |
tree | acffae36122d018201e9bf74f07ccc2671fa6951 | |
parent | 672f9b600994c1a377477b6d88b7f63aaf9c7ffe (diff) | |
download | gdb-6839b47f2b1cd56c90dc38da7bb612df7e052d90.zip gdb-6839b47f2b1cd56c90dc38da7bb612df7e052d90.tar.gz gdb-6839b47f2b1cd56c90dc38da7bb612df7e052d90.tar.bz2 |
2011-09-15 Kevin Pouget <kevin.pouget@st.com>
Handle multiple breakpoint hits in Python interface:
* python/py-bpevent.c (create_breakpoint_event_object): Rename C/Python
variable to breakpoints.
* python/py-stopevent.c (emit_stop_event): Return a Python tuple of
bps instead of single breakpoint. Fix some space typos.
* python/py-stopevent.c (create_breakpoint_event_object): Rename
variable to breakpoints.
testsuite:
* gdb.python/py-events.exp: Set a duplicate breakpoint and check its
presence.
* gdb.python/py-events.py (breakpoint_stop_handler): Browse all the
breakpoint hits.
doc:
* gdb.texinfo (Events In Python): New function documentation:
gdb.BreakpointEvent.breakpoints. Indicate that
gdb.BreakpointEvent.breakpoint is now deprecated.
-rw-r--r-- | gdb/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/NEWS | 3 | ||||
-rw-r--r-- | gdb/doc/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 13 | ||||
-rw-r--r-- | gdb/python/py-bpevent.c | 8 | ||||
-rw-r--r-- | gdb/python/py-stopevent.c | 43 | ||||
-rw-r--r-- | gdb/python/py-stopevent.h | 3 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-events.exp | 3 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-events.py | 4 |
10 files changed, 85 insertions, 17 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 18af26c..380f75f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,15 @@ 2011-09-15 Kevin Pouget <kevin.pouget@st.com> + Handle multiple breakpoint hits in Python interface: + * python/py-bpevent.c (create_breakpoint_event_object): Rename C/Python + variable to breakpoints. + * python/py-stopevent.c (emit_stop_event): Return a Python tuple of + bps instead of single breakpoint. Fix some space typos. + * python/py-stopevent.c (create_breakpoint_event_object): Rename + variable to breakpoints. + +2011-09-15 Kevin Pouget <kevin.pouget@st.com> + * breakpoint.c (describe_other_breakpoints): Do not write 'duplicate' note if the breakpoint is internal. @@ -38,6 +38,9 @@ ** Symbols now provide the "type" attribute, the type of the symbol. + ** The "gdb.breakpoint" function has been deprecated in favor of + "gdb.breakpoints". + * libthread-db-search-path now supports two special values: $sdir and $pdir. $sdir specifies the default system locations of shared libraries. $pdir specifies the directory where the libpthread used by the application diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index e5d2161..54dd4e8 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,10 @@ +2011-09-15 Kevin Pouget <kevin.pouget@st.com> + + Handle multiple breakpoint hits in Python interface: + * gdb.texinfo (Events In Python): New function documentation: + gdb.BreakpointEvent.breakpoints. Indicate that + gdb.BreakpointEvent.breakpoint is now deprecated. + 2011-09-04 Joel Brobecker <brobecker@adacore.com> * gdb.texinfo: Set EDITION to "Tenth" and change ISBN. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index ccef92c..76c804b 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -22317,14 +22317,19 @@ the @value{GDBN} command prompt. Also emits @code{gdb.BreakpointEvent} which extends @code{gdb.StopEvent}. -@code{gdb.BreakpointEvent} event indicates that a breakpoint has been hit, and -has the following attributes: +@code{gdb.BreakpointEvent} event indicates that one or more breakpoints have +been hit, and has the following attributes: @table @code -@defivar BreakpointEvent breakpoint -A reference to the breakpoint that was hit of type @code{gdb.Breakpoint}. +@defivar BreakpointEvent breakpoints +A sequence containing references to all the breakpoints (type +@code{gdb.Breakpoint}) that were hit. @xref{Breakpoints In Python}, for details of the @code{gdb.Breakpoint} object. @end defivar +@defivar BreakpointEvent breakpoint +A reference to the first breakpoint that was hit. +This function is maintained for backward compatibility and is now deprecated +in favor of the @code{gdb.BreakpointEvent.breakpoints} function. @end table @end table diff --git a/gdb/python/py-bpevent.c b/gdb/python/py-bpevent.c index c7f7965..f37b248 100644 --- a/gdb/python/py-bpevent.c +++ b/gdb/python/py-bpevent.c @@ -24,7 +24,7 @@ static PyTypeObject breakpoint_event_object_type; /* Create and initialize a BreakpointEvent object. */ PyObject * -create_breakpoint_event_object (PyObject *breakpoint) +create_breakpoint_event_object (PyObject *breakpoint_list, PyObject *first_bp) { PyObject *breakpoint_event_obj = create_stop_event_object (&breakpoint_event_object_type); @@ -34,7 +34,11 @@ create_breakpoint_event_object (PyObject *breakpoint) if (evpy_add_attribute (breakpoint_event_obj, "breakpoint", - breakpoint) < 0) + first_bp) < 0) + goto fail; + if (evpy_add_attribute (breakpoint_event_obj, + "breakpoints", + breakpoint_list) < 0) goto fail; return breakpoint_event_obj; diff --git a/gdb/python/py-stopevent.c b/gdb/python/py-stopevent.c index 122fe6b..1ecbe6c 100644 --- a/gdb/python/py-stopevent.c +++ b/gdb/python/py-stopevent.c @@ -45,18 +45,42 @@ int emit_stop_event (struct bpstats *bs, enum target_signal stop_signal) { PyObject *stop_event_obj = NULL; /* Appease GCC warning. */ + PyObject *list = NULL; + PyObject *first_bp = NULL; + struct bpstats *current_bs; if (evregpy_no_listeners_p (gdb_py_events.stop)) return 0; - if (bs && bs->breakpoint_at - && bs->breakpoint_at->py_bp_object) + /* Add any breakpoint set at this location to the list. */ + for (current_bs = bs; current_bs != NULL; current_bs = current_bs->next) { - stop_event_obj = create_breakpoint_event_object ((PyObject *) bs - ->breakpoint_at - ->py_bp_object); + if (current_bs->breakpoint_at + && current_bs->breakpoint_at->py_bp_object) + { + PyObject *current_py_bp = + (PyObject *) current_bs->breakpoint_at->py_bp_object; + + if (list == NULL) + { + list = PyList_New (0); + if (!list) + goto fail; + } + + if (PyList_Append (list, current_py_bp)) + goto fail; + + if (first_bp == NULL) + first_bp = current_py_bp; + } + } + + if (list != NULL) + { + stop_event_obj = create_breakpoint_event_object (list, first_bp); if (!stop_event_obj) - goto fail; + goto fail; } /* Check if the signal is "Signal 0" or "Trace/breakpoint trap". */ @@ -75,13 +99,14 @@ emit_stop_event (struct bpstats *bs, enum target_signal stop_signal) { stop_event_obj = create_stop_event_object (&stop_event_object_type); if (!stop_event_obj) - goto fail; + goto fail; } return evpy_emit_event (stop_event_obj, gdb_py_events.stop); - fail: - return -1; + fail: + Py_XDECREF (list); + return -1; } GDBPY_NEW_EVENT_TYPE (stop, diff --git a/gdb/python/py-stopevent.h b/gdb/python/py-stopevent.h index 52f3511..85ac4d3 100644 --- a/gdb/python/py-stopevent.h +++ b/gdb/python/py-stopevent.h @@ -28,7 +28,8 @@ extern void stop_evpy_dealloc (PyObject *self); extern int emit_stop_event (struct bpstats *bs, enum target_signal stop_signal); -extern PyObject *create_breakpoint_event_object (PyObject *breakpoint); +extern PyObject *create_breakpoint_event_object (PyObject *breakpoint_list, + PyObject *first_bp); extern PyObject *create_signal_event_object (enum target_signal stop_signal); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 62eb291..c33f55b 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2011-04-30 Kevin Pouget <kevin.pouget@st.com> + + Handle multiple breakpoint hits in Python interface: + * gdb.python/py-events.exp: Set a duplicate breakpoint and check its + presence. + * gdb.python/py-events.py (breakpoint_stop_handler): Browse all the + breakpoint hits. + 2011-09-13 Sami Wagiaalla <swagiaal@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp index 8493809..2d2139d 100644 --- a/gdb/testsuite/gdb.python/py-events.exp +++ b/gdb/testsuite/gdb.python/py-events.exp @@ -40,12 +40,15 @@ if ![runto_main ] then { gdb_test "Test_Events" "Event testers registered." gdb_breakpoint "first" +gdb_breakpoint "first" # Test continue event and breakpoint stop event gdb_test "continue" ".*event type: continue.* .*event type: stop.* .*stop reason: breakpoint.* +.*first breakpoint number: 2.* .*breakpoint number: 2.* +.*breakpoint number: 3.* all threads stopped" #test exited event. diff --git a/gdb/testsuite/gdb.python/py-events.py b/gdb/testsuite/gdb.python/py-events.py index 9f05b9f..10aea4f 100644 --- a/gdb/testsuite/gdb.python/py-events.py +++ b/gdb/testsuite/gdb.python/py-events.py @@ -31,7 +31,9 @@ def breakpoint_stop_handler (event): print "event type: stop" if (isinstance (event, gdb.BreakpointEvent)): print "stop reason: breakpoint" - print "breakpoint number: %s" % (event.breakpoint.number) + print "first breakpoint number: %s" % (event.breakpoint.number) + for bp in event.breakpoints: + print "breakpoint number: %s" % (bp.number) if ( event.inferior_thread is not None) : print "thread num: %s" % (event.inferior_thread.num); else: |