From: Joel Brobecker <brobecker@adacore.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFA: implement all missing macro expansion features
Date: Sat, 20 Sep 2008 00:19:00 -0000 [thread overview]
Message-ID: <20080920001852.GC23372@adacore.com> (raw)
In-Reply-To: <m3fxoxghw5.fsf@fleche.redhat.com>
:REVIEWMAIL:
> 2008-08-22 Tom Tromey <tromey@redhat.com>
>
> * macrocmd.c (extract_identifier): Add is_parameter argument.
> (macro_define_command): Update.
> (macro_undef_command): Likewise.
> * macroexp.c (stringify): New function.
> (find_parameter): Likewise.
> (gather_arguments): Add nargs argument. Handle varargs.
> (substitute_args): Add is_varargs and va_arg_name arguments.
> Handle varargs, splicing, stringification. Use find_parameter.
> (expand): Handle varargs.
Would anyone who is familiar with C macros like to take a look at
this one too? I looked at it, and it looks fine to me. In fact,
I must compliment Tom on his very nice style with lots of nice comments
explaining what he does. Very nice!
Tom, give it a few more days to see if we have any reaction, and
then go ahead and commit (let's not count the weekend, though).
> 2008-08-21 Tom Tromey <tromey@redhat.com>
>
> * gdb.base/macscp.exp: Add tests for stringification, splicing,
> and varargs.
This is OK too.
>
> diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c
> index 8213c0d..9a4fdee 100644
> --- a/gdb/macrocmd.c
> +++ b/gdb/macrocmd.c
> @@ -197,18 +197,36 @@ skip_ws (char **expp)
> ++*expp;
> }
>
> +/* Try to find the bounds of an identifier. If an identifier is
> + found, returns a newly allocated string; otherwise returns NULL.
> + EXPP is a pointer to an input string; it is updated to point to the
> + text following the identifier. If IS_PARAMETER is true, this
> + function will also allow "..." forms as used in varargs macro
> + parameters. */
> static char *
> -extract_identifier (char **expp)
> +extract_identifier (char **expp, int is_parameter)
Thanks for adding the comment describing the function. Can you add an
extra empty line before the function declaration?
> +/* A helper function for substitute_args. If the token TOK is the
> + name of a parameter, return the parameter's index. ARGV is a
> + vector of all the arguments; ARGC is the number of arguments. If
> + TOK is not an argument, return -1. */
> +static int
> +find_parameter (const struct macro_buffer *tok,
> + int is_varargs, const struct macro_buffer *va_arg_name,
> + int argc, const char * const *argv)
Same here. And perhaps if you wouldn't mind describing the IS_VARARGS
and VA_ARG_NAME parameters...
> + /* Is this token the splicing operator? */
> + else if (tok.len == 2
> + && tok.text[0] == '#'
> + && tok.text[1] == '#')
> + {
> + /* Just ignore a stray token splicing operator. Really this
> + is an error, but there's no reason to penalize the
> + user. */
> + }
I don't see how this would be penalizing the user. when could this
error actually happen? I assume that the compiler would reject an
incorrect expression, so it would only happen when defining the
macro in GDB? If it were the case, I would rather error out and
tell the user to fix its expression. Or perhaps can this happen
after expansion?
--
Joel
next prev parent reply other threads:[~2008-09-20 0:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-22 16:01 Tom Tromey
2008-09-20 0:19 ` Joel Brobecker [this message]
2008-09-20 4:55 ` Tom Tromey
2008-09-20 15:19 ` Joel Brobecker
2008-09-20 21:56 ` Tom Tromey
2008-09-21 3:13 ` Eli Zaretskii
2008-09-21 3:25 ` Tom Tromey
2008-09-21 18:01 ` Eli Zaretskii
2008-09-21 6:08 ` Joel Brobecker
2008-09-27 21:39 ` Tom Tromey
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=20080920001852.GC23372@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.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