<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - gdb: watchpoint for local variable doesn't work on RISC-V"
href="https://bugs.llvm.org/show_bug.cgi?id=51864">51864</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>gdb: watchpoint for local variable doesn't work on RISC-V
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: RISC-V
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>shivam98.tkg@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>asb@lowrisc.org, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=25258" name="attach_25258" title="This is test file to reproduce the bug">attachment 25258</a> <a href="attachment.cgi?id=25258&action=edit" title="This is test file to reproduce the bug">[details]</a></span>
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 <<a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>>.
*/
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 :-
<a href="https://github.com/sifive/riscv-llvm#how-can-i-build-llvmclang-and-use-it-to-cross-compile-for-a-riscv-target">https://github.com/sifive/riscv-llvm#how-can-i-build-llvmclang-and-use-it-to-cross-compile-for-a-riscv-target</a>)
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>