Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Patrick Monnerat <patrick@monnerat.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Notify observer of breakpoint auto-disabling
Date: Sat, 14 Aug 2021 00:05:58 -0400	[thread overview]
Message-ID: <3002b4db-52a4-b7a5-ca1a-49398ba439ed@polymtl.ca> (raw)
In-Reply-To: <20210813222411.3076-1-patrick@monnerat.net>

On 2021-08-13 6:24 p.m., Patrick Monnerat via Gdb-patches wrote:
> As observer is currently notified of breakpoint stop before handling its
> auto-disabling after count is reached, the observer is never notified of
> the disabling.
> 
> The problem does not seem to affect gdb alone. However it impacts insight:
> breakpoint GUI window is not properly updated upon auto-disable.
> 
> This patch moves the observer notification after the auto-disabling
> code.
> 
> Fixes https://sourceware.org/bugzilla/show_bug.cgi?id=23336
> 
> * gdb/breakpoint.c (bpstat_stop_status): move observer notification
>   after auto-disabling code.

Note that GDB doesn't use ChangeLogs anymore.

> ---
>  gdb/breakpoint.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index 89af44ee4c6..feca224ccf4 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -5491,7 +5491,6 @@ bpstat_stop_status (const address_space *aspace,
>  	  if (bs->stop)
>  	    {
>  	      ++(b->hit_count);
> -	      gdb::observers::breakpoint_modified.notify (b);
>  
>  	      /* We will stop here.  */
>  	      if (b->disposition == disp_disable)
> @@ -5501,6 +5500,7 @@ bpstat_stop_status (const address_space *aspace,
>  		    b->enable_state = bp_disabled;
>  		  removed_any = 1;
>  		}
> +	      gdb::observers::breakpoint_modified.notify (b);

I looked at the change a bit more in depth, in particular at the various
observers of breakpoint_modified.  One of them is MI, who prints the
=breakpoint-modified notification.  That suggested that your change
would affect that notification in a similar way that insight is
affected.  And indeed, if I run a program with a breakpoint with "enable
count 1 1", the notification I get without your patch is:

  =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="dis",enabled="n",...
                                                                              ^
And with the patch:

  =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="dis",enabled="y",
                                                                              ^

I think the change is desirable in MI for the same reason it is
desirable in insight.  But this means we should add a test for it.
Maybe gdb.mi/mi-breakpoint-changed.exp would be a good place for it.  I
don't think there's an official way to set a count on a breakpoint using
MI.  However, it seems to work through -break-enable, since
-break-enable is implemented on top of the CLI "enable" command.  So
"-break-enable count 1 1" is equivalent to "enable count 1 1".  It's not
documented but...

There is also the Python breakpoint_modified event.  This script:

  def func(bp):
      print(bp.enabled)

  gdb.events.breakpoint_modified.connect(func)

Prints "True" before your patch and "False" after.  We should have a
test for that too, ideally, I guess in gdb.python/py-breakpoint.exp.

Simon

  reply	other threads:[~2021-08-14  4:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 22:24 Patrick Monnerat via Gdb-patches
2021-08-14  4:05 ` Simon Marchi via Gdb-patches [this message]
2021-08-15  0:30   ` Patrick Monnerat via Gdb-patches
  -- strict thread matches above, loose matches on Subject: below --
2021-08-16 12:44 Patrick Monnerat via Gdb-patches
2021-08-16 14:04 ` Simon Marchi via Gdb-patches
2021-08-16 14:09   ` Patrick Monnerat via Gdb-patches
2021-08-16 15:10     ` Simon Marchi via Gdb-patches
2021-08-16 16:18       ` Patrick Monnerat via Gdb-patches
2021-08-15  0:33 Patrick Monnerat via Gdb-patches
2021-08-16  1:32 ` Simon Marchi via Gdb-patches
2021-08-13 15:31 Patrick Monnerat via Gdb-patches
2021-08-13 15:45 ` Simon Marchi via Gdb-patches
2021-08-13 16:27   ` Patrick Monnerat via Gdb-patches
2021-08-13 18:59     ` Simon Marchi via Gdb-patches
2021-08-13 22:15       ` Patrick Monnerat via Gdb-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3002b4db-52a4-b7a5-ca1a-49398ba439ed@polymtl.ca \
    --to=gdb-patches@sourceware.org \
    --cc=patrick@monnerat.net \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox