From patchwork Thu Jun 28 19:39:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 936378 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480715-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="TBNNqOkm"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41Gqpq3lN4z9ryk for ; Fri, 29 Jun 2018 05:39:13 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=Klv8B2EP779U+JB0O CR6H8FNQRzFwseK4ZTqT/IC7l+wtAxMHRSloxnqgIxApJqrL+FaMqB9ui6DpQPMY PhQtMWejkdpUE/23Rw0H0tAR5Ivj9LOTmSmTFb/NDjga90Wm2CuOKw4FsTV16/2F +BmzLc9G9soAHLKHzGZLqmPNGg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=Qx98HXTCmXw4QuVF4Ql8eOj Sw04=; b=TBNNqOkmblxKck+juoVHWuoQNrbJMErpUeDeqoCgJ7bf5nezz9ScfRT bRO9E9+BtJHjDYYrRdFd2w0qrQ8BtRfZAMe2FC6IMxsEQaIiDl9JBb7KLJQBuSq0 v2gsaFEnDU4QkYI2JJSvZjdC7amzzvNXzdryi5BB4Z45nptNpKgo= Received: (qmail 58867 invoked by alias); 28 Jun 2018 19:39:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 58857 invoked by uid 89); 28 Jun 2018 19:39: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, SPF_PASS autolearn=ham version=3.3.2 spammy=deduce X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 28 Jun 2018 19:39:04 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 5955EACB0; Thu, 28 Jun 2018 19:39:02 +0000 (UTC) Date: Thu, 28 Jun 2018 21:39:01 +0200 From: Tom de Vries To: gcc-patches@gcc.gnu.org Cc: Rainer Orth , Mike Stump Subject: [RFC, testsuite/guality] Use relative line numbers in gdb-test Message-ID: <20180628193901.efyteesvsggaw53e@delia> References: <20180628174930.qo67pkvnphg3c3qm@delia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180628174930.qo67pkvnphg3c3qm@delia> User-Agent: NeoMutt/20170912 (1.9.0) X-IsSubscribed: yes [ was: [PATCH, testsuite/guality] Use line number vars in gdb-test ] On Thu, Jun 28, 2018 at 07:49:30PM +0200, Tom de Vries wrote: > Hi, > > I played around with pr45882.c and ran into FAILs. It took me a while to > realize that the FAILs where due to the gdb-test (a dg-final action) using > absolute line numbers, and me adding lines before the gdb-test lines. > > I've written this patch, which factors out the handling of relative line > numbers as well as line number variables from process-message, and reuses the > functionality in gdb-test. > > This enables the line number variables functionality in gdb-test. [ There's > one quirk: line number variables have a define-before-use semantics (with > matching used-before-defined error) but in the test-case the use in gdb-test > preceeds the definition in gdb-line. This doesn't cause errors, because > the dg-final actions are executed after the definition has taken effect. ] > > [ Relative line numbers still don't work in gdb-test, but that's due to an > orthogonal issue: gdb-test is a dg-final action, and while dg-final receives > the line number on which it occurred as it's first argument, it doesn't pass > on this line number to the argument list of the action. I'll submit a > follow-on rfc patch for this. ] > This patch adds a dg-final override that passes it's first argument to the gdb-test action. This allows us to use relative line numbers in gdb-test. Tested pr45882.c. Any comments? Thanks, - Tom [testsuite/guality] Use relative line numbers in gdb-test 2018-06-28 Tom de Vries * gcc.dg/guality/pr45882.c (foo): Use relative line numbers. * lib/gcc-dg.exp (dg-final): New proc. * lib/gcc-gdb-test.exp (gdb-test): Add and handle additional line number argument. --- gcc/testsuite/gcc.dg/guality/pr45882.c | 10 +++++----- gcc/testsuite/lib/gcc-dg.exp | 20 ++++++++++++++++++++ gcc/testsuite/lib/gcc-gdb-test.exp | 4 ++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/gcc/testsuite/gcc.dg/guality/pr45882.c b/gcc/testsuite/gcc.dg/guality/pr45882.c index da9e2755590..02d74389ea0 100644 --- a/gcc/testsuite/gcc.dg/guality/pr45882.c +++ b/gcc/testsuite/gcc.dg/guality/pr45882.c @@ -9,11 +9,11 @@ volatile short int v; __attribute__((noinline,noclone,used)) int foo (int i, int j) { - int b = i; /* { dg-final { gdb-test bpline "b" "7" } } */ - int c = i + 4; /* { dg-final { gdb-test bpline "c" "11" } } */ - int d = a[i]; /* { dg-final { gdb-test bpline "d" "112" } } */ - int e = a[i + 6]; /* { dg-final { gdb-test bpline "e" "142" } } */ - ++v; /* { dg-line bpline } */ + int b = i; /* { dg-final { gdb-test .+4 "b" "7" } } */ + int c = i + 4; /* { dg-final { gdb-test .+3 "c" "11" } } */ + int d = a[i]; /* { dg-final { gdb-test .+2 "d" "112" } } */ + int e = a[i + 6]; /* { dg-final { gdb-test .+1 "e" "142" } } */ + ++v; return ++j; } diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index 22065c7e3fe..6f88ce2213e 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -114,6 +114,26 @@ if [info exists ADDITIONAL_TORTURE_OPTIONS] { [concat $DG_TORTURE_OPTIONS $ADDITIONAL_TORTURE_OPTIONS] } +proc dg-final { args } { + upvar dg-final-code final-code + + if { [llength $args] > 2 } { + error "[lindex $args 0]: too many arguments" + } + set line [lindex $args 0] + set code [lindex $args 1] + set directive [lindex $code 0] + set withline \ + [switch $directive { + gdb-test {expr {1}} + default {expr {0}} + }] + if { $withline == 1 } { + set code [linsert $code 1 $line] + } + append final-code "$code\n" +} + global orig_environment_saved # Deduce generated files from tool flags, return finalcode string diff --git a/gcc/testsuite/lib/gcc-gdb-test.exp b/gcc/testsuite/lib/gcc-gdb-test.exp index 5457e7a793e..c446f5b122d 100644 --- a/gcc/testsuite/lib/gcc-gdb-test.exp +++ b/gcc/testsuite/lib/gcc-gdb-test.exp @@ -26,7 +26,7 @@ # calling print on it in gdb. When asking for the type it is # the literal string with extra whitespace removed. # Argument 3 handles expected failures and the like -proc gdb-test { args } { +proc gdb-test { useline args } { if { ![isnative] || [is_remote target] } { return } if { [llength $args] >= 4 } { @@ -60,7 +60,7 @@ proc gdb-test { args } { set cmd_file "[file rootname [file tail $prog]].gdb" set fd [open $cmd_file "w"] - set line [get-absolute-line "" [lindex $args 0]] + set line [get-absolute-line $useline [lindex $args 0]] puts $fd "break $line" puts $fd "run" puts $fd "$command $var"