public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug breakpoints/30233] New: Hardware watchpoint works as software
@ 2023-03-15  7:02 alexey.lapshin at espressif dot com
  0 siblings, 0 replies; only message in thread
From: alexey.lapshin at espressif dot com @ 2023-03-15  7:02 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 30233
           Summary: Hardware watchpoint works as software
           Product: gdb
           Version: 13.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: breakpoints
          Assignee: unassigned at sourceware dot org
          Reporter: alexey.lapshin at espressif dot com
  Target Milestone: ---

Test code:

```
// file: test.c

static volatile int var = 0;
void main()
{
    while(1) {
        var++;
    }
}
```

Build command: gcc -Og -g test.c

If execute gdb and set watchpoint to var I get this:

```
Reading symbols from a.out...
(gdb) watch var 
Hardware watchpoint 1: var
(gdb) run
Starting program: /home/alex/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Hardware watchpoint 1: var

Old value = 0
New value = 1
main () at hello_world_main.c:4
4           while(1) {
(gdb) x/i $pc
=> 0x401115 <main+15>:  jmp    0x401106 <main>
(gdb) 
```

GDB pointed to a wrong instruction and as a result to the wrong line.

From the documentation
(https://sourceware.org/gdb/download/onlinedocs/gdb/Set-Watchpoints.html):

```
Hardware watchpoints execute very quickly, and the debugger reports a change in
value at the exact instruction where the change occurs.

software watchpoint, which executes more slowly and reports the change in value
at the next statement, not the instruction, after the change occurs.
```

- why gdb does not stop on the variable change instruction?
- how make sure that was set exactly hardware watchpoint (not software)?

Also, I did not find any related testcase in gdb tests...


Tested with gdb 12.2 and 13.1 (Ubuntu distributives)

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-15  7:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15  7:02 [Bug breakpoints/30233] New: Hardware watchpoint works as software alexey.lapshin at espressif dot com

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