This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC/RFA PATCH] Constify strings in tracepoint.c, lookup_cmd and the completers.
- From: Tom Tromey <tromey at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 13 Mar 2013 11:28:51 -0600
- Subject: Re: [RFC/RFA PATCH] Constify strings in tracepoint.c, lookup_cmd and the completers.
- References: <20130313123205.31184.43525.stgit@brno.lan>
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> That ended up constifying lookup_cmd/add_cmd and (lots of) friends,
Pedro> and the completers.
Very nice. I'd like to see it go in.
A few trivial nits below.
Pedro> I didn't try to constify the command hooks themselves, because I know
Pedro> upfront there are commands that write to the command string argument,
Pedro> and I think I managed to stop at a nice non-hacky split point already.
Yeah, I think changing the commands difficult to do incrementally.
I have a trick I'm playing with to let it work file-by-file; but really
this just shows that a lot of plumbing has to be constified first...
Pedro> I think the only non-really-super-obvious changes are
Pedro> tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions.
In trace_dump_actions, I think that the "line" local variable is now
dead, and the code would be clearer if you just removed it.
Pedro> +static struct expression *
Pedro> +parse_exp_in_context (const char **stringptr, CORE_ADDR pc, const struct block *block,
Over-long line.
Pedro> +parse_exp_in_context_1 (char **stringptr, CORE_ADDR pc, const struct block *block,
Here too.
Pedro> @@ -1402,8 +1408,10 @@ x_command (char *exp, int from_tty)
Pedro> if (exp && *exp == '/')
Pedro> {
Pedro> - exp++;
Pedro> - fmt = decode_format (&exp, last_format, last_size);
Pedro> + const char *tmp = exp + 1;
Pedro> +
Pedro> + fmt = decode_format (&tmp, last_format, last_size);
Pedro> + exp = (char *) tmp;
I see x_command can't have the same "char *arg" treatment as
display_command:
/* Cause expression not to be there any more if this command is
repeated with Newline. But don't clobber a user-defined
command's definition. */
if (from_tty)
*exp = 0;
Gross!
Tom