* [PATCH] Handle multiple breakpoint hits in Python interface [not found] <BANLkTik-ffBpfx4BALF5+Y0xSx_NnaCs7g@mail.gmail.com> @ 2011-04-22 9:34 ` Kevin Pouget 2011-05-19 18:34 ` Tom Tromey 0 siblings, 1 reply; 21+ messages in thread From: Kevin Pouget @ 2011-04-22 9:34 UTC (permalink / raw) To: gdb-patches Hello, following the discussion on http://sourceware.org/ml/gdb/2011-04/msg00131.html, here is a patch which allows Python scripts to know that several breakpoints (with the same PC) where hit during the "stop" event callback. What do you think about it ? Cordially, Kevin -- 2011-04-22 Kevin Pouget <kevin.pouget@st.com> Handle multiple breakpoint hits in Python interface: * gdb.texinfo (Events In Python): Indicate that multiple breakpoint may have been hit and rename the variable to breakpoints. 2011-04-22 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-04-22 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. -- diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index edcf5c2..f042001 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -22086,12 +22086,12 @@ 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 several 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 tuple containing references to the breakpoints (type @code{gdb.Breakpoint}) that were hit. @xref{Breakpoints In Python}, for details of the @code{gdb.Breakpoint} object. @end defivar @end table diff --git a/gdb/python/py-bpevent.c b/gdb/python/py-bpevent.c index c7f7965..8c9808c 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 *breakpoints) { PyObject *breakpoint_event_obj = create_stop_event_object (&breakpoint_event_object_type); @@ -33,8 +33,8 @@ create_breakpoint_event_object (PyObject *breakpoint) goto fail; if (evpy_add_attribute (breakpoint_event_obj, - "breakpoint", - breakpoint) < 0) + "breakpoints", + breakpoints) < 0) goto fail; return breakpoint_event_obj; diff --git a/gdb/python/py-stopevent.c b/gdb/python/py-stopevent.c index 122fe6b..5e28756 100644 --- a/gdb/python/py-stopevent.c +++ b/gdb/python/py-stopevent.c @@ -45,26 +45,37 @@ int emit_stop_event (struct bpstats *bs, enum target_signal stop_signal) { PyObject *stop_event_obj = NULL; /* Appease GCC warning. */ + PyObject *list = 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) + { + if (list == NULL) + list = PyList_New (0); + + if (PyList_Append (list, (PyObject *) current_bs->breakpoint_at->py_bp_object)) + goto fail; + } + } + if (list != NULL) + { + stop_event_obj = create_breakpoint_event_object (list); if (!stop_event_obj) - goto fail; + goto fail; } /* Check if the signal is "Signal 0" or "Trace/breakpoint trap". */ if (stop_signal != TARGET_SIGNAL_0 && stop_signal != TARGET_SIGNAL_TRAP) { - stop_event_obj = - create_signal_event_object (stop_signal); + stop_event_obj = create_signal_event_object (stop_signal); if (!stop_event_obj) goto fail; } @@ -75,7 +86,7 @@ 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); diff --git a/gdb/python/py-stopevent.h b/gdb/python/py-stopevent.h index 52f3511..4633ffd 100644 --- a/gdb/python/py-stopevent.h +++ b/gdb/python/py-stopevent.h @@ -28,7 +28,7 @@ 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 *breakpoints); extern PyObject *create_signal_event_object (enum target_signal stop_signal); diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp index e5d6daf..2b7cc08 100644 --- a/gdb/testsuite/gdb.python/py-events.exp +++ b/gdb/testsuite/gdb.python/py-events.exp @@ -45,12 +45,14 @@ 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.* .*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..fb8f7e4 100644 --- a/gdb/testsuite/gdb.python/py-events.py +++ b/gdb/testsuite/gdb.python/py-events.py @@ -31,7 +31,8 @@ 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) + 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: -- 1.7.4.4 ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-04-22 9:34 ` [PATCH] Handle multiple breakpoint hits in Python interface Kevin Pouget @ 2011-05-19 18:34 ` Tom Tromey 2011-05-23 9:39 ` Kevin Pouget 0 siblings, 1 reply; 21+ messages in thread From: Tom Tromey @ 2011-05-19 18:34 UTC (permalink / raw) To: Kevin Pouget; +Cc: gdb-patches >>>>> "Kevin" == Kevin Pouget <kevin.pouget@gmail.com> writes: Kevin> following the discussion on Kevin> http://sourceware.org/ml/gdb/2011-04/msg00131.html, here is a patch Kevin> which allows Python scripts to know that several breakpoints (with the Kevin> same PC) where hit during the "stop" event callback. Kevin> What do you think about it ? It seems like a reasonable idea. I think we can't just replace the "breakpoint" attribute with "breakpoints", since this is going to ship in 7.3, and we don't want to break backward compatibility. IIRC, you don't yet have your paperwork in place, so this can't go in too quickly. This still needs a doc review. Kevin> +@defivar BreakpointEvent breakpoints Kevin> +A tuple containing references to the breakpoints (type Not technically a tuple, the code makes a list. Saying "sequence" would be ok. Kevin> + /*Add any breakpoint set at this location to the list. */ Space after the first "*". Kevin> + if (list == NULL) Kevin> + list = PyList_New (0); You must check for failure here. Kevin> + if (PyList_Append (list, (PyObject *) current_bs-> breakpoint_at->py_bp_object)) Kevin> + goto fail; In the fail case, nothing frees 'list'. Tom ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-05-19 18:34 ` Tom Tromey @ 2011-05-23 9:39 ` Kevin Pouget 2011-05-23 10:51 ` Eli Zaretskii 2011-05-27 20:09 ` Tom Tromey 0 siblings, 2 replies; 21+ messages in thread From: Kevin Pouget @ 2011-05-23 9:39 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches [-- Attachment #1: Type: text/plain, Size: 2564 bytes --] Hello, On Thu, May 19, 2011 at 2:34 PM, Tom Tromey <tromey@redhat.com> wrote: >>>>>> "Kevin" == Kevin Pouget <kevin.pouget@gmail.com> writes: > > Kevin> following the discussion on > Kevin> http://sourceware.org/ml/gdb/2011-04/msg00131.html, here is a patch > Kevin> which allows Python scripts to know that several breakpoints (with the > Kevin> same PC) where hit during the "stop" event callback. > Kevin> What do you think about it ? > > It seems like a reasonable idea. > > I think we can't just replace the "breakpoint" attribute with > "breakpoints", since this is going to ship in 7.3, and we don't want to > break backward compatibility. I put back the breakpoint attribute in addition to the "breakpoints" sequence and added in the documentation that it was "legacy support", is it okay for you? > > This still needs a doc review. > > Kevin> +@defivar BreakpointEvent breakpoints > Kevin> +A tuple containing references to the breakpoints (type > > Not technically a tuple, the code makes a list. Saying "sequence" would > be ok. fixed > Kevin> + /*Add any breakpoint set at this location to the list. */ > > Space after the first "*". fixed > Kevin> + if (list == NULL) > Kevin> + list = PyList_New (0); > > You must check for failure here. fixed > Kevin> + if (PyList_Append (list, (PyObject *) > current_bs-> breakpoint_at->py_bp_object)) > Kevin> + goto fail; > > In the fail case, nothing frees 'list'. fixed I hope this patch will address all your concerns, cordially, Kevin -- 2011-04-22 Kevin Pouget <kevin.pouget@st.com> Handle multiple breakpoint hits in Python interface: * gdb.texinfo (Events In Python): Indicate that multiple breakpoint may have been hit and rename the variable to breakpoints. 2011-04-22 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-04-22 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. [-- Attachment #2: multiple-bps.txt --] [-- Type: text/plain, Size: 6119 bytes --] diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 584a520..84d7900 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -22157,13 +22157,17 @@ 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 several 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. +@defivar BreakpointEvent breakpoint +A reference to the first breakpoint that was hit of type @code{gdb.Breakpoint}. +(Legacy support.) @end defivar @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..15ffa74 100644 --- a/gdb/python/py-stopevent.c +++ b/gdb/python/py-stopevent.c @@ -45,18 +45,36 @@ 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) + { + if (list == NULL) + { + list = PyList_New (0); + if (!list) + goto fail; + } + if (PyList_Append (list, (PyObject *) current_bs->breakpoint_at->py_bp_object)) + goto fail; + if (first_bp == NULL) + first_bp = (PyObject *) current_bs->breakpoint_at->py_bp_object; + } + } + 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 +93,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/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp index e5d6daf..8eff165 100644 --- a/gdb/testsuite/gdb.python/py-events.exp +++ b/gdb/testsuite/gdb.python/py-events.exp @@ -45,12 +45,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: ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-05-23 9:39 ` Kevin Pouget @ 2011-05-23 10:51 ` Eli Zaretskii 2011-05-23 11:01 ` Kevin Pouget 2011-05-27 20:09 ` Tom Tromey 1 sibling, 1 reply; 21+ messages in thread From: Eli Zaretskii @ 2011-05-23 10:51 UTC (permalink / raw) To: Kevin Pouget; +Cc: tromey, gdb-patches > From: Kevin Pouget <kevin.pouget@gmail.com> > Date: Mon, 23 May 2011 05:38:54 -0400 > Cc: gdb-patches@sourceware.org > > 2011-04-22 Kevin Pouget <kevin.pouget@st.com> > > Handle multiple breakpoint hits in Python interface: > * gdb.texinfo (Events In Python): Indicate that multiple breakpoint > may have been hit and rename the variable to breakpoints. This part is OK, except... > +@defivar BreakpointEvent breakpoint > +A reference to the first breakpoint that was hit of type @code{gdb.Breakpoint}. > +(Legacy support.) ^^^^^^^^^^^^^^^^^ ...this. What is that phrase in parens for? Can it be removed? Thanks. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-05-23 10:51 ` Eli Zaretskii @ 2011-05-23 11:01 ` Kevin Pouget 2011-05-23 11:59 ` Eli Zaretskii 0 siblings, 1 reply; 21+ messages in thread From: Kevin Pouget @ 2011-05-23 11:01 UTC (permalink / raw) To: Eli Zaretskii; +Cc: tromey, gdb-patches hello, > ...this. What is that phrase in parens for? Can it be removed? do you mean the phrase or the parens? The reason why I added this comment is that, to my eyes, BreakpointEvent.breakpoint don't make sense anymore because it is incomplete and inaccurate, but it's kept in order not to break the backward compatibility. Maybe 'deprecated' would be a better wording ? cordially, Kevin On Mon, May 23, 2011 at 6:51 AM, Eli Zaretskii <eliz@gnu.org> wrote: >> From: Kevin Pouget <kevin.pouget@gmail.com> >> Date: Mon, 23 May 2011 05:38:54 -0400 >> Cc: gdb-patches@sourceware.org >> >> 2011-04-22 Kevin Pouget <kevin.pouget@st.com> >> >> Handle multiple breakpoint hits in Python interface: >> * gdb.texinfo (Events In Python): Indicate that multiple breakpoint >> may have been hit and rename the variable to breakpoints. > > This part is OK, except... > >> +@defivar BreakpointEvent breakpoint >> +A reference to the first breakpoint that was hit of type @code{gdb.Breakpoint}. >> +(Legacy support.) > ^^^^^^^^^^^^^^^^^ > ...this. What is that phrase in parens for? Can it be removed? > > Thanks. > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-05-23 11:01 ` Kevin Pouget @ 2011-05-23 11:59 ` Eli Zaretskii 0 siblings, 0 replies; 21+ messages in thread From: Eli Zaretskii @ 2011-05-23 11:59 UTC (permalink / raw) To: Kevin Pouget; +Cc: tromey, gdb-patches > From: Kevin Pouget <kevin.pouget@gmail.com> > Date: Mon, 23 May 2011 07:00:33 -0400 > Cc: tromey@redhat.com, gdb-patches@sourceware.org > > > ...this. What is that phrase in parens for? Can it be removed? > do you mean the phrase or the parens? Both. > The reason why I added this comment is that, to my eyes, > BreakpointEvent.breakpoint don't make sense anymore because it is > incomplete and inaccurate, but it's kept in order not to break the > backward compatibility. Maybe 'deprecated' would be a better wording ? In that case, I suggest to say it is deprecated and kept for backward compatibility, and advise which alternative should be used instead. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-05-23 9:39 ` Kevin Pouget 2011-05-23 10:51 ` Eli Zaretskii @ 2011-05-27 20:09 ` Tom Tromey 2011-05-30 7:37 ` Kevin Pouget 1 sibling, 1 reply; 21+ messages in thread From: Tom Tromey @ 2011-05-27 20:09 UTC (permalink / raw) To: Kevin Pouget; +Cc: gdb-patches >>>>> "Kevin" == Kevin Pouget <kevin.pouget@gmail.com> writes: Kevin> I put back the breakpoint attribute in addition to the "breakpoints" Kevin> sequence and added in the documentation that it was "legacy support", Kevin> is it okay for you? Yes. Many of your patches seem ready to me. A couple still may need doc review. IIRC, your paperwork isn't done yet, so at this point we must wait for that. I don't recall when you sent things in, if it has been a while you might consider pinging the FSF copyright clerk. Tom ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-05-27 20:09 ` Tom Tromey @ 2011-05-30 7:37 ` Kevin Pouget 2011-05-30 7:49 ` Eli Zaretskii 0 siblings, 1 reply; 21+ messages in thread From: Kevin Pouget @ 2011-05-30 7:37 UTC (permalink / raw) To: Tom Tromey, Eli Zaretskii; +Cc: gdb-patches [-- Attachment #1: Type: text/plain, Size: 1994 bytes --] Hello, here is the patch which includes the documentation modification asked by Eli: > In that case, I suggest to say it is deprecated and kept for backward > compatibility, and advise which alternative should be used instead. + This function is maintained for backward compatibility and is now deprecated + in favor of @code{gdb.BreakpointEvent.breakpoints()}. Thanks, Kevin -- 2011-04-30 Kevin Pouget <kevin.pouget@st.com> Handle multiple breakpoint hits in Python interface: * gdb.texinfo (Events In Python): Indicate that multiple breakpoint may have been hit and rename the variable to breakpoints. 2011-04-30 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-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. On Fri, May 27, 2011 at 4:09 PM, Tom Tromey <tromey@redhat.com> wrote: > > >>>>> "Kevin" == Kevin Pouget <kevin.pouget@gmail.com> writes: > > Kevin> I put back the breakpoint attribute in addition to the "breakpoints" > Kevin> sequence and added in the documentation that it was "legacy support", > Kevin> is it okay for you? > > Yes. > > Many of your patches seem ready to me. A couple still may need doc > review. IIRC, your paperwork isn't done yet, so at this point we must > wait for that. I don't recall when you sent things in, if it has been a > while you might consider pinging the FSF copyright clerk. > > Tom [-- Attachment #2: multiple-bps.txt --] [-- Type: text/plain, Size: 6249 bytes --] diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 584a520..15ec088 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -22157,13 +22157,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 several 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. +@defivar BreakpointEvent breakpoint +A reference to the first breakpoint that was hit of type @code{gdb.Breakpoint}. +This function is maintained for backward compatibility and is now deprecated +in favor of the @code{gdb.BreakpointEvent.breakpoints()} function. + @end defivar @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..15ffa74 100644 --- a/gdb/python/py-stopevent.c +++ b/gdb/python/py-stopevent.c @@ -45,18 +45,36 @@ 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) + { + if (list == NULL) + { + list = PyList_New (0); + if (!list) + goto fail; + } + if (PyList_Append (list, (PyObject *) current_bs->breakpoint_at->py_bp_object)) + goto fail; + if (first_bp == NULL) + first_bp = (PyObject *) current_bs->breakpoint_at->py_bp_object; + } + } + 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 +93,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/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp index e5d6daf..8eff165 100644 --- a/gdb/testsuite/gdb.python/py-events.exp +++ b/gdb/testsuite/gdb.python/py-events.exp @@ -45,12 +45,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: ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-05-30 7:37 ` Kevin Pouget @ 2011-05-30 7:49 ` Eli Zaretskii 2011-05-30 10:53 ` Kevin Pouget 0 siblings, 1 reply; 21+ messages in thread From: Eli Zaretskii @ 2011-05-30 7:49 UTC (permalink / raw) To: Kevin Pouget; +Cc: tromey, gdb-patches > From: Kevin Pouget <kevin.pouget@gmail.com> > Date: Mon, 30 May 2011 03:37:06 -0400 > Cc: gdb-patches@sourceware.org > > + This function is maintained for backward compatibility and is now deprecated > + in favor of @code{gdb.BreakpointEvent.breakpoints()}. Thanks, but please remove the "()" part, because it doesn't belong to the name of the method. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-05-30 7:49 ` Eli Zaretskii @ 2011-05-30 10:53 ` Kevin Pouget 2011-08-31 17:49 ` Tom Tromey 0 siblings, 1 reply; 21+ messages in thread From: Kevin Pouget @ 2011-05-30 10:53 UTC (permalink / raw) To: Eli Zaretskii; +Cc: gdb-patches [-- Attachment #1: Type: text/plain, Size: 1419 bytes --] On Mon, May 30, 2011 at 3:48 AM, Eli Zaretskii <eliz@gnu.org> wrote: >> From: Kevin Pouget <kevin.pouget@gmail.com> >> Date: Mon, 30 May 2011 03:37:06 -0400 >> Cc: gdb-patches@sourceware.org >> >> + This function is maintained for backward compatibility and is now deprecated >> + in favor of @code{gdb.BreakpointEvent.breakpoints()}. > > Thanks, but please remove the "()" part, because it doesn't belong to > the name of the method. fixed. thanks, Kevin 2011-04-30 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-04-30 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-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. [-- Attachment #2: multiple-bps.txt --] [-- Type: text/plain, Size: 6247 bytes --] diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 584a520..18bd66a 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -22157,13 +22157,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 several 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. +@defivar BreakpointEvent breakpoint +A reference to the first breakpoint that was hit of type @code{gdb.Breakpoint}. +This function is maintained for backward compatibility and is now deprecated +in favor of the @code{gdb.BreakpointEvent.breakpoints} function. + @end defivar @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..15ffa74 100644 --- a/gdb/python/py-stopevent.c +++ b/gdb/python/py-stopevent.c @@ -45,18 +45,36 @@ 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) + { + if (list == NULL) + { + list = PyList_New (0); + if (!list) + goto fail; + } + if (PyList_Append (list, (PyObject *) current_bs->breakpoint_at->py_bp_object)) + goto fail; + if (first_bp == NULL) + first_bp = (PyObject *) current_bs->breakpoint_at->py_bp_object; + } + } + 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 +93,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/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp index e5d6daf..8eff165 100644 --- a/gdb/testsuite/gdb.python/py-events.exp +++ b/gdb/testsuite/gdb.python/py-events.exp @@ -45,12 +45,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: ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-05-30 10:53 ` Kevin Pouget @ 2011-08-31 17:49 ` Tom Tromey 2011-09-01 8:36 ` Kevin Pouget 0 siblings, 1 reply; 21+ messages in thread From: Tom Tromey @ 2011-08-31 17:49 UTC (permalink / raw) To: Kevin Pouget; +Cc: Eli Zaretskii, gdb-patches >>>>> "Kevin" == Kevin Pouget <kevin.pouget@gmail.com> writes: Kevin> 2011-04-30 Kevin Pouget <kevin.pouget@st.com> Kevin> Handle multiple breakpoint hits in Python interface: Kevin> * gdb.texinfo (Events In Python): New function documentation: Kevin> gdb.BreakpointEvent.breakpoints. Indicate that Kevin> gdb.BreakpointEvent.breakpoint is now deprecated. [...] Kevin> + if (PyList_Append (list, (PyObject *) current_bs->breakpoint_at->py_bp_object)) I suggest introducing a PyObject* variable whose value is the second argument here. Then you don't need to reformat this line or the subsequent assignment to first_bp: Kevin> + first_bp = (PyObject *) current_bs->breakpoint_at->py_bp_object; Kevin> + Py_XDECREF(list); Missing space before "(". Otherwise seems reasonable. Could you please write NEWS patches for your change to the Python API? Tom ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-08-31 17:49 ` Tom Tromey @ 2011-09-01 8:36 ` Kevin Pouget 2011-09-01 8:52 ` Kevin Pouget 2011-09-01 10:18 ` Eli Zaretskii 0 siblings, 2 replies; 21+ messages in thread From: Kevin Pouget @ 2011-09-01 8:36 UTC (permalink / raw) To: Tom Tromey; +Cc: Eli Zaretskii, gdb-patches [-- Attachment #1: Type: text/plain, Size: 1227 bytes --] On Wed, Aug 31, 2011 at 7:49 PM, Tom Tromey <tromey@redhat.com> wrote: >>>>>> "Kevin" == Kevin Pouget <kevin.pouget@gmail.com> writes: > > Kevin> 2011-04-30 Kevin Pouget <kevin.pouget@st.com> > Kevin> Handle multiple breakpoint hits in Python interface: > Kevin> * gdb.texinfo (Events In Python): New function documentation: > Kevin> gdb.BreakpointEvent.breakpoints. Indicate that > Kevin> gdb.BreakpointEvent.breakpoint is now deprecated. > [...] > > Kevin> + if (PyList_Append (list, (PyObject *) current_bs->breakpoint_at->py_bp_object)) > > I suggest introducing a PyObject* variable whose value is the second > argument here. Then you don't need to reformat this line or the > subsequent assignment to first_bp: > > Kevin> + first_bp = (PyObject *) current_bs->breakpoint_at->py_bp_object; done > Kevin> + Py_XDECREF(list); > > Missing space before "(". done > Could you please write NEWS patches for your change to the Python API? I added this line: > ** The "gdb.breakpoint" function has been deprecated and in favor of "gdb.breakpoints". > Otherwise seems reasonable. Thanks, I attached a patch with these modifications Cordially, Kevin [-- Attachment #2: 0001-Handle-multiple-breakpoint-hits-in-Python-interface --] [-- Type: application/octet-stream, Size: 7472 bytes --] From 5ce26d0d2acff15dff8609248579b59c97d61033 Mon Sep 17 00:00:00 2001 From: Kevin Pouget <kevin.pouget@st.com> Date: Thu, 1 Sep 2011 10:27:09 +0200 Subject: [PATCH] Handle multiple breakpoint hits in Python interface --- gdb/NEWS | 3 ++ gdb/doc/gdb.texinfo | 14 +++++++--- gdb/python/py-bpevent.c | 8 ++++- gdb/python/py-stopevent.c | 43 +++++++++++++++++++++++++------ gdb/python/py-stopevent.h | 3 +- gdb/testsuite/gdb.python/py-events.exp | 3 ++ gdb/testsuite/gdb.python/py-events.py | 4 ++- 7 files changed, 61 insertions(+), 17 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 255a22e..94e4198 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -38,6 +38,9 @@ ** Symbols now provide the "type" attribute, the type of the symbol. + ** The "gdb.breakpoint" function has been deprecated and 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/gdb.texinfo b/gdb/doc/gdb.texinfo index 23b2a98..c007de9 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -22317,13 +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 several 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. +@defivar BreakpointEvent breakpoint +A reference to the first breakpoint that was hit of type @code{gdb.Breakpoint}. +This function is maintained for backward compatibility and is now deprecated +in favor of the @code{gdb.BreakpointEvent.breakpoints} function. + @end defivar @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/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp index e5d6daf..8eff165 100644 --- a/gdb/testsuite/gdb.python/py-events.exp +++ b/gdb/testsuite/gdb.python/py-events.exp @@ -45,12 +45,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: -- 1.7.6 ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-09-01 8:36 ` Kevin Pouget @ 2011-09-01 8:52 ` Kevin Pouget 2011-09-01 10:08 ` Pedro Alves 2011-09-01 10:18 ` Eli Zaretskii 1 sibling, 1 reply; 21+ messages in thread From: Kevin Pouget @ 2011-09-01 8:52 UTC (permalink / raw) To: Tom Tromey; +Cc: Eli Zaretskii, gdb-patches [-- Attachment #1: Type: text/plain, Size: 1042 bytes --] Sorry, I forgot to include the ChangeLog entry with the previous post, here it is: 2011-04-30 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-04-30 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-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. [-- Attachment #2: 0001-Handle-multiple-breakpoint-hits-in-Python-interface --] [-- Type: application/octet-stream, Size: 7472 bytes --] From 5ce26d0d2acff15dff8609248579b59c97d61033 Mon Sep 17 00:00:00 2001 From: Kevin Pouget <kevin.pouget@st.com> Date: Thu, 1 Sep 2011 10:27:09 +0200 Subject: [PATCH] Handle multiple breakpoint hits in Python interface --- gdb/NEWS | 3 ++ gdb/doc/gdb.texinfo | 14 +++++++--- gdb/python/py-bpevent.c | 8 ++++- gdb/python/py-stopevent.c | 43 +++++++++++++++++++++++++------ gdb/python/py-stopevent.h | 3 +- gdb/testsuite/gdb.python/py-events.exp | 3 ++ gdb/testsuite/gdb.python/py-events.py | 4 ++- 7 files changed, 61 insertions(+), 17 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 255a22e..94e4198 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -38,6 +38,9 @@ ** Symbols now provide the "type" attribute, the type of the symbol. + ** The "gdb.breakpoint" function has been deprecated and 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/gdb.texinfo b/gdb/doc/gdb.texinfo index 23b2a98..c007de9 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -22317,13 +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 several 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. +@defivar BreakpointEvent breakpoint +A reference to the first breakpoint that was hit of type @code{gdb.Breakpoint}. +This function is maintained for backward compatibility and is now deprecated +in favor of the @code{gdb.BreakpointEvent.breakpoints} function. + @end defivar @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/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp index e5d6daf..8eff165 100644 --- a/gdb/testsuite/gdb.python/py-events.exp +++ b/gdb/testsuite/gdb.python/py-events.exp @@ -45,12 +45,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: -- 1.7.6 ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-09-01 8:52 ` Kevin Pouget @ 2011-09-01 10:08 ` Pedro Alves 0 siblings, 0 replies; 21+ messages in thread From: Pedro Alves @ 2011-09-01 10:08 UTC (permalink / raw) To: gdb-patches; +Cc: Kevin Pouget, Tom Tromey, Eli Zaretskii > --bcaec52e5f83af47d204abdd5b89 > Content-Type: application/octet-stream; Please teach your browser to attach files to gmail as some text based content type, like patch/diff or text/x-patch. It may just be a matter of renaming the files with a ".diff" extension before attaching them. If not, you may need to teach your browser about the mime type of .diff. You can see which mime type gmail gives your patch before actually sending the email. Just let gmail complete the patch upload, and you should then see something like [X] 0001-Handle-multiple-breakpoint-hits-in-Python-interface.diff (text/x-patch) 5K > name=0001-Handle-multiple-breakpoint-hits-in-Python-interface > Content-Disposition: attachment; > filename=0001-Handle-multiple-breakpoint-hits-in-Python-interface > Content-Transfer-Encoding: base64 > X-Attachment-Id: f_gs1hwbr01 It also affects the mail archives, check the difference, both sent from gmail: <http://sourceware.org/ml/gdb-patches/2011-08/msg00659.html> <http://sourceware.org/ml/gdb-patches/2011-08/msg00570.html> (follow the "Raw text" link too) -- Pedro Alves ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-09-01 8:36 ` Kevin Pouget 2011-09-01 8:52 ` Kevin Pouget @ 2011-09-01 10:18 ` Eli Zaretskii 2011-09-01 11:41 ` Kevin Pouget 1 sibling, 1 reply; 21+ messages in thread From: Eli Zaretskii @ 2011-09-01 10:18 UTC (permalink / raw) To: Kevin Pouget; +Cc: tromey, gdb-patches > From: Kevin Pouget <kevin.pouget@gmail.com> > Date: Thu, 1 Sep 2011 10:35:42 +0200 > Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sourceware.org > > + ** The "gdb.breakpoint" function has been deprecated and in favor of > + "gdb.breakpoints". Without the "and", this is okay. > +@code{gdb.BreakpointEvent} event indicates that one or several breakpoints have ^^^^^^^^^^^^^^ "one or more" > +@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. > +@defivar BreakpointEvent breakpoint This cannot be right: each @defivar should end with the corresponding "@end defivar". Didn't makeinfo bitch at you? > +A reference to the first breakpoint that was hit of type @code{gdb.Breakpoint}. As opposed to what? watchpoints, catchpoints etc.? IOW, why do you need to mention the type issue? Thanks. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-09-01 10:18 ` Eli Zaretskii @ 2011-09-01 11:41 ` Kevin Pouget 2011-09-01 15:39 ` Pedro Alves 2011-09-01 20:53 ` Eli Zaretskii 0 siblings, 2 replies; 21+ messages in thread From: Kevin Pouget @ 2011-09-01 11:41 UTC (permalink / raw) To: Eli Zaretskii, Pedro Alves; +Cc: tromey, gdb-patches [-- Attachment #1: Type: text/plain, Size: 2983 bytes --] On Thu, Sep 1, 2011 at 11:56 AM, Pedro Alves <pedro@codesourcery.com> wrote: > Please teach your browser to attach files to gmail as > some text based content type, like patch/diff or > text/x-patch. I'm sorry for that, it was on purpose that I removed the '.patch', but I actually mixed up everything ... From now one there should be no problem, I'll take extra care about it, thanks for the tip (I guess there is no way to clean up the archive ... ?) On Thu, Sep 1, 2011 at 12:12 PM, Eli Zaretskii <eliz@gnu.org> wrote: >> + ** The "gdb.breakpoint" function has been deprecated and in favor of >> + "gdb.breakpoints". > > Without the "and", this is okay. done >> +@code{gdb.BreakpointEvent} event indicates that one or several breakpoints have > ^^^^^^^^^^^^^^ > "one or more" done >> +@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. >> +@defivar BreakpointEvent breakpoint > > This cannot be right: each @defivar should end with the corresponding > "@end defivar". Didn't makeinfo bitch at you? yes sorry it does; I naïvely expected `make' to build --and crash-- the documentation >> +A reference to the first breakpoint that was hit of type @code{gdb.Breakpoint}. > > As opposed to what? watchpoints, catchpoints etc.? IOW, why do you > need to mention the type issue? these are not my words, I just updated the sentence to mention that it's now deprecated. But you're right, it is redundant with "(type @code{gdb.Breakpoint})" mentioned in the previous lines (I removed it). I understand this precision as a way to tell the Python type of the object, and/or that it's a breakpoint hit, and nothing else (watchpoints/catchpoints are not handled in Python yet, AFAIK) Cordially, Kevin -- 2011-04-30 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-04-30 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-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. [-- Attachment #2: 0001-Handle-multiple-breakpoint-hits-in-Python-interface.patch --] [-- Type: text/x-patch, Size: 7444 bytes --] From 71b7f9086f3cab392459dabf102f33d0d88053a8 Mon Sep 17 00:00:00 2001 From: Kevin Pouget <kevin.pouget@st.com> Date: Thu, 1 Sep 2011 10:27:09 +0200 Subject: [PATCH] Handle multiple breakpoint hits in Python interface --- gdb/NEWS | 3 ++ gdb/doc/gdb.texinfo | 13 ++++++--- gdb/python/py-bpevent.c | 8 ++++- gdb/python/py-stopevent.c | 43 +++++++++++++++++++++++++------ gdb/python/py-stopevent.h | 3 +- gdb/testsuite/gdb.python/py-events.exp | 3 ++ gdb/testsuite/gdb.python/py-events.py | 4 ++- 7 files changed, 60 insertions(+), 17 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 255a22e..2c27337 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -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/gdb.texinfo b/gdb/doc/gdb.texinfo index 23b2a98..ca8b50e 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/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp index e5d6daf..8eff165 100644 --- a/gdb/testsuite/gdb.python/py-events.exp +++ b/gdb/testsuite/gdb.python/py-events.exp @@ -45,12 +45,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: -- 1.7.6 ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-09-01 11:41 ` Kevin Pouget @ 2011-09-01 15:39 ` Pedro Alves 2011-09-01 20:53 ` Eli Zaretskii 1 sibling, 0 replies; 21+ messages in thread From: Pedro Alves @ 2011-09-01 15:39 UTC (permalink / raw) To: gdb-patches; +Cc: Kevin Pouget, Eli Zaretskii, tromey On Thursday 01 September 2011 12:28:30, Kevin Pouget wrote: > On Thu, Sep 1, 2011 at 11:56 AM, Pedro Alves <pedro@codesourcery.com> wrote: > > Please teach your browser to attach files to gmail as > > some text based content type, like patch/diff or > > text/x-patch. > > I'm sorry for that, it was on purpose that I removed the '.patch', but > I actually mixed up everything ... > From now one there should be no problem, I'll take extra care about > it, thanks for the tip Thanks! > (I guess there is no way to clean up the archive ... ?) Nah, let's not bother with that. -- Pedro Alves ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-09-01 11:41 ` Kevin Pouget 2011-09-01 15:39 ` Pedro Alves @ 2011-09-01 20:53 ` Eli Zaretskii 2011-09-15 12:34 ` Kevin Pouget 1 sibling, 1 reply; 21+ messages in thread From: Eli Zaretskii @ 2011-09-01 20:53 UTC (permalink / raw) To: Kevin Pouget; +Cc: pedro, tromey, gdb-patches > From: Kevin Pouget <kevin.pouget@gmail.com> > Date: Thu, 1 Sep 2011 13:28:30 +0200 > Cc: tromey@redhat.com, gdb-patches@sourceware.org > > 2011-04-30 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. This version is fine with me. Thanks. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Handle multiple breakpoint hits in Python interface 2011-09-01 20:53 ` Eli Zaretskii @ 2011-09-15 12:34 ` Kevin Pouget 2011-09-16 7:55 ` [commit] gdb.python/py-evthreads.exp regression [Re: [PATCH] Handle multiple breakpoint hits in Python interface] Jan Kratochvil 0 siblings, 1 reply; 21+ messages in thread From: Kevin Pouget @ 2011-09-15 12:34 UTC (permalink / raw) To: gdb-patches; +Cc: pedro, tromey, Eli Zaretskii commited http://sourceware.org/ml/gdb-cvs/2011-09/msg00085.html thanks, Kevin On Thu, Sep 1, 2011 at 5:38 PM, Eli Zaretskii <eliz@gnu.org> wrote: >> From: Kevin Pouget <kevin.pouget@gmail.com> >> Date: Thu, 1 Sep 2011 13:28:30 +0200 >> Cc: tromey@redhat.com, gdb-patches@sourceware.org >> >> 2011-04-30 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. > > This version is fine with me. Thanks. > ^ permalink raw reply [flat|nested] 21+ messages in thread
* [commit] gdb.python/py-evthreads.exp regression [Re: [PATCH] Handle multiple breakpoint hits in Python interface] 2011-09-15 12:34 ` Kevin Pouget @ 2011-09-16 7:55 ` Jan Kratochvil 2011-09-16 9:12 ` Kevin Pouget 0 siblings, 1 reply; 21+ messages in thread From: Jan Kratochvil @ 2011-09-16 7:55 UTC (permalink / raw) To: Kevin Pouget; +Cc: gdb-patches, pedro, tromey, Eli Zaretskii On Thu, 15 Sep 2011 14:30:21 +0200, Kevin Pouget wrote: > commited > > http://sourceware.org/ml/gdb-cvs/2011-09/msg00085.html Regressed: FAIL: gdb.python/py-evthreads.exp: Run to breakpoint 1 FAIL: gdb.python/py-evthreads.exp: reached breakpoint 2 FAIL: gdb.python/py-evthreads.exp: reached breakpoint 3 event type: stop event type: stop stop reason: breakpoint +first breakpoint number: 1 breakpoint number: 1 thread num: 1 -(gdb) PASS: gdb.python/py-evthreads.exp: Run to breakpoint 1 +(gdb) FAIL: gdb.python/py-evthreads.exp: Run to breakpoint 1 I understand gdb.python/py-evthreads.exp has been checked in between your patch development and its check-in. Checked in. Regards, Jan http://sourceware.org/ml/gdb-cvs/2011-09/msg00096.html --- src/gdb/testsuite/ChangeLog 2011/09/15 12:42:30 1.2854 +++ src/gdb/testsuite/ChangeLog 2011/09/16 07:34:26 1.2855 @@ -1,3 +1,8 @@ +2011-09-16 Jan Kratochvil <jan.kratochvil@redhat.com> + + * gdb.python/py-evthreads.exp (Run to breakpoint 1) + (reached breakpoint 2, reached breakpoint 3): Update expected output. + 2011-09-15 Kevin Pouget <kevin.pouget@st.com> PR Python/12692 Add gdb.selected_inferior() to Python interface. --- src/gdb/testsuite/gdb.python/py-evthreads.exp 2011/09/13 21:39:59 1.5 +++ src/gdb/testsuite/gdb.python/py-evthreads.exp 2011/09/16 07:34:27 1.6 @@ -55,7 +55,7 @@ gdb_run_cmd set test "Run to breakpoint 1" gdb_test_multiple "" $test { - -re "event type: stop\r\nstop reason: breakpoint\r\nbreakpoint number: 1\r\nthread num: 1\r\n$gdb_prompt $" { + -re "event type: stop\r\nstop reason: breakpoint\r\nfirst breakpoint number: 1\r\nbreakpoint number: 1\r\nthread num: 1\r\n$gdb_prompt $" { pass $test } -re "The target does not support running in non-stop mode" { @@ -64,11 +64,11 @@ } } -gdb_test "next" "event type: stop\r\nstop reason: breakpoint\r\nbreakpoint number: 2\r\nthread num: 2" "reached breakpoint 2" +gdb_test "next" "event type: stop\r\nstop reason: breakpoint\r\nfirst breakpoint number: 2\r\nbreakpoint number: 2\r\nthread num: 2" "reached breakpoint 2" gdb_test "thread 2" {\[Switching to thread 2 .*} -gdb_test "next" "event type: stop\r\nstop reason: breakpoint\r\nbreakpoint number: 3\r\nthread num: 3" "reached breakpoint 3" +gdb_test "next" "event type: stop\r\nstop reason: breakpoint\r\nfirst breakpoint number: 3\r\nbreakpoint number: 3\r\nthread num: 3" "reached breakpoint 3" gdb_test "thread 3" {\[Switching to thread 3 .*} ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [commit] gdb.python/py-evthreads.exp regression [Re: [PATCH] Handle multiple breakpoint hits in Python interface] 2011-09-16 7:55 ` [commit] gdb.python/py-evthreads.exp regression [Re: [PATCH] Handle multiple breakpoint hits in Python interface] Jan Kratochvil @ 2011-09-16 9:12 ` Kevin Pouget 0 siblings, 0 replies; 21+ messages in thread From: Kevin Pouget @ 2011-09-16 9:12 UTC (permalink / raw) To: Jan Kratochvil; +Cc: gdb-patches, pedro, tromey, Eli Zaretskii On Fri, Sep 16, 2011 at 9:35 AM, Jan Kratochvil <jan.kratochvil@redhat.com> wrote: > > On Thu, 15 Sep 2011 14:30:21 +0200, Kevin Pouget wrote: > > commited > > > > http://sourceware.org/ml/gdb-cvs/2011-09/msg00085.html > > Regressed: > FAIL: gdb.python/py-evthreads.exp: Run to breakpoint 1 > FAIL: gdb.python/py-evthreads.exp: reached breakpoint 2 > FAIL: gdb.python/py-evthreads.exp: reached breakpoint 3 > > event type: stop > event type: stop > stop reason: breakpoint > +first breakpoint number: 1 > breakpoint number: 1 > thread num: 1 > -(gdb) PASS: gdb.python/py-evthreads.exp: Run to breakpoint 1 > +(gdb) FAIL: gdb.python/py-evthreads.exp: Run to breakpoint 1 > > I understand gdb.python/py-evthreads.exp has been checked in between your > patch development and its check-in. > > Checked in. > > > Regards, > Jan Thanks for noticing that, Jan, next time I'll double-check that there is no regression at commit time, and not only when the patch is being validated Cordially, Kevin ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2011-09-16 9:07 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <BANLkTik-ffBpfx4BALF5+Y0xSx_NnaCs7g@mail.gmail.com>
2011-04-22 9:34 ` [PATCH] Handle multiple breakpoint hits in Python interface Kevin Pouget
2011-05-19 18:34 ` Tom Tromey
2011-05-23 9:39 ` Kevin Pouget
2011-05-23 10:51 ` Eli Zaretskii
2011-05-23 11:01 ` Kevin Pouget
2011-05-23 11:59 ` Eli Zaretskii
2011-05-27 20:09 ` Tom Tromey
2011-05-30 7:37 ` Kevin Pouget
2011-05-30 7:49 ` Eli Zaretskii
2011-05-30 10:53 ` Kevin Pouget
2011-08-31 17:49 ` Tom Tromey
2011-09-01 8:36 ` Kevin Pouget
2011-09-01 8:52 ` Kevin Pouget
2011-09-01 10:08 ` Pedro Alves
2011-09-01 10:18 ` Eli Zaretskii
2011-09-01 11:41 ` Kevin Pouget
2011-09-01 15:39 ` Pedro Alves
2011-09-01 20:53 ` Eli Zaretskii
2011-09-15 12:34 ` Kevin Pouget
2011-09-16 7:55 ` [commit] gdb.python/py-evthreads.exp regression [Re: [PATCH] Handle multiple breakpoint hits in Python interface] Jan Kratochvil
2011-09-16 9:12 ` Kevin Pouget
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox