aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorThiago Jung Bauermann <thiago.bauermann@linaro.org>2024-09-05 01:42:02 -0300
committerThiago Jung Bauermann <thiago.bauermann@linaro.org>2024-09-24 15:16:11 -0300
commit94aedcf7ea5b1dbd8bf79247a8ed247b75b3dfb0 (patch)
treeea24b7e576f0f57e14f955b1507f605227efa625 /gdb/testsuite
parent89320f8658db71ae42c6f5f356fda48f9780be9c (diff)
downloadbinutils-94aedcf7ea5b1dbd8bf79247a8ed247b75b3dfb0.zip
binutils-94aedcf7ea5b1dbd8bf79247a8ed247b75b3dfb0.tar.gz
binutils-94aedcf7ea5b1dbd8bf79247a8ed247b75b3dfb0.tar.bz2
gdb: testsuite: Test whether PC register is expedited in gdb.server/server-run.exp
One thing GDB always does when the inferior stops is finding out where it's stopped at, by way of querying the value of the program counter register. To save a packet round trip, the remote target can send the PC value (often alongside other frequently consulted registers such as the stack pointer) in the stop reply packet as an "expedited register". Test that this is actually done for the targets where gdbserver is supposed to. Extend the "maintenance print remote-registers" command output with an "Expedited" column which says "yes" if the register was seen by GDB in the last stop reply packet it received, and is left blank otherwise. Tested for regressions on aarch64-linux-gnu native-extended-remote. The testcase was tested on aarch64-linux-gnu, i686-linux-gnu and x86_64-linux-gnu native-remote and native-extended-remote targets. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.server/server-run.exp33
1 files changed, 33 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.server/server-run.exp b/gdb/testsuite/gdb.server/server-run.exp
index 92eb38b..af5a5f5 100644
--- a/gdb/testsuite/gdb.server/server-run.exp
+++ b/gdb/testsuite/gdb.server/server-run.exp
@@ -52,3 +52,36 @@ if { [istarget *-*-linux*] } {
gdb_breakpoint main
gdb_test "continue" "Breakpoint.* main .*" "continue to main"
+
+if { [istarget "aarch64*-*-*"]
+ || [istarget "arm*-*-*"]
+ || [istarget "csky*-*-*"]
+ || [istarget "loongarch*-*-*"]
+ || [istarget "riscv*-*-*"] } {
+ set pc_regname "pc"
+} elseif { [is_amd64_regs_target] } {
+ set pc_regname "rip"
+} elseif { [is_x86_like_target] } {
+ set pc_regname "eip"
+} elseif { [istarget "tic6x-*-*"] } {
+ set pc_regname "PC"
+}
+
+# Sending the PC register in advance is good practice. Test that this is
+# actually done for the targets where gdbserver is supposed to.
+set expedited_pc_test_name "send PC as expedited register in stop reply"
+if { [info exists pc_regname] } {
+ set seen_line false
+ gdb_test_multiple "maintenance print remote-registers" \
+ $expedited_pc_test_name -lbl {
+ -re " ${pc_regname}\[\[:space:\]\]+${decimal}.*${decimal} yes" {
+ set seen_line true
+ exp_continue
+ }
+ -re "\r\n$gdb_prompt $" {
+ gdb_assert { $seen_line } $gdb_test_name
+ }
+ }
+} else {
+ untested $expedited_pc_test_name
+}