public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug breakpoints/27423] New: Watchpoint could be hw but is sw
@ 2021-02-15 15:36 vries at gcc dot gnu.org
  2021-02-15 16:19 ` [Bug breakpoints/27423] " vries at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2021-02-15 15:36 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 27423
           Summary: Watchpoint could be hw but is sw
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: breakpoints
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

Consider the same test-case as in PR27422.

Now consider the following 4 scenarios.


I. b 20, watch address:
...
$ gdb -iex "set trace-commands on" -batch a.out -ex "b 20" -ex run -ex "watch
*(int *)0x602260" -ex cont -ex "info break"
+b 20
Breakpoint 1 at 0x4005c5: file test.c, line 20.
+run

Breakpoint 1, main () at test.c:20
20        printf ("%p\n", ap);
+watch *(int *)0x602260
Hardware watchpoint 2: *(int *)0x602260
+cont
0x602260

Hardware watchpoint 2: *(int *)0x602260

Old value = 1
New value = 0
main () at test.c:22
22        a = 0;
+info break
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x00000000004005c5 in main at test.c:20
        breakpoint already hit 1 time
2       hw watchpoint  keep y                      *(int *)0x602260
        breakpoint already hit 1 time
...


II. b 20, watch expression:
...
$ gdb -iex "set trace-commands on" -batch a.out -ex "b 20" -ex run -ex "watch
*(int *)0x602260 == 0" -ex cont -ex "info break"
+b 20
Breakpoint 1 at 0x4005c5: file test.c, line 20.
+run

Breakpoint 1, main () at test.c:20
20        printf ("%p\n", ap);
+watch *(int *)0x602260 == 0
Hardware watchpoint 2: *(int *)0x602260 == 0
+cont
0x602260

Hardware watchpoint 2: *(int *)0x602260 == 0

Old value = 0
New value = 1
main () at test.c:22
22        a = 0;
+info break
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x00000000004005c5 in main at test.c:20
        breakpoint already hit 1 time
2       hw watchpoint  keep y                      *(int *)0x602260 == 0
        breakpoint already hit 1 time
...


III. b 18, watch address:
...
$ gdb -iex "set trace-commands on" -batch a.out -ex "b 18" -ex run -ex "watch
*(int *)0x602260" -ex cont -ex "info break"       
+b 18
Breakpoint 1 at 0x4005ad: file test.c, line 18.
+run

Breakpoint 1, main () at test.c:18
18        int *ap = malloc (sizeof(int));
+watch *(int *)0x602260
Hardware watchpoint 2: *(int *)0x602260
+cont

Hardware watchpoint 2: *(int *)0x602260

Old value = <unreadable>
New value = 1
main () at test.c:20
20        printf ("%p\n", ap);
+info break
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x00000000004005ad in main at test.c:18
        breakpoint already hit 1 time
2       hw watchpoint  keep y                      *(int *)0x602260
        breakpoint already hit 1 time
...


IV. b 18, watch expression:
...
$ gdb -iex "set trace-commands on" -batch a.out -ex "b 18" -ex run -ex "watch
*(int *)0x602260 == 0" -ex cont -ex "info break"
+b 18
Breakpoint 1 at 0x4005ad: file test.c, line 18.
+run

Breakpoint 1, main () at test.c:18
18        int *ap = malloc (sizeof(int));
+watch *(int *)0x602260 == 0
Watchpoint 2: *(int *)0x602260 == 0
+cont

Watchpoint 2: *(int *)0x602260 == 0

Old value = <unreadable>
New value = 1
0x00007ffff7b0e9a9 in __brk (addr=addr@entry=0x623000) at
../sysdeps/unix/sysv/linux/x86_64/brk.c:31
31        __curbrk = newbrk = (void *) INLINE_SYSCALL (brk, 1, addr);
+info break
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x00000000004005ad in main at test.c:18
        breakpoint already hit 1 time
2       watchpoint     keep y                      *(int *)0x602260 == 0
        breakpoint already hit 1 time
...

We have a hw breakpoint in all cases, except case IV.

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

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

end of thread, other threads:[~2021-02-15 20:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-15 15:36 [Bug breakpoints/27423] New: Watchpoint could be hw but is sw vries at gcc dot gnu.org
2021-02-15 16:19 ` [Bug breakpoints/27423] " vries at gcc dot gnu.org
2021-02-15 18:48 ` vries at gcc dot gnu.org
2021-02-15 18:51 ` vries at gcc dot gnu.org
2021-02-15 20:09 ` vries at gcc dot gnu.org

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