From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29118 invoked by alias); 8 May 2010 19:50:33 -0000 Received: (qmail 29107 invoked by uid 22791); 8 May 2010 19:50:32 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 08 May 2010 19:50:27 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 88EB72BAB43; Sat, 8 May 2010 15:50:25 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id QuUpzD2VyPUd; Sat, 8 May 2010 15:50:25 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 3C4A82BAB5A; Sat, 8 May 2010 15:50:25 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 7BB44F58F9; Sat, 8 May 2010 12:50:16 -0700 (PDT) Date: Sat, 08 May 2010 19:50:00 -0000 From: Joel Brobecker To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: Add prms_id and bug_id to the ARI? Message-ID: <20100508195016.GA7479@adacore.com> References: <20100505181633.GT2768@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="SUOF0GtieIMvvwua" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) 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 X-SW-Source: 2010-05/txt/msg00216.txt.bz2 --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 641 > You could try putting this into gdb.exp somewhere: > > proc gdb_trace_error {name ignore op} { > error "Attempt to write to $name." > } > > trace variable prms_id w gdb_trace_error > trace variable bug_id w gdb_trace_error Nice trick! Attached is a patch that implements something along those lines... Ideally, we would really like to check any use of these variables (including reads and unsets), but these variable do get accessed during the run (computing some pass strings). In practice, all the uses I've found were setting them, so it is probably going to be good enough. Tested on x86_64-linux. -- Joel --SUOF0GtieIMvvwua Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="verbotten.diff" Content-length: 1906 commit 35e9b1f2ec01514d8455c0366f77ab4e196da8f8 Author: Joel Brobecker Date: Sat May 8 12:20:36 2010 -0700 testsuite: Prevent writes to prms_id and bug_id. gdb/testsuite/ChangeLog: * lib/gdb.exp (banned_variables): New variable/constant. (gdb_init): Add write trace on variables listed in banned_variables. (gdb_finish): Remove write traces on variables listed in banned_variables. diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 8be2a72..70df5ea 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -2480,6 +2480,11 @@ if ![info exists gdb_test_timeout] { set gdb_test_timeout $timeout } +# A list of global variables that GDB testcases should not use. +# We try to prevent their use by monitoring write accesses and raising +# an error when that happens. +set banned_variables { bug_id prms_id } + proc gdb_init { args } { # Reset the timeout value to the default. This way, any testcase # that changes the timeout value without resetting it cannot affect @@ -2488,6 +2493,13 @@ proc gdb_init { args } { global timeout set timeout $gdb_test_timeout + # Block writes to all banned variables... + global banned_variables + foreach banned_var $banned_variables { + global "$banned_var" + trace variable "$banned_var" w error + } + return [eval default_gdb_init $args]; } @@ -2501,6 +2513,14 @@ proc gdb_finish { } { eval remote_file target delete $cleanfiles set cleanfiles {} } + + # Unblock write access to the banned variables. Dejagnu typically + # resets some of them between testcases. + global banned_variables + foreach banned_var $banned_variables { + global "$banned_var" + trace remove variable "$banned_var" write error + } } global debug_format --SUOF0GtieIMvvwua--