gdb/testsuite: Handle targets with lots of registers
authorAndrew Burgess <andrew.burgess@embecosm.com>
Sun, 8 Apr 2018 23:18:34 +0000 (00:18 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 4 May 2018 14:38:18 +0000 (15:38 +0100)
In gdb.base/maint.exp a test calls 'maint print registers'.  If the
target has lots of registers this may overflow expect's buffers,
causing the test to fail.

After this commit we process the output line at a time until we get back
to the GDB prompt, this should prevent buffer overrun while still
testing that the command works as required.

gdb/testsuite/ChangeLog:

* gdb.base/maint.exp: Process output from 'maint print registers'
line at a time.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/maint.exp

index a66b8cc4173ac44040da57c733f21b0458a5ccdd..73c4a2ca6c260794967956e6d485ba144aeb6df5 100644 (file)
@@ -1,3 +1,8 @@
+2018-05-04  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * gdb.base/maint.exp: Process output from 'maint print registers'
+       line at a time.
+
 2018-05-04  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * lib/mi-support.exp (mi_run_cmd_full): Fix regexp and add a
index 93221085653c2a62dc9b88bd8e77d539ad6f869f..f576cb384025ca3673f89b543a5a6e571c08dbff 100644 (file)
@@ -62,8 +62,28 @@ gdb_test_no_output "set height 0"
 gdb_file_cmd ${binfile}
 
 # Test for a regression where this command would internal-error if the
-# program wasn't running.
-gdb_test "maint print registers" "Name.*Nr.*Rel.*Offset.*Size.*Type.*"
+# program wasn't running.  If there's a lot of registers then this
+# might overflow expect's buffers, so process the output line at a
+# time.
+set saw_registers 0
+set saw_headers 0
+set test "maint print registers"
+gdb_test_multiple $test $test {
+    -re "\[^\r\n\]+Name\[^\r\n\]+Nr\[^\r\n\]+Rel\[^\r\n\]+Offset\[^\r\n\]+Size\[^\r\n\]+Type\[^\r\n\]+\[\r\n\]+" {
+       set saw_headers 1
+       exp_continue
+    }
+    -re "^\[^\r\n\]+\[0-9\]+\[^\r\n\]+\[0-9\]+\[^\r\n\]+\[0-9\]+\[^\r\n\]+\[0-9\]+\[^\r\n\]+\[\r\n\]+" {
+        set saw_registers 1
+        exp_continue
+    }
+    -re "^\\*\[0-9\]+\[^\r\n\]+\[\r\n\]+" {
+        exp_continue
+    }
+    -re "$gdb_prompt $" {
+        gdb_assert { $saw_registers && $saw_headers } $test
+    }
+}
 
 # Test "mt expand-symtabs" here as it's easier to verify before we
 # run the program.
This page took 0.031439 seconds and 4 git commands to generate.