From: Pedro Alves <palves@redhat.com>
To: Doug Evans <dje@google.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH, doc RFA] Add "skip regexp"
Date: Thu, 04 Feb 2016 13:47:00 -0000 [thread overview]
Message-ID: <56B35656.9070505@redhat.com> (raw)
In-Reply-To: <94eb2c0b86103073b2052abf11e5@google.com>
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<char>::allocator (this=0x7fffffffe6bf)
> std::basic_string<char, std::char_traits<char>, std::allocator<char>
>> ::basic_string (this=0x7fffffffe6b0, __s=0x400ad1 "abc", __a=...)
> std::basic_string<char, std::char_traits<char>, std::allocator<char>
>> ::~basic_string (this=0x7fffffffe6b0, __in_chrg=<optimized out>)
> std::allocator<char>::~allocator (this=0x7fffffffe6bf, __in_chrg=<optimized
> 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
next prev parent reply other threads:[~2016-02-04 13:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-02 1:03 Doug Evans
2016-02-02 16:10 ` Eli Zaretskii
2016-02-04 13:47 ` Pedro Alves [this message]
2016-02-02 18:05 Doug Evans
2016-02-17 1:07 Doug Evans
2016-02-17 16:07 ` Eli Zaretskii
2016-02-29 18:55 ` Simon Marchi
2016-02-23 21:36 Doug Evans
2016-02-24 9:54 ` Joel Brobecker
2016-02-24 18:21 ` Doug Evans
2016-03-02 23:20 Doug Evans
2016-03-03 19:21 Doug Evans
2016-03-03 20:40 ` Simon Marchi
2016-03-15 19:45 Doug Evans
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56B35656.9070505@redhat.com \
--to=palves@redhat.com \
--cc=dje@google.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox