From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25421 invoked by alias); 4 Dec 2014 14:02:30 -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 25403 invoked by uid 89); 4 Dec 2014 14:02:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=no 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; Thu, 04 Dec 2014 14:02:26 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sB4E2PHN025193 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 4 Dec 2014 09:02:25 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sB4E2NxO004857; Thu, 4 Dec 2014 09:02:24 -0500 Message-ID: <5480696F.1060308@redhat.com> Date: Thu, 04 Dec 2014 14:02:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Mark Wielaard , 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> In-Reply-To: <1417099980-31834-1-git-send-email-mjw@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-12/txt/msg00091.txt.bz2 Hi Mark, Thanks for doing this. On 11/27/2014 02:53 PM, Mark Wielaard wrote: > Add a flag field is_noreturn to struct func_type. Make calling_convention > a small bit field to not increase the size of the struct. Set is_noreturn > if the new GCC5/DWARF5 DW_AT_noreturn is set on a DW_TAG_subprogram. > Use this information to warn the user before doing a finish or return from > a function that does not return normally to its caller. > > (gdb) finish > Warning. Function endless does not return normally. > Try to finish anyway? (y or n) > > (gdb) return > warning: Function does not return normally to caller! > Make endless return now? (y or n) I'd suggest making the warnings a bit more consistent. - "Warning." vs "warning: " Prefer the latter, as that's what the "warning" function uses. - "." vs "!" I'd keep it calm and get rid of the "!". :-) > > gdb/ChangeLog > > * dwarf2read.c (read_subroutine_type): Set TYPE_NO_RETURN from > DW_AT_noreturn. > * gdbtypes.h (struct func_type): Add is_noreturn field flag. Make > calling_convention an 8 bit bit field. > (TYPE_NO_RETURN): New macro. > * infcmd.c (finish_command): Query if function does not return > normally. > * stack.c (return_command): Likewise. > > include/ChangeLog > > * dwarf2.def (DW_AT_noreturn): New DWARF5 attribute. I wonder if we could have a test? Could e.g., make sure we don't crash when the user confirms a return in a noreturn function. > diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c > index 36cbbd9..56212e5 100644 > --- a/gdb/dwarf2read.c > +++ b/gdb/dwarf2read.c > @@ -14312,6 +14312,12 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) > else > TYPE_CALLING_CONVENTION (ftype) = DW_CC_normal; > > + /* Record whether the function returns normally to its caller or not > + if the DWARF producer set that information. */ > + attr = dwarf2_attr (die, DW_AT_noreturn, cu); > + if (attr && (DW_UNSND (attr) != 0)) if (attr != NULL && (DW_UNSND (attr) != 0)) > + TYPE_NO_RETURN (ftype) = 1; > + > /* We need to add the subroutine type to the die immediately so > we don't infinitely recurse when dealing with parameters > declared as the same subroutine type. */ > --- a/gdb/infcmd.c > +++ b/gdb/infcmd.c > @@ -1869,7 +1869,14 @@ finish_command (char *arg, int from_tty) > if (execution_direction == EXEC_REVERSE) > printf_filtered (_("Run back to call of ")); > else > - printf_filtered (_("Run till exit from ")); > + { > + if (function != NULL && TYPE_NO_RETURN (function->type) > + && ! query (_("Warning. Function %s does not return normally.\n" > + "Try to finish anyway? "), > + SYMBOL_PRINT_NAME (function))) > + error (_("Not confirmed.")); > + printf_filtered (_("Run till exit from ")); > + } No space between "!" and query: && !query ... > --- a/gdb/stack.c > +++ b/gdb/stack.c > @@ -2462,8 +2462,12 @@ return_command (char *retval_exp, int from_tty) > confirmed = query (_("%sMake selected stack frame return now? "), > query_prefix); > else > - confirmed = query (_("%sMake %s return now? "), query_prefix, > - SYMBOL_PRINT_NAME (thisfun)); > + { > + if (TYPE_NO_RETURN (thisfun->type)) > + warning ("Function does not return normally to caller!"); i18n / _() . Thanks, Pedro Alves