Re: [RFC 2/9] move some rsp bits into rsp-low.h

Pedro Alves
2014-02-05T20:33:28Z

On 01/20/2014 07:18 PM, Tom Tromey wrote:
> This moves various low-level remote serial protocol bits into
> common/rsp-low.[ch].
>
> This is as close to a pure move as possible. There are some
> redundancies remaining but those will be dealt with in a subsequent
> patch.
>
> Note that the two variants of remote_escape_output disagreed on the
> treatment of "*". On the theory that quoting cannot hurt but the
> absence possibly can, I chose the gdbserver variant to be the
> canonical one.

Hmm. This makes me a tiny bit nervous. What if some random
silly stub out there is checking that the resulting byte after
unescaping is one of '#', '$' or '}'? But maybe that's being
overzealous...

> +int
> +remote_unescape_input (const gdb_byte *buffer, int len,
> + gdb_byte *out_buf, int out_maxlen)
> +{
> + int input_index, output_index;
> + int escaped;
> +
> + output_index = 0;
> + escaped = 0;
> + for (input_index = 0; input_index < len; input_index++)
> + {
> + gdb_byte b = buffer[input_index];
> +
> + if (output_index + 1 > out_maxlen)
> + error ("Received too much data from the target.");

Note this loses i18n in GDB. Please add _(). Also, in
the GDB this particular error was actually warning, but
I think it's fine to make it an error. I also notice that
"target" in "from the target" isn't right in the gdbserver
case, but that's a preexisting minor issue.

> +
> + if (escaped)
> + {
> + out_buf[output_index++] = b ^ 0x20;
> + escaped = 0;
> + }
> + else if (b == '}')
> + escaped = 1;
> + else
> + out_buf[output_index++] = b;
> + }
> +
> + if (escaped)
> + error ("Unmatched escape character in target response.");

i18n.

> +
> + return output_index;
> +}
> +

> @@ -163,7 +163,8 @@ SFILES= $(srcdir)/gdbreplay.c $(srcdir)/inferiors.c $(srcdir)/dll.c \
> $(srcdir)/common/linux-osdata.c $(srcdir)/common/ptid.c \
> $(srcdir)/common/buffer.c $(srcdir)/common/linux-btrace.c \
> $(srcdir)/common/filestuff.c $(srcdir)/target/waitstatus.c \
> - $(srcdir)/common/mips-linux-watch.c $(srcdir)/common/cells.c
> + $(srcdir)/common/mips-linux-watch.c $(srcdir)/common/cells.c \
> + $(srcdir)/common/rsp-low.c

Something odd with indentation?

Otherwise, this looks fine to me.

--
Pedro Alves