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 /gdb/python/py-stopevent.c | |
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.
Diffstat (limited to 'gdb/python/py-stopevent.c')
-rw-r--r-- | gdb/python/py-stopevent.c | 43 |
1 files changed, 34 insertions, 9 deletions
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, |