public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCH 3/3] gdb/testsuite: Handle targets with lots of registers
Date: Mon, 09 Apr 2018 15:15:00 -0000	[thread overview]
Message-ID: <f708d6f5e4f81f3f08c27916fb8d6a18d753cde8.1523286728.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1523286728.git.andrew.burgess@embecosm.com>
In-Reply-To: <cover.1523286728.git.andrew.burgess@embecosm.com>

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          |  5 +++++
 gdb/testsuite/gdb.base/maint.exp | 18 ++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index 93221085653..f73495faa5b 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -62,8 +62,22 @@ 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.
+send_gdb "maint print registers\n"
+gdb_expect {
+    -re "^\[^\n\r\]+\[0-9\]+\[^\n\r\]+\[0-9\]+\[^\n\r\]+\[0-9\]+\[^\n\r\]+\[0-9\]+\[^\n\r\]+\[\n\r\]+" {
+	exp_continue
+    }
+    -re ".*$gdb_prompt $" {
+	pass "maint print registers"
+    }
+    timeout {
+	fail "maint print registers (timeout)"
+    }
+}
+
 
 # Test "mt expand-symtabs" here as it's easier to verify before we
 # run the program.
-- 
2.12.2

  parent reply	other threads:[~2018-04-09 15:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-09 15:15 [PATCH 0/3] Small testsuite updates Andrew Burgess
2018-04-09 15:15 ` [PATCH 2/3] gdb/testsuite: Filter out some registers for riscv Andrew Burgess
2018-04-09 21:28   ` Palmer Dabbelt
2018-04-09 22:26     ` Andrew Burgess
2018-04-10 20:25       ` Palmer Dabbelt
2018-04-13 12:55         ` Pedro Alves
2018-04-09 15:15 ` [PATCH 1/3] gdb/testsuite: Fix broken regexp in gdbstub case Andrew Burgess
2018-04-13 12:12   ` Pedro Alves
2018-05-03 19:41     ` Andrew Burgess
2018-05-04  9:18       ` Pedro Alves
2018-04-09 15:15 ` Andrew Burgess [this message]
2018-04-12 23:40   ` [PATCH 3/3] gdb/testsuite: Handle targets with lots of registers Maciej W. Rozycki
2018-04-13 13:10     ` Pedro Alves
2018-04-13 13:57       ` Maciej W. Rozycki
2018-05-04 12:01         ` Andrew Burgess
2018-05-04 12:47           ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f708d6f5e4f81f3f08c27916fb8d6a18d753cde8.1523286728.git.andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).