From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97537 invoked by alias); 23 Sep 2018 21:34:15 -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 97521 invoked by uid 89); 23 Sep 2018 21:34:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 spammy=type_name, Done X-HELO: mailsec102.isp.belgacom.be Received: from mailsec102.isp.belgacom.be (HELO mailsec102.isp.belgacom.be) (195.238.20.98) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 23 Sep 2018 21:34:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1537738451; x=1569274451; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=JcZFHcOJfT11pnCMjSQs8CJeczyi10P8eOjaA76Urhw=; b=Q09IlYtDGBj21DePHdDwUnYllXKqjb877KYfSOmggSD6KHotRHFBx/bC wjgP2QwjArNkQ1HJPB8N3V0ZxVOMog==; Received: from 148.211-243-81.adsl-dyn.isp.belgacom.be (HELO md) ([81.243.211.148]) by relay.skynet.be with ESMTP/TLS/AES256-GCM-SHA384; 23 Sep 2018 23:34:09 +0200 Message-ID: <1537738449.2426.1.camel@skynet.be> Subject: Re: [RFAv2 3/6] Add [-q] [-t TYPEREGEXP] [NAMEREGEXP] args to info [args|functions|locals|variables] From: Philippe Waroquiers To: Tom Tromey Cc: gdb-patches@sourceware.org Date: Sun, 23 Sep 2018 21:34:00 -0000 In-Reply-To: <874lemu7kz.fsf@tromey.com> References: <20180826165359.1600-1-philippe.waroquiers@skynet.be> <20180826165359.1600-4-philippe.waroquiers@skynet.be> <874lemu7kz.fsf@tromey.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-09/txt/msg00784.txt.bz2 Feedback below ... RFAv3 will follow soon Thanks for the comments. Philippe On Tue, 2018-09-18 at 09:51 -0600, Tom Tromey wrote: > > > > > > "Philippe" == Philippe Waroquiers writes: > > Philippe> As stack.h now uses a type defined in gdb_regex.h, all files including stack.h > Philippe> need to include gdb_regex.h. > > It's better to just include gdb_regex.h from stack.h in this situation. Done (rather, no need anymore for regexp in stack.h). > > Philippe> + if (preg > > I think preg.has_value (). gdb is trending away from these bool > conversions, I think. At least that's been the style for pointers. > > Philippe> + if (treg > > Here too. Done. > > Philippe> +/* Prepares the regular expression REG from REGEXP. > Philippe> + If REGEXP is NULL, it results in an empty regular expression. */ > Philippe> +static void > Philippe> +prepare_reg (const char *regexp, gdb::optional ®) > > Out parameters should be pointers in the gdb style. Done. > > Philippe> - iterate_over_block_local_vars (block, > Philippe> + iterate_over_block_local_vars (block, preg, treg, > Philippe> do_print_variable_and_value, > Philippe> &cb_data); > > iterate_over_block_local_vars already takes some opaque data that it > just passes through to the callback. So, I think there should not be > a need to add the regexp parameters directly to it. Instead they can be > put into the cb_data here. > > Philippe> void > Philippe> iterate_over_block_arg_vars (const struct block *b, > Philippe> + const gdb::optional &preg, > Philippe> + const gdb::optional &treg, > Philippe> iterate_over_block_arg_local_vars_cb cb, > Philippe> void *cb_data) > > Same here. Done: the preg/treg regexp have been put in the opaque cb_data, and regexp filtering logic has been moved to do_print_variable_and_value. > > Philippe> +/* Returns true if the type_name of symbol_type of SYM matches TREG. > Philippe> + If SYM has no symbol_type or symbol_name, returns false. */ > Philippe> + > Philippe> +bool > Philippe> +treg_matches_sym_type_name (const compiled_regex &treg, > Philippe> + const struct symbol *sym) > Philippe> +{ > Philippe> + if (language_mode == language_mode_auto) > Philippe> + language_def (SYMBOL_LANGUAGE (sym))->la_print_type > Philippe> + (sym_type, "", &printed_sym_type_name, > Philippe> + -1, 0, &default_ptype_flags); > > I think this won't actually work, because the type printing code is free > to use current_language. This is not good, but it is how it is. > > So instead I think what this should do is save and restore the current > language. IIRC there's a helper RAII class for that already. > > Then you can just call type_print and drop patch #2. Done. > > Philippe> +extern bool > Philippe> +treg_matches_sym_type_name (const compiled_regex &treg, > Philippe> + const struct symbol *sym); > > No newline after the "bool" for a declaration. Done. Thanks Philippe