From patchwork Mon Apr 9 15:15:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 26658 Received: (qmail 118901 invoked by alias); 9 Apr 2018 15:15:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 118790 invoked by uid 89); 9 Apr 2018 15:15:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=2122, internal-error, internalerror, Hx-spam-relays-external:209.85.128.194 X-HELO: mail-wr0-f194.google.com Received: from mail-wr0-f194.google.com (HELO mail-wr0-f194.google.com) (209.85.128.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Apr 2018 15:15:40 +0000 Received: by mail-wr0-f194.google.com with SMTP id 80so9971591wrb.2 for ; Mon, 09 Apr 2018 08:15:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=uiSOeXU4vPcDXUc1Iln1Qh/fiMc4RngF0Z0FylE30Tg=; b=iDXklTFpKCluTpQwJU8yZPBZ43zcyugGq+BmV18oHgjBhEjW0vkBQ5OE98tx/37OHV zw2S+y/hrPtgg/TcV+MRy2nX6XuDoIdSoHxI+Ehu8XTSdFp5V/rdaNdG5qYgXSqi7SH/ oR4ivheSJg65pITDnDpJyno9iiOnX6EUtbbD4MhPReYcw0B9JBemJA54BVKDlMCMWmIU VVyPv6H9VN6IwQ6Dnb2UGD+hPEWAJShEk9wHNHWFjWtmSUCglQSjo5Z+L+TK/cXtBB25 smkwzdfYcmD5wCNOekn9oXCSnnMp7sOKDzT5Qu8XK78XF6hal4Mt7fA/FdlrFLYZxVrO 7xuA== X-Gm-Message-State: ALQs6tCfI5PErSsSLb7lj2+0aGvwnbxY6ANAZZ0X1nkPnMN5iqdDzcut vC6IsGQj/OWdMr80+RA+cwCiQNbT X-Google-Smtp-Source: AIpwx48BlbBOePD0xjNoN6hvKnhmXUtEq4IBssP4kpzZL2PTpZcpLc5taZicGLIy+Eso1RaqeMxaIQ== X-Received: by 10.223.135.237 with SMTP id c42mr5012248wrc.146.1523286935958; Mon, 09 Apr 2018 08:15:35 -0700 (PDT) Received: from localhost (host81-148-252-121.range81-148.btcentralplus.com. [81.148.252.121]) by smtp.gmail.com with ESMTPSA id 39sm872726wry.89.2018.04.09.08.15.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Apr 2018 08:15:35 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 3/3] gdb/testsuite: Handle targets with lots of registers Date: Mon, 9 Apr 2018 16:15:29 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes 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.