Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Matt Rice <ratmice@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] PR 12999 info macros command.
Date: Tue, 19 Jul 2011 17:29:00 -0000	[thread overview]
Message-ID: <m3d3h642de.fsf@fleche.redhat.com> (raw)
In-Reply-To: <CACTLOFot6DnZj173bQTLEqW=XzTDngjCLvpSZv4a-aCKfaLxog@mail.gmail.com>	(Matt Rice's message of "Mon, 18 Jul 2011 23:57:25 -0700")

>>>>> "Matt" == Matt Rice <ratmice@gmail.com> writes:

Matt> this patch adds 2 commands,
Matt> info macros LINESPEC
Matt> info definitions MACRO

Matt> the PR only asks for the former, but the latter seemed possibly useful.

Thanks, this is very nice.

Matt> +@kindex info definitions 
Matt> +@cindex macro definition, showing
Matt> +@cindex definition, showing a macro's
Matt> +@item info definitions @var{macro}
Matt> +Show all definitions of the macro named @var{macro}, in the current scope,
Matt> +and describe the source location or compiler command-line where those
Matt> +definitions were established.

I didn't understand what this did from this explanation.
I got confused because "in the current scope" would seem to restrict us
to a single definition.

I would reword it to say something about "all definitions of MACRO at or
before the indicated line in the indicated source file", or something to
that effect.

Matt> +print_macro_definition (const char *name,
Matt> +			const struct macro_definition *d,
Matt> +			struct macro_source_file *file,
Matt> +			int line)

Add an introductory comment.

Matt> +static void
Matt> +print_macro_callback (const char *name, const struct macro_definition *macro,
Matt> +		   struct macro_source_file *source, int line,
Matt> +		   void *user_data)

Likewise.

Matt> +  add_cmd ("macros", no_class, info_macros_command,
Matt> +	   _("Show the names of all macros at LINESPEC, or the current \
Matt> +scope."),
Matt> +	   &infolist);
Matt> +
Matt> +  add_cmd ("definitions", no_class, info_definitions_command,
Matt> +	   _("Show all definitions of the macro named MACRO in the\n\
Matt> +current scope."),
Matt> +	   &infolist);

I think the "definitions" one shouldn't have a \n in the help string.
The first sentence of the help is special, it should be on one line.
Also the text for "definitions" needs updating, following the docs.

I'd like it if the help for all new commands included a usage line,
e.g.:

Usage: info macros [LINESPEC]

Matt> --- a/gdb/macrotab.h
Matt> +++ b/gdb/macrotab.h
Matt> @@ -311,6 +311,8 @@ struct macro_source_file *(macro_definition_location
Matt>     or macro_for_each_in_scope.  */
Matt>  typedef void (*macro_callback_fn) (const char *name,
Matt>  				   const struct macro_definition *definition,
Matt> +				   struct macro_source_file *source,
Matt> +				   int line,
Matt>  				   void *user_data);

The comment just above this typedef needs an update.

Matt> +if [test_compiler_info gcc*] {
Matt> +    lappend options additional_flags=-g3
Matt> +} else {
Matt> +  return -1
Matt> +}

I think this should probably call 'untested' first.

Matt> +set test "info definitions FOO"
Matt> +gdb_test "$test" ".*#define FOO \"hello\".*" "info definitions FOO 1"
Matt> +gdb_test "$test" ".*#define FOO \" \".*" "info definitions FOO 2"
Matt> +gdb_test "$test" ".*#define FOO \"world\".*" "info definitions FOO 3"
Matt> +gdb_test "$test" ".*#define FOO\\(a\\) foo = a.*" "info definitions FOO 4"

As you mentioned on irc, this is weird.

How about just a single test with one big regexp that matches all the
output?  You can easily construct the regexp in pieces if that makes it
simpler.

Matt> +# info macros on the line where the #define or #include is
Matt> +# fails to find the macro defined (though it works on the next line.)
Matt> +setup_kfail "gdb/NNNN" *-*-*
Matt> +gdb_test "$test" ".*define ONE.*" "$test.2"

I suppose technically the macro is not actually defined until the next
line.  I don't think it matters much though, since the #define line will
never be executable anyhow.

Tom


  reply	other threads:[~2011-07-19 17:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-19  9:57 Matt Rice
2011-07-19 17:29 ` Tom Tromey [this message]
2011-07-20  2:06   ` Matt Rice
2011-07-20 14:14     ` Tom Tromey
2011-07-20 17:24 ` Eli Zaretskii
2011-07-21  6:47   ` Matt Rice
2011-07-21 10:22     ` Eli Zaretskii
2011-07-21 14:07     ` Tom Tromey
2011-07-21 15:56       ` Matt Rice
2011-07-21 16:13         ` Pedro Alves

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=m3d3h642de.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ratmice@gmail.com \
    /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