public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "pedro at palves dot net" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/31521] New: Can't set watchpoints when current thread is running
Date: Thu, 21 Mar 2024 15:50:24 +0000	[thread overview]
Message-ID: <bug-31521-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=31521

            Bug ID: 31521
           Summary: Can't set watchpoints when current thread is running
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: pedro at palves dot net
  Target Milestone: ---

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.

I have a patch that makes setting the watchpoint work.  You'll get instead:

 (gdb) c&
 Continuing.
 (gdb) [New Thread 0x7ffff7d6e640 (LWP 434993)]
 [New Thread 0x7ffff756d640 (LWP 434994)]
 p global
 $1 = 88168
 (gdb) watch global
 Hardware watchpoint 2: global
 (gdb) [Switching to Thread 0x7ffff7d6e640 (LWP 434993)]

 Thread 2 "function0" hit Hardware watchpoint 2: global

 Old value = 185420
 New value = 185423
 int_return () at threads.c:39
 39      }

Software watchpoints require more fixing, as the succesfully set sw watchpoint
doesn't fire.  GDB needs to force the running-free thread to pause and switch
to single-stepping to make that work.  Software watchpoints have general design
issues with multi-threading, though, so that's just yet another issue for the
pile.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2024-03-21 15:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-21 15:50 pedro at palves dot net [this message]
2024-03-21 15:51 ` [Bug gdb/31521] " pedro at palves dot net

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=bug-31521-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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).