From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26120 invoked by alias); 13 Apr 2018 13:10:10 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 26110 invoked by uid 89); 13 Apr 2018 13:10:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 spammy=serving, pause X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Apr 2018 13:10:09 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6660E4022414; Fri, 13 Apr 2018 13:10:07 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD3AB2026DFD; Fri, 13 Apr 2018 13:10:06 +0000 (UTC) Subject: Re: [PATCH 3/3] gdb/testsuite: Handle targets with lots of registers To: "Maciej W. Rozycki" , Andrew Burgess References: Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <4273f7eb-464a-3abc-fc50-b6598ed3b896@redhat.com> Date: Fri, 13 Apr 2018 13:10:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-04/txt/msg00252.txt.bz2 On 04/13/2018 12:39 AM, Maciej W. Rozycki wrote: > On Mon, 9 Apr 2018, Andrew Burgess wrote: > >> # 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 >> + } > > I think this changes the meaning of the test; you want to preserve the > heading match pattern at the very least. Also `gdb_test' handles various > error cases gracefully (which matters for the avoidance of excessive > timeouts with some test boards), whereas your simple matcher does not. Yeah, there's no good reason to use gdb_expect directly here, AFAICT. You can do the same thing with gdb_test_multiple, which handles the timeout already, as well as other error conditions, including the internal-error the comment the test above mentions. > > Also how many is "a lot"? Perhaps you could take the path of least > resistance instead and simply increase the size of the buffer, like with > commit ff604a674771 ("gdb/testsuite: Bump up `match_max'"). This could be > done temporarily for this test only, so as to avoid slowing down `expect' > throughout the test suite. I think the exp_continue trick is better for getting rid of the problem for good. We can still use it, with gdb_test_multiple. A few comments more: > + -re "^\[^\n\r\]+\[0-9\]+\[^\n\r\]+\[0-9\]+\[^\n\r\]+\[0-9\]+\[^\n\r\]+\[0-9\]+\[^\n\r\]+\[\n\r\]+" { Nit: \n\r instead of \r\n kind of reads like a typo to me: $ grep -rn "\\\\r\\\\n\\\\]" | wc -l 1036 $ grep -rn "\\\\n\\\\r\\\\]" | wc -l 28 I'd suggest flipping it around to the more usual form just to avoid causing pause when people read the regexp. > + exp_continue > + } > + -re ".*$gdb_prompt $" { No need for leading .*, it's implied. > + pass "maint print registers" > + } > + timeout { > + fail "maint print registers (timeout)" > + } > +} > + So I'd suggest something like this: set saw_registers 0 set test "maint print registers" gdb_test_multiple $test $test { -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 "$gdb_prompt $" { gdb_assert $saw_registers $test } } The "saw_registers" bit ends up serving as replacement for seeing the heading, though you can also add a pattern to match the heading and check it in the gdb_assert instead if you'd like. Thanks, Pedro Alves