Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* G packet format ...
@ 2001-11-01  9:37 Andrew Cagney
  2001-11-01 10:18 ` Daniel Jacobowitz
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Andrew Cagney @ 2001-11-01  9:37 UTC (permalink / raw)
  To: gdb

[-- Attachment #1: Type: text/plain, Size: 2731 bytes --]

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

[-- Attachment #2: reg.sh --]
[-- Type: text/plain, Size: 430 bytes --]

#!/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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2001-11-15 21:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-01  9:37 G packet format Andrew Cagney
2001-11-01 10:18 ` Daniel Jacobowitz
2001-11-01 10:30   ` Andrew Cagney
2001-11-01 10:58     ` Daniel Jacobowitz
2001-11-05  8:04       ` Andrew Cagney
2001-11-01 12:30 ` Fernando Nasser
2001-11-01 12:51   ` Andrew Cagney
2001-11-01 16:51 ` Frank Ch. Eigler
2001-11-02  0:37   ` Andrew Cagney
2001-11-05  8:19 ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox