From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 105139 invoked by alias); 9 Jul 2018 19:16:05 -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 105030 invoked by uid 89); 9 Jul 2018 19:16:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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; Mon, 09 Jul 2018 19:15:56 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2193887A6C; Mon, 9 Jul 2018 19:15:55 +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 A36002026D65; Mon, 9 Jul 2018 19:15:54 +0000 (UTC) Subject: Re: [RFA_v3 2/8] Implement frame apply [all | COUNT | -COUNT | id ID... ] [FLAG]... COMMAND. To: Philippe Waroquiers , gdb-patches@sourceware.org References: <20180624183708.888-1-philippe.waroquiers@skynet.be> <20180624183708.888-3-philippe.waroquiers@skynet.be> From: Pedro Alves Message-ID: <922c099e-4580-d804-1357-907bbe0b90ad@redhat.com> Date: Mon, 09 Jul 2018 19:16:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180624183708.888-3-philippe.waroquiers@skynet.be> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-07/txt/msg00222.txt.bz2 On 06/24/2018 07:37 PM, Philippe Waroquiers wrote: > Implement frame apply [all | COUNT | -COUNT | id ID... ] [FLAG]... COMMAND. > Also implement the command 'faas COMMAND', a shortcut for > 'frame apply all -s COMMAND'. > > The syntax of 'frame apply' to specify some innermost or outermost > frames is similar to 'backtrace' command, using COUNT or -COUNT. > > To apply a COMMAND to a more specific set of frames, the following > new command and syntax can be used: > frame apply id ID... [FLAG]... COMMAND > where ID is one or more frame ids or range of frame ids. Thanks much for doing this. Other than the "id" / "level" thing, this looks mostly OK to me. One minor detail below. > + > +/* Implementation of the "frame apply id" command. */ > + > +static void > +frame_apply_id_command (const char *cmd, int from_tty) > +{ > + if (!target_has_stack) > + error (_("No stack.")); > + > + bool id_found = false; > + const char *ids = cmd; > + number_or_range_parser idls (ids); > + > + /* Skip the ID list to find the flags and command args. */ > + while (!idls.finished ()) > + { > + const int id_beg = idls.get_number (); > + > + id_found = true; > + if (idls.in_range ()) > + idls.skip_range (); > + } > + > + if (!id_found) > + error (_("Missing or invalid ID... argument")); > + > + cmd = idls.cur_tok (); > + > + /* Redo the IDLS parsing, but applying COMMAND. */ > + idls.init (ids); > + while (!idls.finished ()) > + { > + const int id_beg = idls.get_number (); > + int n_frames; > + > + if (idls.in_range ()) > + { > + n_frames = idls.end_value () - id_beg + 1; > + idls.skip_range (); > + } > + else > + n_frames = 1; > + > + frame_apply_command_count ("frame apply id", cmd, from_tty, > + leading_innermost_frame (id_beg), n_frames); I noticed that as is, frame_apply_command_count is going to parse CMD for parse_flags_qcs for every iteration. I wonder whether it wouldn't be clearer to split frame_apply_command_count after that CMD parsing to a separate function that is called by both frame_apply_id_command and frame_apply_command_count. Thanks, Pedro Alves