From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 054483858D39; Wed, 15 Mar 2023 07:02:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 054483858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678863756; bh=hI9QGoOyvIWNt9IHnjDC1kIAA7i3CClYo1YZkwIgHEY=; h=From:To:Subject:Date:From; b=SFbVV2Z+gweHCaomWHBBXRCytHHT2fLx9BUsZa9VVLT1NkVEOGk0lqIiMVKavwoqP rtO1akwdEa2ax4GQR60DGglVct9auPrYFYd3tgL1zmVO4U1OtZcyY9pmOm8FIK7aW6 DyIEdOhsHGc1/HrQIvj7qri8HP5oS43iG0mN4JFA= From: "alexey.lapshin at espressif dot com" To: gdb-prs@sourceware.org Subject: [Bug breakpoints/30233] New: Hardware watchpoint works as software Date: Wed, 15 Mar 2023 07:02:35 +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: 13.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: alexey.lapshin at espressif dot com 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 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=3D30233 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 =3D 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=20 Hardware watchpoint 1: var (gdb) run Starting program: /home/alex/a.out=20 [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 =3D 0 New value =3D 1 main () at hello_world_main.c:4 4 while(1) { (gdb) x/i $pc =3D> 0x401115 : jmp 0x401106
(gdb)=20 ``` 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 chang= e in value at the exact instruction where the change occurs. software watchpoint, which executes more slowly and reports the change in v= alue 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) --=20 You are receiving this mail because: You are on the CC list for the bug.=