From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 44680 invoked by alias); 18 May 2018 19:38: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 44665 invoked by uid 89); 18 May 2018 19:38:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=legitimate, H*f:sk:cover.1 X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 May 2018 19:38:29 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 99A0B859AA; Fri, 18 May 2018 19:38:27 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3B26111670F; Fri, 18 May 2018 19:38:26 +0000 (UTC) Subject: Re: [PATCHv2 1/2] gdb: Split func_command into two parts. To: Andrew Burgess , gdb-patches@sourceware.org References: From: Pedro Alves Message-ID: <3378e45e-2da2-6eea-814a-86e6e565bf7a@redhat.com> Date: Fri, 18 May 2018 19:57:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-05/txt/msg00414.txt.bz2 On 05/08/2018 05:58 PM, Andrew Burgess wrote: > The func_command function is used to emulate the dbx 'func' command. > However, finding a stack frame based on function name might be a useful > feature, and so the core of func_command is now split out into a > separate function. > > gdb/ChangeLog: > > * stack.c (select_and_print_frame): Delete. > (func_command): Most content moved into new function > find_frame_for_function, use new function, print result, add > function comment. > (find_frame_for_function): New function, now returns a result. This LGTM, with a couple minor nits. > /* Return the symbol-block in which the selected frame is executing. > Can return zero under various legitimate circumstances. > @@ -2460,19 +2450,19 @@ struct function_bounds > CORE_ADDR low, high; > }; > > -static void > -func_command (const char *arg, int from_tty) > +static struct frame_info * > +find_frame_for_function (const char *function_name) There's a comment above the structure that is describing what the func_command function did. That needs to be updated to describe what the new function does. > + > +/* Implements the dbx 'func' command. */ > + > +static void > +func_command (const char *arg, int from_tty) > +{ > + struct frame_info *frame; > + > + if (arg == NULL) > + return; > + > + frame = find_frame_for_function (arg); You can declare and initialize at the same time: func_command (const char *arg, int from_tty) { if (arg == NULL) return; frame_info *frame = find_frame_for_function (arg); Thanks, Pedro Alves