public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Pedro Alves <pedro@palves.net>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix setting watchpoints when current thread is running (PR gdb/31521)
Date: Thu, 21 Mar 2024 19:11:19 +0200	[thread overview]
Message-ID: <86o7b71pe0.fsf@gnu.org> (raw)
In-Reply-To: <20240321164331.967577-1-pedro@palves.net> (message from Pedro Alves on Thu, 21 Mar 2024 16:43:31 +0000)

> From: Pedro Alves <pedro@palves.net>
> Date: Thu, 21 Mar 2024 16:43:31 +0000
> 
> Currently, when the current thread is running, you can print global
> variables.  However, if you try to set a watchpoint on the same
> globals, GDB errors out, complaining that the selected thread is
> running.  Like so:
> 
>  (gdb) c&
>  Continuing.
>  (gdb) p global
>  $1 = 1098377287
>  (gdb) watch global
>  Selected thread is running.
> 
> This patch makes setting the watchpoint work.  The problem is that
> update_watchpoint calls get_selected_frame unconditionally.  We can
> skip it if the watchpoint expression is only watching globals.

What does this mean in practice?  E.g., suppose GDB sets the
watchpoint when the selected thread is changing the variable to be
watched -- will the thread stop or won't it?  IOW, I don't understand
what happens with programming the debug registers while some thread is
running.

> New NEWS blurb added.  I don't think we need to change anything in the
> manual.

If this is deemed a bugfix, then we don't need to say anything in
NEWS, either, IMO.

> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -28,6 +28,11 @@ maintenance info line-table
>    if the line is considered the start of the epilgoue, and thus a point at
>    which the frame can be considered destroyed.
>  
> +watch
> +awatch
> +rwatch
> +  GDB now lets you set a watchpoint even if the selected thread is running.
> +

Reviewed-By: Eli Zaretskii <eliz@gnu.org>

  reply	other threads:[~2024-03-21 17:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-21 16:43 Pedro Alves
2024-03-21 17:11 ` Eli Zaretskii [this message]
2024-03-21 18:38   ` Pedro Alves
2024-04-12 17:57     ` Pedro Alves
2024-05-07  8:46       ` Tom de Vries
2024-05-07 10:30         ` Pedro Alves

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=86o7b71pe0.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).