diff options
author | Hui Li <lihui@loongson.cn> | 2024-07-30 19:41:05 +0800 |
---|---|---|
committer | Tiezhu Yang <yangtiezhu@loongson.cn> | 2024-08-01 22:23:44 +0800 |
commit | 94223333026f06dc5d78266dd9b6082544641f07 (patch) | |
tree | 1934231759f07f3ae600ddbcafc2d20e51238c2a | |
parent | 479c61163612f37d853efd21c40963459ef611d4 (diff) | |
download | gdb-94223333026f06dc5d78266dd9b6082544641f07.zip gdb-94223333026f06dc5d78266dd9b6082544641f07.tar.gz gdb-94223333026f06dc5d78266dd9b6082544641f07.tar.bz2 |
gdb: LoongArch: Add show-debug-regs maintenance command
This patch register the command "maint set show-debug-regs on/off"
and make it settable by the user. If show-debug-regs is enabled,
the debug register values are shown when GDB inserts or removes a
hardware breakpoint or watchpoint. This is helpful for the use and
development of hardware watchpoints.
With this patch, the effect of this maintenance command as follows:
lihui@bogon:~$ cat test.c
int a = 0;
int main()
{
a = 1;
return 0;
}
lihui@bogon:~$ gcc -g test.c -o test
lihui@bogon:~$ gdb test
...
(gdb) watch a
Hardware watchpoint 1: a
(gdb) maint set show-debug-regs on
(gdb) r
Starting program: /home/lihui/test
...
...
prepare_to_resume thread 41525
...
insert_watchpoint (addr=0x12000803c, len=4, type=hw-write-watchpoint):
BREAKPOINTs:
BP0: addr=0x0, ctrl=0x00000000, ref.count=0
BP1: addr=0x0, ctrl=0x00000000, ref.count=0
BP2: addr=0x0, ctrl=0x00000000, ref.count=0
BP3: addr=0x0, ctrl=0x00000000, ref.count=0
BP4: addr=0x0, ctrl=0x00000000, ref.count=0
BP5: addr=0x0, ctrl=0x00000000, ref.count=0
BP6: addr=0x0, ctrl=0x00000000, ref.count=0
BP7: addr=0x0, ctrl=0x00000000, ref.count=0
WATCHPOINTs:
WP0: addr=0x0, ctrl=0x00000000, ref.count=0
WP1: addr=0x0, ctrl=0x00000000, ref.count=0
WP2: addr=0x0, ctrl=0x00000000, ref.count=0
WP3: addr=0x0, ctrl=0x00000000, ref.count=0
WP4: addr=0x0, ctrl=0x00000000, ref.count=0
WP5: addr=0x0, ctrl=0x00000000, ref.count=0
WP6: addr=0x0, ctrl=0x00000000, ref.count=0
WP7: addr=0x12000803c, ctrl=0x00000610, ref.count=1
...
remove_watchpoint (addr=0x12000803c, len=4, type=hw-write-watchpoint):
BREAKPOINTs:
BP0: addr=0x0, ctrl=0x00000000, ref.count=0
BP1: addr=0x0, ctrl=0x00000000, ref.count=0
BP2: addr=0x0, ctrl=0x00000000, ref.count=0
BP3: addr=0x0, ctrl=0x00000000, ref.count=0
BP4: addr=0x0, ctrl=0x00000000, ref.count=0
BP5: addr=0x0, ctrl=0x00000000, ref.count=0
BP6: addr=0x0, ctrl=0x00000000, ref.count=0
BP7: addr=0x0, ctrl=0x00000000, ref.count=0
WATCHPOINTs:
WP0: addr=0x0, ctrl=0x00000000, ref.count=0
WP1: addr=0x0, ctrl=0x00000000, ref.count=0
WP2: addr=0x0, ctrl=0x00000000, ref.count=0
WP3: addr=0x0, ctrl=0x00000000, ref.count=0
WP4: addr=0x0, ctrl=0x00000000, ref.count=0
WP5: addr=0x0, ctrl=0x00000000, ref.count=0
WP6: addr=0x0, ctrl=0x00000000, ref.count=0
WP7: addr=0x0, ctrl=0x00000000, ref.count=0
Hardware watchpoint 1: a
Old value = 0
New value = 1
main () at test.c:5
5 return 0;
(gdb)
Signed-off-by: Hui Li <lihui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
-rw-r--r-- | gdb/loongarch-linux-nat.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gdb/loongarch-linux-nat.c b/gdb/loongarch-linux-nat.c index 8736287..bc9927d 100644 --- a/gdb/loongarch-linux-nat.c +++ b/gdb/loongarch-linux-nat.c @@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "cli/cli-cmds.h" #include "elf/common.h" #include "gregset.h" #include "inferior.h" @@ -765,4 +766,19 @@ _initialize_loongarch_linux_nat () { linux_target = &the_loongarch_linux_nat_target; add_inf_child_target (&the_loongarch_linux_nat_target); + + /* Add a maintenance command to enable printing the LoongArch internal + debug registers mirror variables. */ + add_setshow_boolean_cmd ("show-debug-regs", class_maintenance, + &show_debug_regs, _("\ +Set whether to show the LoongArch debug registers state."), _("\ +Show whether to show the LoongArch debug registers state."), _("\ +Use \"on\" to enable, \"off\" to disable.\n\ +If enabled, the debug registers values are shown when GDB inserts\n\ +or removes a hardware breakpoint or watchpoint, and when the inferior\n\ +triggers a breakpoint or watchpoint."), + NULL, + NULL, + &maintenance_set_cmdlist, + &maintenance_show_cmdlist); } |