From patchwork Fri Mar 21 00:03:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 200 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx21.g.dreamhost.com (caibbdcaaahb.dreamhost.com [208.113.200.71]) by wilcox.dreamhost.com (Postfix) with ESMTP id A49ED360080 for ; Thu, 20 Mar 2014 17:03:34 -0700 (PDT) Received: by homiemail-mx21.g.dreamhost.com (Postfix, from userid 14314964) id 5164EC5125B; Thu, 20 Mar 2014 17:03:34 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx21.g.dreamhost.com 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 homiemail-mx21.g.dreamhost.com (Postfix) with ESMTPS id 20C20C51298 for ; Thu, 20 Mar 2014 17:03:34 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version:content-type; q=dns; s=default; b=PgBU1 qUI0kcnODx6+x+M82I+WOhaQJdtTF/B2bibHAvIdImVJBB6ecdstwJ94OpefQpYv 9bfE460hZQnF9yOcaayFhlUK1Do2t9l2f78DIQe37d3gVzKy68IVWYM4iMl7WMQ2 dUF0hAQCEebyrgjz4heYvxz0rSMfDAAYiK37AM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version:content-type; s=default; bh=R+RfCpEtAUF Hb5UapSwMOxwjgJM=; b=TfcrPE84mT3zM5Xsjdb3MY7y4LwVJFGAO+Xokw/o8TA dhzHRbQHfqBXjoltbLxQXISINWibma82Fg4JtSvTT2A9BFhZJrVhFJQWytxDj16w pgpx24mUsEEtiaE14PBym2lbs46QoDORaOAwqvfcXAHGg+zXDmqUlTDIuuedFlBo = Received: (qmail 29751 invoked by alias); 21 Mar 2014 00:03:32 -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 29735 invoked by uid 89); 21 Mar 2014 00:03:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Mar 2014 00:03:30 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WQmvm-0005mG-K1 from Maciej_Rozycki@mentor.com ; Thu, 20 Mar 2014 17:03:26 -0700 Received: from SVR-IES-FEM-02.mgc.mentorg.com ([137.202.0.106]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 20 Mar 2014 17:03:26 -0700 Received: from [172.30.64.80] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.2.247.3; Fri, 21 Mar 2014 00:03:24 +0000 Date: Fri, 21 Mar 2014 00:03:14 +0000 From: "Maciej W. Rozycki" To: Pedro Alves CC: Subject: Re: [PATCH] gdb.threads/thread-specific.exp: Fix uninitialized variable references In-Reply-To: <532AD002.8000602@redhat.com> Message-ID: References: <532AD002.8000602@redhat.com> User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 X-DH-Original-To: gdb@patchwork.siddhesh.in On Thu, 20 Mar 2014, Pedro Alves wrote: > Thanks! Close, but needs a little tweak. > > Using "info exists" uses like this isn't safe, given that > in a single dejagnu run that tests multiple .exp test files (like just > plain "make check"), global variables set in previous test files leak > into the current test file. So what we usually do instead is set > the variable unconditionally upfront to some invalid value, and > then compare against that value. E.g.: > > set this_breakpoint -1 > gdb_test_multiple "continue" "continue to thread-specific breakpoint" { > -re "Breakpoint $main_breakpoint, .* at .*\r\n$gdb_prompt $" { > fail "continue to thread-specific breakpoint (wrong breakpoint)" > } > -re "Breakpoint (\[0-9\]*), .* at .*\r\n$gdb_prompt $" { > set this_breakpoint $expect_out(1,string) > pass "continue to thread-specific breakpoint" > } > } > if { $this_breakpoint == -1 } { > untested ... > } else { > ... > } > > Of course we could unset the variable instead of setting it > to -1, using 'unset -nocomplain'. Same thing. Somehow I'm > inclined to think that pattern is more prone to copy-paste > forgetting to do the unset though, but I'd be fine with it. OK, I'd prefer keeping the usual case first in the conditional though. How about this version then? I have tested it on the failing system and it still works. 2014-03-21 Maciej W. Rozycki gdb/testsuite/ * gdb.threads/thread-specific.exp: Handle the lack of usable $this_breakpoint and $this_thread. Maciej gdb-test-thread-specific-this-foo.diff Index: gdb-fsf-trunk-quilt/gdb/testsuite/gdb.threads/thread-specific.exp =================================================================== --- gdb-fsf-trunk-quilt.orig/gdb/testsuite/gdb.threads/thread-specific.exp 2014-03-18 19:00:40.000000000 +0000 +++ gdb-fsf-trunk-quilt/gdb/testsuite/gdb.threads/thread-specific.exp 2014-03-20 23:48:55.277523035 +0000 @@ -95,6 +95,7 @@ foreach thread [lrange $threads 1 end] { gdb_breakpoint "$line thread $thread" } +set this_breakpoint -1 gdb_test_multiple "continue" "continue to thread-specific breakpoint" { -re "Breakpoint $main_breakpoint, .* at .*\r\n$gdb_prompt $" { fail "continue to thread-specific breakpoint (wrong breakpoint)" @@ -105,13 +106,22 @@ gdb_test_multiple "continue" "continue t } } -gdb_test_multiple "info breakpoint $this_breakpoint" "info on bp" { - -re ".*stop only in thread (\[0-9\]*).*$gdb_prompt $" { - set this_thread $expect_out(1,string) - pass "found breakpoint for thread number" +set this_thread -1 +if { $this_breakpoint != -1 } { + gdb_test_multiple "info breakpoint $this_breakpoint" "info on bp" { + -re ".*stop only in thread (\[0-9\]*).*$gdb_prompt $" { + set this_thread $expect_out(1,string) + pass "found breakpoint for thread number" + } } +} else { + untested "info on bp" } -gdb_test {print $_thread} ".* = $this_thread" "thread var at break" +if { $this_thread != -1 } { + gdb_test {print $_thread} ".* = $this_thread" "thread var at break" +} else { + untested "thread var at break" +} return 0