[PATCH] gdb output pipelining to shell

Eli Zaretskii eliz@gnu.org
Sat Jul 16 14:49:00 GMT 2011


> 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?



More information about the Gdb-patches mailing list