public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/31521] New: Can't set watchpoints when current thread is running
@ 2024-03-21 15:50 pedro at palves dot net
  2024-03-21 15:51 ` [Bug gdb/31521] " pedro at palves dot net
  0 siblings, 1 reply; 2+ messages in thread
From: pedro at palves dot net @ 2024-03-21 15:50 UTC (permalink / raw)
  To: gdb-prs

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug gdb/31521] Can't set watchpoints when current thread is running
  2024-03-21 15:50 [Bug gdb/31521] New: Can't set watchpoints when current thread is running pedro at palves dot net
@ 2024-03-21 15:51 ` pedro at palves dot net
  0 siblings, 0 replies; 2+ messages in thread
From: pedro at palves dot net @ 2024-03-21 15:51 UTC (permalink / raw)
  To: gdb-prs

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

Pedro Alves <pedro at palves dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at sourceware dot org   |pedro at palves dot net

--- Comment #1 from Pedro Alves <pedro at palves dot net> ---
Got patch.

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-21 15:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-21 15:50 [Bug gdb/31521] New: Can't set watchpoints when current thread is running pedro at palves dot net
2024-03-21 15:51 ` [Bug gdb/31521] " pedro at palves dot net

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).