[llvm-bugs] [Bug 51864] New: gdb: watchpoint for local variable doesn't work on RISC-V

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 14 19:52:45 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51864

            Bug ID: 51864
           Summary: gdb: watchpoint for local variable doesn't work on
                    RISC-V
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: RISC-V
          Assignee: unassignedbugs at nondot.org
          Reporter: shivam98.tkg at gmail.com
                CC: asb at lowrisc.org, llvm-bugs at lists.llvm.org

Created attachment 25258
  --> https://bugs.llvm.org/attachment.cgi?id=25258&action=edit
This is test file to reproduce the bug

Please consider the following program :-

  1 /* This testcase is part of GDB, the GNU debugger.
  2 
  3    Copyright 2010-2021 Free Software Foundation, Inc.
  4 
  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 
 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 
 15    You should have received a copy of the GNU General Public License
 16    along with this program.  If not, see <http://www.gnu.org/licenses/>. 
*/
 17 
 18 int global = 0;
 19 int global2 = 0;
 20 
 21 int func(int *foo)
 22 {
 23   (*foo)++;
 24   global++;
 25   global2++;
 26   return 0;
 27 }
 28 
 29 void func2(int *foo)
 30 {
 31   global2++;
 32 }
 33 
 34 int main()
 35 {
 36   int q = 0;
 37 
 38   func2 (&q);
 39   global2++;
 40 
 41   while (1)
 42     {
 43       func(&q);
 44     }
 45 
 46   return 0;
 47 }

Steps to produce the issue :- 

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-to-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 = 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=0x0) at watch-cond.c:32
32      }
(gdb) 

I tested same the program debugging, compiled with gcc compiler, working fine.

Does someone have some hint where maybe the issue, I can try to fix.
Thanks.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210915/f51a516c/attachment.html>


More information about the llvm-bugs mailing list