This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] gdb output pipelining to shell
- From: Eli Zaretskii <eliz at gnu dot org>
- To: Abhijit Halder <abhijit dot k dot halder at gmail dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Sat, 16 Jul 2011 12:47:00 +0300
- Subject: Re: [PATCH] gdb output pipelining to shell
- References: <CAOhZP9yENbwxY5e_VTwtWffqbZztCxemayS+eU7YH8hYQwPrDA@mail.gmail.com>
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
> Date: Sat, 16 Jul 2011 14:12:35 +0530
> From: Abhijit Halder <abhijit.k.halder@gmail.com>
>
> I have implemented a feature which will allow one to pass the output
> of any gdb command to the shell for further processing.
Thanks.
If this is accepted, we will need a corresponding addition to the
manual.
> + for (cpos = spos; (cpos = memchr (cpos, '"', (sh_cmd-cpos))) != NULL; cpos++)
> + quote_cnt++;
> + spos = (sh_cmd + 1);
> + if ((quote_cnt % 2) == 0 || (sh_cmd = strchr (spos, '|')) == NULL)
> + break;
I'm not sure I understand this (comments would be helpful). Are you
assuming that quote characters `"' in shell commands cannot be
escaped, e.g. with a backslash? And what about quoting with a single
quote character ("'")?
> + if (*cpos != '{')
> + return NULL;
> +
> + *cpos = ' ';
> +
> + cpos = epos;
> + while (isspace(*cpos))
> + cpos--;
> +
> + if (*cpos != '}')
> + return NULL;
What is this magic about {...} that you are removing? Again, comments
could help.
> +
> + *cpos = ' ';
> + }
> +
> + if (sh_cmd)
> + *sh_cmd++ = '\0';
> +
> + return sh_cmd;
This butchers the string passed to execute_command. Are you sure all
the callers of execute_command can safely deal with that? What if the
string is a constant string, for example?