From patchwork Sun Sep 23 11:11:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 186206 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 3B63C2C0094 for ; Sun, 23 Sep 2012 21:12:05 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1349003526; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:From:To:Subject:Date:Message-ID: User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=hl3+B4qYoqLVCswWVFxeQwruySw=; b=YzlVnLLF8AFR33b V0aIPC1/CebpbXSHyZBvjIctl0b3aPeNEkVmwN35bupox/q8VMUkFMwcyLyT0yQM KI6U27j8rRxmVoOmeyVq+Ph0HwTJQ0CKVl2sYTPD4sGB3JndFUaG5YWaMPpgq+JU wU3HkRKBOlfz8/hZRfsvAdj1y2WM= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=wUofBqk4la4afPXPo77jcalyQSR+z4LjHoxfk781XYX5YG7wGdQSbprGJpXO86 yR0VAQG+LirYD+K/+AA4W9srNPg0Tig17SN2b7Wx6O09XYQeemAnbnMQi2ltLAoV ZqHWRgNMc++XVcN+jDNbUmgbsRo29ITpg9UEg07+bhFJ0=; Received: (qmail 10575 invoked by alias); 23 Sep 2012 11:12:00 -0000 Received: (qmail 10563 invoked by uid 22791); 23 Sep 2012 11:11:59 -0000 X-SWARE-Spam-Status: No, hits=-5.6 required=5.0 tests=AWL, BAYES_00, FILL_THIS_FORM_SHORT, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 23 Sep 2012 11:11:41 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8NBBfPo012178 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 23 Sep 2012 07:11:41 -0400 Received: from freie.oliva.athome.lsd.ic.unicamp.br (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q8NBBdB8017858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 23 Sep 2012 07:11:41 -0400 Received: from livre.localdomain (livre-to-gw.oliva.athome.lsd.ic.unicamp.br [172.31.160.19]) by freie.oliva.athome.lsd.ic.unicamp.br (8.14.5/8.14.5) with ESMTP id q8NBBcAq019982 for ; Sun, 23 Sep 2012 08:11:38 -0300 Received: from livre.localdomain (aoliva@localhost.localdomain [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id q8NBBcH0014251; Sun, 23 Sep 2012 08:11:38 -0300 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id q8NBBZ0a014249; Sun, 23 Sep 2012 08:11:35 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: robustify guality self-check Date: Sun, 23 Sep 2012 08:11:35 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 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 I found out I wasn't getting any guality tests run. The old gdb I used wouldn't recognize line number information at -O0 or something, and this caused guality.exp to give up. -O2 -g would have worked, but passing them to guality_check in either order would cause only the first of the two to make to the command line, so the test would still fail. Some messing with a list and additional quoting to avoid too-early expansion within the eval took care of that. But the test still wouldn't work. Debug info generated for the local variables used by the guality framework wouldn't be recognized by that old gdb: as a result, the variables wouldn't be set, and we'd conclude they had incorrect values. I've now arranged for the variables to be initialized to different values at each probe point, and if they remain unchanged, we just bump them up and repeat the probe, with an upper limit of retries large enough to make room for both probe variables to get values identical to the initializer, but not for us to loop indefinitely: we quickly realize when gdb is unable to set the probe variables and error out. Having taken care of detecting problems, I made the probe variables global, just like the variable used to detect whether gdb has attached to the program, and that got things to work at least to some extend with the older GDB. However, it looks like we're emitting a lot of debug info now that the older GDB can't deal with, so... Having fixed it all, I installed a newer GDB, but I still thing the patch brings in some useful robustness improvements. Ok to install? Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Robustify guality tests, fix and improve check_guality From: Alexandre Oliva for gcc/testsuite/ChangeLog * gcc.dg/guality/guality.exp (check_guality): Fix compilation attempt with -O0 -g, and retry with -O2 -g upon failure. * gcc.dg/guality/guality.h (guality_xvalue): New variable. (guality_unavailable): Likewise. (guality_check): Robustify to cope with failure to set user variables, now using the new guality_* variables. --- gcc/testsuite/gcc.dg/guality/guality.exp | 19 +++++++++++++ gcc/testsuite/gcc.dg/guality/guality.h | 43 +++++++++++++++++++++++------- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/gcc/testsuite/gcc.dg/guality/guality.exp b/gcc/testsuite/gcc.dg/guality/guality.exp index 49e2ac5..0c47fa4 100644 --- a/gcc/testsuite/gcc.dg/guality/guality.exp +++ b/gcc/testsuite/gcc.dg/guality/guality.exp @@ -9,7 +9,24 @@ if { [istarget *-*-darwin*] } { } proc check_guality {args} { - set result [eval check_compile guality_check executable $args "-g -O0"] + set options [list "-O0" "-g"] + set result [eval check_compile guality_check \ + executable $args "\"\$options\""] + set lines [lindex $result 0] + set output [lindex $result 1] + set ret 0 + if {[string match "" $lines]} { + set execout [gcc_load "./$output"] + set ret [string match "*1 PASS, 0 FAIL, 0 UNRESOLVED*" $execout] + } + remote_file build delete $output + if {$ret} { + return $ret + } + # Retry with -O2 -g + set options [list "-O2" "-g"] + set result [eval check_compile guality_check \ + executable $args "\"\$options\""] set lines [lindex $result 0] set output [lindex $result 1] set ret 0 diff --git a/gcc/testsuite/gcc.dg/guality/guality.h b/gcc/testsuite/gcc.dg/guality/guality.h index 8b657f2..9d51893 100644 --- a/gcc/testsuite/gcc.dg/guality/guality.h +++ b/gcc/testsuite/gcc.dg/guality/guality.h @@ -194,6 +194,14 @@ int guality_breakpoint_line; /* GDB should set this to true once it's connected. */ int volatile guality_attached; +/* GDB should set this to the value of the expression we're checking. */ +gualchk_t volatile guality_xvalue; + +/* GDB should set this to a value that tells whether the value was + optimized away. */ +int volatile guality_unavailable; + + /* This function is the main guality program. It may actually be defined as main, because we #define main to it afterwards. Because of this wrapping, guality_main may not have an empty argument @@ -283,8 +291,12 @@ guality_check (const char *name, gualchk_t value, int unknown_ok) return; { - volatile gualchk_t xvalue = -1; - volatile int unavailable = 0; + static int test_count; + int retry_count = test_count; + retry: + ++test_count; + guality_xvalue = test_count; + guality_unavailable = test_count; if (name) { /* The sequence below cannot distinguish an optimized away @@ -300,8 +312,8 @@ set $value4 = $value1 + 1\n\ set $value3 = (%s)++\n\ set $value4 = --(%s)\n\ down\n\ -set xvalue = $value1\n\ -set unavailable = $value1 != $value2 ? -1 : $value3 != $value4 ? 1 : 0\n\ +set guality_xvalue = $value1\n\ +set guality_unavailable = $value1 != $value2 ? -1 : $value3 != $value4 ? 1 : 0\n\ continue\n\ ", name, name, name, name) <= 0 || fflush (guality_gdb_input)) @@ -322,7 +334,7 @@ continue\n\ ; if (!timeout && !guality_attached) { - fprintf (stderr, "gdb: took too long to attach\n"); + fprintf (stderr, "ERROR: gdb: took too long to attach\n"); abort (); } } @@ -334,28 +346,39 @@ continue\n\ } /* Do NOT add lines between the __LINE__ above and the line below, without also adjusting the added constant to match. */ - if (!unavailable || (unavailable > 0 && xvalue)) + if (guality_xvalue == test_count || guality_unavailable == test_count) + { + if (test_count - retry_count < 4) + goto retry; + + fprintf (stderr, "ERROR: gdb: failed to set interface variables\n"); + abort (); + } + if (!guality_unavailable || (guality_unavailable > 0 && guality_xvalue)) { - if (xvalue == value) + if (guality_xvalue == value) result = PASS; else result = INCORRECT; } else result = INCOMPLETE; - asm ("" : : "X" (name), "X" (value), "X" (unknown_ok), "m" (xvalue)); + asm ("" : : "X" (name), "X" (value), "X" (unknown_ok), + "m" (guality_xvalue)); switch (result) { case PASS: fprintf (stderr, "PASS: %s is %lli\n", name, value); break; case INCORRECT: - fprintf (stderr, "FAIL: %s is %lli, not %lli\n", name, xvalue, value); + fprintf (stderr, "FAIL: %s is %lli, not %lli\n", name, + guality_xvalue, value); break; case INCOMPLETE: fprintf (stderr, "%s: %s is %s, expected %lli\n", unknown_ok ? "UNRESOLVED" : "FAIL", name, - unavailable < 0 ? "not computable" : "optimized away", value); + guality_unavailable < 0 + ? "not computable" : "optimized away", value); result = unknown_ok ? INCOMPLETE : INCORRECT; break; default: