From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A3E0C3858D28; Tue, 11 Apr 2023 16:15:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3E0C3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681229718; bh=maOlTrdN74x9TWKbD9YIgFsgbOpWjbOCCZOJd+gTiB8=; h=From:To:Subject:Date:From; b=wHxcEaX7oVgIqmf9te74nNiUKWT+zMcHcWsPN0I2K57r+GCWrLWcAPVbD+0fKAc6y 5jSZNBpSdcH42guknxaL50EtBuyMahfPkWsYOzrftSv+rsfgqLD6MI+Fg3d49e8+er OrZb7TpVrXCnpULps+LlqTIewpcR1gYHtFyjq2ps= From: "joe at lothan dot net" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: breakpoints X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: joe at lothan dot net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone cf_gccbuild Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30335 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 int towatch =3D 0; void change_var() { towatch ++; printf("new towatch: %d\n", towatch); } int main() { for (int i =3D 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 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: . Find the GDB manual and other documentation resources online at: . 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 =3D 0; i < 5; i++) (gdb) watch towatch Hardware watchpoint 2: towatch (gdb) p towatch $1 =3D 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 =3D 1 (gdb) continue Continuing. Hardware watchpoint 2: towatch Old value =3D 0 New value =3D 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`:=20 $ 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 =3D 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:=20 $ 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 =3D 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 --=20 You are receiving this mail because: You are on the CC list for the bug.=