diff options
author | Hui Li <lihui@loongson.cn> | 2024-06-11 19:21:25 +0800 |
---|---|---|
committer | Tiezhu Yang <yangtiezhu@loongson.cn> | 2024-06-25 05:50:08 +0800 |
commit | c1cdee0e2c1715718c1e6224038096142ccabe40 (patch) | |
tree | 1e50ae293e34a0f0bde9f21c71fc68a956cb24ed /gdb/Makefile.in | |
parent | 5ae5974d60378fa3faecff64725e00c8695bcc7d (diff) | |
download | binutils-c1cdee0e2c1715718c1e6224038096142ccabe40.zip binutils-c1cdee0e2c1715718c1e6224038096142ccabe40.tar.gz binutils-c1cdee0e2c1715718c1e6224038096142ccabe40.tar.bz2 |
gdb: LoongArch: Add support for hardware watchpoint
LoongArch defines hardware watchpoint functions for load/store
operations. After the software configures the watchpoints for
load/store, the processor hardware will monitor the access
addresses of the load/store operations and trigger watchpoint
exception when the watchpoint setting conditions are met.
After this patch, watch/rwatch/awatch command are supported. Refer to the
following document for hardware watchpoint.
https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#control-and-status-registers-related-to-watchpoints
A simple test is as follows:
lihui@bogon:~$ cat test.c
#include <stdio.h>
int a = 0;
int main()
{
printf("start test\n");
a = 1;
printf("a = %d\n", a);
printf("end test\n");
return 0;
}
lihui@bogon:~$ gcc -g test.c -o test
without this patch:
lihui@bogon:~$ gdb test
...
(gdb) start
...
Temporary breakpoint 1, main () at test.c:5
5 printf("start test\n");
(gdb) awatch a
Target does not support this type of hardware watchpoint.
...
with this patch:
lihui@bogon:~$ gdb test
...
(gdb) start
...
Temporary breakpoint 1, main () at test.c:5
5 printf("start test\n");
(gdb) awatch a
Hardware access (read/write) watchpoint 2: a
(gdb) c
Continuing.
start test
Hardware access (read/write) watchpoint 2: a
Old value = 0
New value = 1
main () at test.c:7
7 printf("a = %d\n", a);
(gdb) c
Continuing.
Hardware access (read/write) watchpoint 2: a
Value = 1
0x00000001200006e0 in main () at test.c:7
7 printf("a = %d\n", a);
(gdb) c
Continuing.
a = 1
end test
[Inferior 1 (process 22250) exited normally]
Signed-off-by: Hui Li <lihui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Diffstat (limited to 'gdb/Makefile.in')
-rw-r--r-- | gdb/Makefile.in | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 6f7f2af..1c697bf 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1608,6 +1608,9 @@ HFILES_NO_SRCDIR = \ nat/linux-personality.h \ nat/linux-ptrace.h \ nat/linux-waitpid.h \ + nat/loongarch-hw-point.h \ + nat/loongarch-linux.h \ + nat/loongarch-linux-hw-point.h \ nat/mips-linux-watch.h \ nat/ppc-linux.h \ nat/x86-cpuid.h \ |