public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "joe at lothan dot net" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug breakpoints/30335] New: Watchpoints aren't triggered when calling program functions Date: Tue, 11 Apr 2023 16:15:18 +0000 [thread overview] Message-ID: <bug-30335-4717@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=30335 Bug ID: 30335 Summary: Watchpoints aren't triggered when calling program functions Product: gdb Version: HEAD Status: UNCONFIRMED Severity: normal Priority: P2 Component: breakpoints Assignee: unassigned at sourceware dot org Reporter: joe at lothan dot net Target Milestone: --- Build: Current When calling program functions using `call` or `print`, existing watchpoints are not triggered even if the value changes. For example: $ cat test.c #include <stdio.h> int towatch = 0; void change_var() { towatch ++; printf("new towatch: %d\n", towatch); } int main() { for (int i = 0; i < 5; i++) change_var(); } $ gcc -g -o test test.c $ ./test new towatch: 1 new towatch: 2 new towatch: 3 new towatch: 4 new towatch: 5 $ gdb ./test GNU gdb (GDB) 14.0.50.20230411-git Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./test... (gdb) break main Breakpoint 1 at 0x118b: file test.c, line 11. (gdb) run Starting program: /home/joe/test [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Breakpoint 1, main () at test.c:11 11 for (int i = 0; i < 5; i++) (gdb) watch towatch Hardware watchpoint 2: towatch (gdb) p towatch $1 = 0 (gdb) # I'd expect the watchpoint to trigger with the following call, but it doesn't (gdb) call change_var() new towatch: 1 (gdb) p towatch $2 = 1 (gdb) continue Continuing. Hardware watchpoint 2: towatch Old value = 0 New value = 2 change_var () at test.c:7 7 printf("new towatch: %d\n", towatch); This also happens if I pass the `-location` parameter with `watch`: $ gdb -q ./test Reading symbols from ./test... (gdb) break main Breakpoint 1 at 0x118b: file test.c, line 11. (gdb) run Starting program: /home/joe/test [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Breakpoint 1, main () at test.c:11 11 for (int i = 0; i < 5; i++) (gdb) watch -location towatch Hardware watchpoint 2: -location towatch (gdb) call change_var() new towatch: 1 (gdb) And when using a software watchpoints: $ gdb -q ./test Reading symbols from ./test... (gdb) break main Breakpoint 1 at 0x118b: file test.c, line 11. (gdb) run Starting program: /home/joe/test [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Breakpoint 1, main () at test.c:11 11 for (int i = 0; i < 5; i++) (gdb) show can-use-hw-watchpoints Debugger's willingness to use watchpoint hardware is 1. (gdb) set can-use-hw-watchpoints 0 (gdb) watch towatch Watchpoint 2: towatch (gdb) i breakpoints 2 Num Type Disp Enb Address What 2 watchpoint keep y towatch (gdb) call change_var() new towatch: 1 (gdb) Thanks to tromey and BigKnife for the help in #gdb. First time submitting a bug in gdb, can provide more info if need be. Cheers, Joe Environment: gdb version 14.0.50.20230411-git gdb configuration x86_64-pc-linux-gnu Ubuntu 22.04.1 LTS Linux 5.15.0-58-generic gcc version 11.3.0 -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2023-04-11 16:15 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-04-11 16:15 joe at lothan dot net [this message] 2023-04-11 16:39 ` [Bug breakpoints/30335] " joe at lothan 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-30335-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: linkBe 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).