From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12222 invoked by alias); 21 Jan 2015 17:07:45 -0000 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 Received: (qmail 12207 invoked by uid 89); 21 Jan 2015 17:07:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 21 Jan 2015 17:07:40 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0LH7cSm022765 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 21 Jan 2015 12:07:38 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0LH7aCH028407; Wed, 21 Jan 2015 12:07:37 -0500 Message-ID: <54BFDCD8.9090709@redhat.com> Date: Wed, 21 Jan 2015 17:07:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Mark Wielaard CC: Stan Shebs , gdb-patches@sourceware.org Subject: Re: [PATCH] Use GCC5/DWARF5 DW_AT_noreturn to mark functions that don't return normally. References: <1417099980-31834-1-git-send-email-mjw@redhat.com> <5480696F.1060308@redhat.com> <1418122161.18974.42.camel@bordewijk.wildebeest.org> <548745FD.40000@earthlink.net> <1418210696.5011.10.camel@bordewijk.wildebeest.org> <548AC7C3.9020000@redhat.com> <1421366172.26117.29.camel@bordewijk.wildebeest.org> In-Reply-To: <1421366172.26117.29.camel@bordewijk.wildebeest.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-01/txt/msg00574.txt.bz2 On 01/15/2015 11:56 PM, Mark Wielaard wrote: > create mode 100644 gdb/testsuite/gdb.base/noreturn.c > create mode 100644 gdb/testsuite/gdb.base/noreturn.exp How about "noreturn-return.{c|exp}", to go with noreturn_finish ? > create mode 100644 gdb/testsuite/gdb.base/noreturn_finish.c > create mode 100644 gdb/testsuite/gdb.base/noreturn_finish.exp But please use '-' instead of '_': gdb/testsuite/gdb.base/noreturn-finish.c gdb/testsuite/gdb.base/noreturn-finish.exp > diff --git a/gdb/testsuite/gdb.base/noreturn.c b/gdb/testsuite/gdb.base/noreturn.c > new file mode 100644 > index 0000000..e39cf15 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/noreturn.c > @@ -0,0 +1,13 @@ Please add a copyright header. Even though some of our old files don't have it, all new files should, even if the file is small (so that we don't have to recall adding it back if the file grows in future). > +void __attribute__((noreturn)) > +noreturn_func () noreturn_func (void) > +{ > + while (1) > + ; Please don't make the test loop forever if GDB crashes. Does e.g., "abort()" like the other test work here too? > +} > + > +int > +main () likewise (void) > +{ > + noreturn_func (); > + return 0; > +} > diff --git a/gdb/testsuite/gdb.base/noreturn.exp b/gdb/testsuite/gdb.base/noreturn.exp > new file mode 100644 > index 0000000..885642f > --- /dev/null > +++ b/gdb/testsuite/gdb.base/noreturn.exp > @@ -0,0 +1,54 @@ > +# Copyright 2015 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +standard_testfile .c You can drop the ".c", as it's the default. > + > +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { > + untested noreturn.exp > + return -1 > +} Use prepare_for_testing, like: if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug}] { return -1 } > + > +proc noreturn_test { } { > + global gdb_prompt > + > + if { ! [ runto_main ] } then { > + untested noreturn.exp Use $testfile, like "untested ${testfile}.exp". > + return -1 > + } > + > + gdb_test "break noreturn_func" "Breakpoint \[0123456789\].*" \ > + "set break on noreturn_func" > + gdb_test "continue" "Breakpoint.* noreturn_func.*" \ > + "continue to noreturn_func" gdb_breakpoint "noreturn_func" gdb_continue_to_breakpoint "noreturn_func" > + > + gdb_test_multiple "return" "return from noreturn_func" { > + -re "warning: Function does not return normally to caller" { > + verbose -log "saw warning" > + exp_continue > + } > + -re "Make noreturn_func return now.*y or n. $" { > + send_gdb "n\n" > + exp_continue > + } > + -re "Not confirmed.*$gdb_prompt $" { > + pass "noreturn_func return cancelled" > + } Make the test message be the same in all paths, like: set test "return from noreturn_func" gdb_test_multiple "return" $test { -re "warning: Function does not return normally to caller" { verbose -log "saw warning" exp_continue } -re "Make noreturn_func return now.*y or n. $" { send_gdb "n\n" exp_continue } -re "Not confirmed.*$gdb_prompt $" { pass $test } > + } > +} > + > +clean_restart ${binfile} prepare_for_testing does this for you. > + > +set timeout 30 I don't see why this is necessary. I think this is just a copy/paste? > +noreturn_test > diff --git a/gdb/testsuite/gdb.base/noreturn_finish.c b/gdb/testsuite/gdb.base/noreturn_finish.c > new file mode 100644 > index 0000000..cd52769 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/noreturn_finish.c > @@ -0,0 +1,14 @@ > +#include > + > +void __attribute__((noreturn)) > +noreturn_func () > +{ > + abort (); > +} > + > +int > +main () > +{ > + noreturn_func (); > + return 0; > +} Same comments apply to noreturn_finish.c|exp. Otherwise OK. Thanks, Pedro Alves