From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106814 invoked by alias); 4 Feb 2016 13:47:07 -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 106801 invoked by uid 89); 4 Feb 2016 13:47:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*M:9070505, loud 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 Feb 2016 13:47:05 +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 (Postfix) with ESMTPS id D6172C0023B2; Thu, 4 Feb 2016 13:47:03 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u14Dl2Is027184; Thu, 4 Feb 2016 08:47:03 -0500 Message-ID: <56B35656.9070505@redhat.com> Date: Thu, 04 Feb 2016 13:47:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Doug Evans , gdb-patches@sourceware.org Subject: Re: [PATCH, doc RFA] Add "skip regexp" References: <94eb2c0b86103073b2052abf11e5@google.com> In-Reply-To: <94eb2c0b86103073b2052abf11e5@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-02/txt/msg00108.txt.bz2 On 02/02/2016 01:03 AM, Doug Evans wrote: > Hi. > > The "skip" command is great, but it can be really cumbersome to use with > c++. > > E.g., consider stepping into functions that take std::string arguments. > > foo (bar ("abc")); > > where bar takes a std::string argument. > > There are four functions you generally always want to skip in this case > (cut-n-pasted from my gdb session): > > std::allocator::allocator (this=0x7fffffffe6bf) > std::basic_string, std::allocator >> ::basic_string (this=0x7fffffffe6b0, __s=0x400ad1 "abc", __a=...) > std::basic_string, std::allocator >> ::~basic_string (this=0x7fffffffe6b0, __in_chrg=) > std::allocator::~allocator (this=0x7fffffffe6bf, __in_chrg= out>) > > With this patch one can specify the skip as: > > skip regexp ^std::(allocator|basic_string)<.*>::~?\1 *\( > > Skipping every templated class constructor/destructor in std > could be specified as: > > skip regexp ^std::([a-zA-z0-9_]+)<.*>::~?\1 *\( I think this is great. Thanks for tackling this. This was originally discussed in the context of the original implementation, but was left out: https://sourceware.org/bugzilla/show_bug.cgi?id=8287 I wonder about the UI though. The command name doesn't make it clear, so I was wondered whether "skip regexp" also matches the filename the function is implemented in. I figured out it doesn't from the documentation, but it got to me consider how we'd extend the UI if/when we want to skip files with a regexp too, as then "skip regexp" becomes ambiguous. Maybe "skip rfunction" instead, and then we'd have "skip rfile" ? Also, ot asking you to implement this, just thinking out loud, but I also wondered if it wouldn't have made more sense to be able to mix file and function names, using command options, rather than have distinct skip types. Like: skip -file foo.c -function foo skip -rfile libfoo/*.c -rfunction ^foo_.* I guess we could still have that and leave "skip function", etc. for compatibility. > > +skip regexp regular-expression > + A variation of "skip function" where the function name is specified > + as a regular expression. > + > +If you wanted to skip every C++ constructor and destructor in the > @code{std} > +namespace you could do: Using past tense reads a bit odd to me. I'd suggest: If you want to skip every C++ constructor and destructor in the @code{std} namespace you can do: > > +/* Return the name of the skiplist entry kind. */ > + > +static const char * > +skiplist_entry_kind_name (struct skiplist_entry *e) > +{ > + switch (e->kind) > + { > + case SKIP_FILE: return "file"; > + case SKIP_FUNCTION: return "function"; > + case SKIP_REGEXP: return "regexp"; > + default: > + gdb_assert_not_reached ("bad skiplist_entry kind"); > + } Line breaks before return. > +} > + > +/* Create a SKIP_FILE object. */ > + > +static struct skiplist_entry * > +make_skip_file (const char *name) > +{ > + struct skiplist_entry *e = XCNEW (struct skiplist_entry); > + > + e->kind = SKIP_FILE; > + e->text = xstrdup (name); > + e->enabled = 1; > + > + return e; > +} > + > +/* Create a SKIP_FUNCTION object. */ > + > +static struct skiplist_entry * > +make_skip_function (const char *name) > +{ > + struct skiplist_entry *e = XCNEW (struct skiplist_entry); > + > + e->kind = SKIP_FUNCTION; > + e->enabled = 1; > + e->text = xstrdup (name); > + > + return e; > +} > + > +/* Create a SKIP_REGEXP object. > + The regexp is not parsed, the caller must do that afterwards. */ > + > +static struct skiplist_entry * > +make_skip_regexp (const char *regexp) > +{ > + struct skiplist_entry *e = XCNEW (struct skiplist_entry); > + > + e->kind = SKIP_REGEXP; > + e->enabled = 1; > + e->text = xstrdup (regexp); > + > + return e; > +} > + Seems like all these three functions could be replaced by a single: static struct skiplist_entry * make_skiplist_entry (enum skip_kind kind, const char *text) { struct skiplist_entry *e = XCNEW (struct skiplist_entry); e->kind = kind; e->text = xstrdup (text); e->enabled = 1; return e; } Thanks, Pedro Alves