From patchwork Thu Feb 20 13:27:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 38255 Received: (qmail 820 invoked by alias); 20 Feb 2020 13:28:07 -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 812 invoked by uid 89); 20 Feb 2020 13:28:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=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.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Feb 2020 13:28:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582205284; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tvpxi9P9vnbFWZFExmSItGx/qaKvHiK0vZtQEonSlrg=; b=C2olsG7f9Cx5HQAqM+3bo59C2ysQMFF4XeAWqvuJXK3TyFsi5PZOYXW7d8vl4UZRi88DpY 0JMNuell/FIly0dVRUSGnt1cqVyQbIfmVuvnGVFD8te0xz0S5bzaJKDkpnlqqAtpZdLKyq SKp/O9Wm8vezHDS2NZtldsba6yByTDE= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-53-7TCb_1LvOBe53pp8BMVCvg-1; Thu, 20 Feb 2020 08:28:02 -0500 Received: by mail-ed1-f71.google.com with SMTP id f13so2661484edy.21 for ; Thu, 20 Feb 2020 05:28:01 -0800 (PST) Return-Path: Received: from ?IPv6:2001:8a0:f909:7b00:56ee:75ff:fe8d:232b? ([2001:8a0:f909:7b00:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id k15sm124743ejc.35.2020.02.20.05.27.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Feb 2020 05:27:58 -0800 (PST) Subject: Re: [RFC][gdb/testsuite] Handle -line and -non-empty-line in gdb_test_multiple To: Tom de Vries , gdb-patches@sourceware.org References: <20200219174014.GA28126@delia> <851a18b0-b172-4b59-e411-ce3379c95c76@redhat.com> <0208e698-e2e1-c13f-486f-caa3f7766d6a@suse.de> From: Pedro Alves Message-ID: <883bfb0f-c8e7-ae6c-aa94-2486b3c76362@redhat.com> Date: Thu, 20 Feb 2020 13:27:57 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <0208e698-e2e1-c13f-486f-caa3f7766d6a@suse.de> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com On 2/19/20 9:30 PM, Tom de Vries wrote: > [ was: Re: [PATCH][gdb/testsuite] Fix corefile-buildid.exp with > Committed. > >> If this pattern appears in more places it may be worth it to >> think about some abstraction to make it easier to write. >> Like e.g., a new "-lbl" (line-by-line) option switch to >> gdb_test_multiple that auto-appends the "match one line" regexp. > > How about this? Oh, by "pattern", I meant the design pattern, the higher-level thing of expecting a string while at the same time consuming input a line at a time. Something like: ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ That should mean we could drop the $gdb_prompt matches too. But maybe a new gdb_test_lbl procedure that wraps gdb_test_multiple would be preferred. The way you have it doesn't look very different from creating a couple globals, like: set line_re "^\[^\r\n\]*\r\n" set non_empty_line_re "^\[^\r\n\]+\r\n" and the using them like: -re "$line_re" { Maybe removing the leading "^" anchor from the variables would make them usable in more places. Anyway, I don't object to your patch if you like it. It just wasn't what I was suggesting. Thanks, Pedro Alves diff --git c/gdb/testsuite/lib/gdb.exp w/gdb/testsuite/lib/gdb.exp index d8ebddf63ce..6eaebc7710d 100644 --- c/gdb/testsuite/lib/gdb.exp +++ w/gdb/testsuite/lib/gdb.exp @@ -858,6 +858,7 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } { set expecting_action 0 set expecting_arg 0 set wrap_pattern 0 + set line_by_line 0 foreach item $user_code subst_item $subst_code { if { $item == "-n" || $item == "-notransfer" || $item == "-nocase" } { lappend $current_list $item @@ -880,6 +881,10 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } { set wrap_pattern 1 continue } + if {$item == "-lbl"} { + set line_by_line 1 + continue + } if { $expecting_arg } { set expecting_arg 0 lappend $current_list $subst_item @@ -1070,6 +1075,14 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } { } } + if {$line_by_line} { + append code { + -re "^\[^\r\n\]*\r\n" { + exp_continue + } + } + } + # Now patterns that apply to any spawn id specified. append code { -i $any_spawn_id