This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
G packet format ...
- To: gdb at sources dot redhat dot com
- Subject: G packet format ...
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Mon, 12 Nov 2001 00:24:04 -0500
Hello,
For those that don't know, GDB's remote protocol G packet currently
determins the layout of GDB's internal register cache. Doh!
As part of breaking^D^D^Dfixing this, I'd like to introduce a new CLI
command that allows the user to specify the G packet (and in fact the
entire remote protocol numbering) at runtime.
The commands are:
set remote registers <spec>
and
show remote registers
(better names welcome). The interesting thing is the spec:
<spec> ::= <entry> { <sep> <entry> }* ;;
<entry> ::= <size> [ ":" <name> [ ":" <pnum> ] ] ;;
<sep> ::= ";" | "\n" ;;
Where:
<name> is the name of a raw register
<size> is the byte size of a register
<pnum> is the [Pp] register number
Eg:
8:r0
8:r1
4:r2
4
8:r3
4:spr0:1000
4:spr1
or:
8:r0;8:r1;4:r2;4;8:r3;;4:spr0:1000;4:spr1
GDBserver might use the first form (\n) while GDB's CLI would use the
second form.
For want of a better way to define the semantics, try the attached shell
script. What follows is an attempt at an english description:
The spec is divided into two parts separated by a blank entry.
Additional blank entries, after the first, are ignored.
The first part describes registers that are transfered via either the
[Gg] packets or the [Pp] packets. Each entry specifies a number of bytes
in the [Gg] packet and then, optionally, the GDB internal name
corresponding to those bytes. Unnamed entries are written as zero.
The second part describes registers that are only transferable via the
[Pp] packets. Size entries in this part of the spec are ignored.
The [Pp] packet register number of the first register is zero (unless
explicitly specified). The [Pp] packet register number of succeeding
registers, if not explicitly specified, is determined by adding one to
the previous register's number. (Yes ``1:r1:1000;;4:r0;0'', while
stupid, is still legal.)
If GDB's internal register is smaller than the packet specification then
high bits are discarded to fit.
If GDB's internal register is larger than the packet specification then
we've got a problem. A guess is zero extend unless a -ve size is
specified which would imply sign extend. Worry about this when it
actually happens.
--
NB: If you didn't catch on. GDB currently doesn't implement the ``read
single register'' packet yet this spec assumes this.
--
NB: Why do this?
The objective is to decouple the remote protocol's G packet from the
rest of GDB. That way, GDB has greater flexability in how it implements
its regcache. For instance, with the MIPS, it will be possible to have
a single internal register layout while still being able to connect to
all the remote MIPS targets.
--
comments, better suggestions, code?
Andrew
#!/bin/sh
pnum=0
offset=0
IFS=:
printf "name\tsize\tpnum\toffset\n"
while read size name num
do
if test x"${size}" = x; then
echo "--- END -- OF -- G -- PACKET --"
offset=
continue
fi
if test x"${num}" = x; then
num=${pnum}
fi
if test x"${name}" != x; then
printf "${name}\t${size}\t${num}\t${offset}\n"
fi
pnum=`expr ${num} + 1`
test "${offset}" && offset=`expr ${offset} + ${size}`
done