diff options
author | Hui Li <lihui@loongson.cn> | 2024-06-11 19:21:26 +0800 |
---|---|---|
committer | Tiezhu Yang <yangtiezhu@loongson.cn> | 2024-06-25 05:50:29 +0800 |
commit | 6ced1278fc0078022f73d623702cf4582750f783 (patch) | |
tree | d6cf7eb15ee11a375fac83a29e1ddc20c845577a /include | |
parent | c1cdee0e2c1715718c1e6224038096142ccabe40 (diff) | |
download | binutils-6ced1278fc0078022f73d623702cf4582750f783.zip binutils-6ced1278fc0078022f73d623702cf4582750f783.tar.gz binutils-6ced1278fc0078022f73d623702cf4582750f783.tar.bz2 |
gdb: LoongArch: Add support for hardware breakpoint
LoongArch defines hardware watchpoint functions for fetch operations.
After the software configures the watchpoints for fetch, the processor
hardware will monitor the access addresses of the fetch operations and
trigger a watchpoint exception when the watchpoint setting conditions
are met.
Hardware watchpoints for fetch operations is used to implement hardware
breakpoint function on LoongArch. Refer to the following document for
hardware breakpoint.
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) hbreak 8
No hardware breakpoint support in the target.
with this patch:
lihui@bogon:~$ gdb test
...
(gdb) start
...
Temporary breakpoint 1, main () at test.c:5
5 printf("start test\n");
(gdb) hbreak 8
Hardware assisted breakpoint 2 at 0x1200006ec: file test.c, line 8.
(gdb) c
Continuing.
start test
a = 1
Breakpoint 2, main () at test.c:8
8 printf("end test\n");
(gdb) c
Continuing.
end test
[Inferior 1 (process 25378) exited normally]
Signed-off-by: Hui Li <lihui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Diffstat (limited to 'include')
-rw-r--r-- | include/elf/common.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/elf/common.h b/include/elf/common.h index 2d18334..c9920e7 100644 --- a/include/elf/common.h +++ b/include/elf/common.h @@ -751,6 +751,8 @@ /* note name must be "LINUX". */ #define NT_LARCH_LBT 0xa04 /* LoongArch Binary Translation registers */ /* note name must be "CORE". */ +#define NT_LOONGARCH_HW_BREAK 0xa05 /* LoongArch hardware breakpoint registers */ + /* note name must be "LINUX". */ #define NT_LOONGARCH_HW_WATCH 0xa06 /* LoongArch hardware watchpoint registers */ /* note name must be "LINUX". */ #define NT_RISCV_CSR 0x900 /* RISC-V Control and Status Registers */ |