From patchwork Fri May 4 12:01:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 27108 Received: (qmail 66176 invoked by alias); 4 May 2018 12:01:31 -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 65714 invoked by uid 89); 4 May 2018 12:01:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 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=H*RU:209.85.128.193, Hx-spam-relays-external:209.85.128.193, Pedro's, pedros X-HELO: mail-wr0-f193.google.com Received: from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com) (209.85.128.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 May 2018 12:01:29 +0000 Received: by mail-wr0-f193.google.com with SMTP id y15-v6so9088070wrg.11 for ; Fri, 04 May 2018 05:01:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=g+W2XvSK9Blt2/0Up7yX6R0ZD0gUVnmyUPr4e8UGRa0=; b=h70/FCLlb6sUXX6eWIsVBLkfbGe0rlLWri4Z8xZXugQwTPWkVvN4PrH14VqCxpvJQJ 4Vt/XXJ1YYi44jA9cBMFbfTIzT1njuQO2EdFGx9B5e4Ca+ry9PT36sZqRwApssy3MMAF 11YAPcVbxIlKy3xGgDW3MJQchxRLP/cbkMnAhIdwunY563ZDunR0tr+rsQQ5DY1vpJq7 TMRrmzIOO5CX5rAkjLELszD4YtMC/pu1x6jdhfs8rynzrcaEmbXbA3VzDv3JCWSmOEBg gDlMw0+i0qrZlB+hAnufd9I0ws74Koa/Uv73Ycn6gGK7KD7NkhIWiFfNp3iRbCfdCuRM S2ag== X-Gm-Message-State: ALQs6tCwpxQpacRZN2GLyBC8iF+TMNa9AiTcbOOnm2/J7Tu1YbzDshnR fVkk+K2cGIBPGqNxOuLIYa6DdUo+ X-Google-Smtp-Source: AB8JxZq1Nm38lEzrooppav/8u+15d3iFzREN7mD2vfaYRXnHuW3i/m7erp0CH9MqCtgeBU1cXD9NBQ== X-Received: by 2002:adf:db4f:: with SMTP id f15-v6mr21028746wrj.212.1525435286886; Fri, 04 May 2018 05:01:26 -0700 (PDT) Received: from localhost (host81-147-175-127.range81-147.btcentralplus.com. [81.147.175.127]) by smtp.gmail.com with ESMTPSA id h81sm1992314wmd.0.2018.05.04.05.01.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 May 2018 05:01:25 -0700 (PDT) Date: Fri, 4 May 2018 13:01:24 +0100 From: Andrew Burgess To: gdb-patches@sourceware.org Cc: "Maciej W. Rozycki" , Pedro Alves Subject: Re: [PATCH 3/3] gdb/testsuite: Handle targets with lots of registers Message-ID: <20180504120124.GK3375@embecosm.com> References: <4273f7eb-464a-3abc-fc50-b6598ed3b896@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Thanks for the review feedback. I've updated the patch below inline with Pedro's feedback, and included a header check as requested by Maciej. I tested this on x86-64 and against RiscV which is the target that was originally causing me problems. Thanks, Andrew --- [PATCH 1/2] gdb/testsuite: Handle targets with lots of registers 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 | 25 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp index 93221085653..1fe36405df3 100644 --- a/gdb/testsuite/gdb.base/maint.exp +++ b/gdb/testsuite/gdb.base/maint.exp @@ -62,8 +62,29 @@ 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 "$test: saw some registers" + gdb_assert $saw_headers "$test: saw header line" + } +} # Test "mt expand-symtabs" here as it's easier to verify before we # run the program.