From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B3F953858C27; Wed, 22 Sep 2021 07:00:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3F953858C27 From: "shivam98.tkg at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug gdb/28371] New: gdb: watchpoint for local variable doesn't work on RISC-V Date: Wed, 22 Sep 2021 07:00:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: shivam98.tkg at gmail 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 attachments.created 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 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Sep 2021 07:00:12 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28371 Bug ID: 28371 Summary: gdb: watchpoint for local variable doesn't work on RISC-V Product: gdb Version: unknown Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: shivam98.tkg at gmail dot com Target Milestone: --- Created attachment 13674 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D13674&action=3Ded= it test program Please consider the following program :- 1 /* This testcase is part of GDB, the GNU debugger. 2=20 3 Copyright 2010-2021 Free Software Foundation, Inc. 4=20 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3 of the License, or 8 (at your option) any later version. 9=20 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14=20 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see = .=20 */ 17=20 18 int global =3D 0; 19 int global2 =3D 0; 20=20 21 int func(int *foo) 22 { 23 (*foo)++; 24 global++; 25 global2++; 26 return 0; 27 } 28=20 29 void func2(int *foo) 30 { 31 global2++; 32 } 33=20 34 int main() 35 { 36 int q =3D 0; 37=20 38 func2 (&q); 39 global2++; 40=20 41 while (1) 42 { 43 func(&q); 44 } 45=20 46 return 0; 47 } Steps to produce the issue :-=20 clang -g -static watch-cond.c -o watch (clang is cross compile by following these instruction :- https://github.com/sifive/riscv-llvm#how-can-i-build-llvmclang-and-use-it-t= o-cross-compile-for-a-riscv-target) qemu-riscv64 -g 1234 watch-cond (start the server) riscv64-unknown-elf-gdb watch-cond (start client) (gdb) target remote :1234 Remote debugging using :1234 0x00000000000100f8 in _start () (gdb) set can-use-hw-watchpoints 0 (gdb) b 36 Breakpoint 1 at 0x101e0: file watch-cond.c, line 36. (gdb) n Single stepping until exit from function _start, which has no line number information. Breakpoint 1, main () at watch-cond.c:36 36 int q =3D 0; (gdb) watch q Watchpoint 2: q (gdb) c Continuing. Watchpoint 2 deleted because the program has left the block in which its expression is valid. 0x00000000000101cc in func2 (foo=3D0x0) at watch-cond.c:32 32 } (gdb) disass main Dump of assembler code for function main: 0x00000000000101a0 <+0>: addi sp,sp,-32 0x00000000000101a2 <+2>: sd ra,24(sp) 0x00000000000101a4 <+4>: sd s0,16(sp) 0x00000000000101a6 <+6>: addi s0,sp,32 0x00000000000101a8 <+8>: li a0,0 0x00000000000101aa <+10>: sw a0,-20(s0) 0x00000000000101ae <+14>: sw a0,-24(s0) 0x00000000000101b2 <+18>: j 0x101b6 0x00000000000101b6 <+22>: lw a1,-24(s0) 0x00000000000101ba <+26>: li a0,4 0x00000000000101bc <+28>: blt a0,a1,0x101d0 0x00000000000101c0 <+32>: j 0x101c4 0x00000000000101c4 <+36>: addi a0,s0,-24 0x00000000000101c8 <+40>: jal ra,0x10180 0x00000000000101cc <+44>: j 0x101b6 0x00000000000101d0 <+48>: li a0,0 0x00000000000101d2 <+50>: ld s0,16(sp) 0x00000000000101d4 <+52>: ld ra,24(sp) 0x00000000000101d6 <+54>: addi sp,sp,32 0x00000000000101d8 <+56>: ret End of assembler dump. (gdb) p &q $1 =3D (int *) 0x40008001d8 (gdb) info frame Stack level 0, frame at 0x40008001f0: pc =3D 0x101e0 in main (watch-cond.c:36); saved pc =3D 0x10134 source language c. Arglist at 0x40008001f0, args:=20 Locals at 0x40008001f0, Previous frame's sp is 0x40008001f0 Saved registers: ra at 0x40008001e8, fp at 0x40008001e0, pc at 0x40008001e8Could not fetch register "ustatus"; remote failure reply 'E14' objdump --disassemble watch-cond 00000000000101d2
: 101d2: 01 11 addi sp, sp, -32 101d4: 06 ec sd ra, 24(sp) 101d6: 22 e8 sd s0, 16(sp) 101d8: 00 10 addi s0, sp, 32 101da: 01 45 mv a0, zero 101dc: 23 26 a4 fe sw a0, -20(s0) 101e0: 23 24 a4 fe sw a0, -24(s0) 101e4: 13 05 84 fe addi a0, s0, -24 101e8: ef f0 df fc jal 0x101b4 101ec: 03 a5 41 f6 lw a0, -156(gp) 101f0: 05 25 addiw a0, a0, 1 101f2: 23 a2 a1 f6 sw a0, -156(gp) 101f6: 6f 00 40 00 j 0x101fa 101fa: 13 05 84 fe addi a0, s0, -24 101fe: ef f0 3f f8 jal 0x10180 10202: 6f f0 9f ff j 0x101fa I tested same the program debugging, compiled with gcc compiler, working fi= ne. --=20 You are receiving this mail because: You are on the CC list for the bug.=