remote protocol extensions for reading and writing registers

J.T. Conklin jtc@redbacknetworks.com
Thu Dec 3 13:13:00 GMT 1998


After composing a patch that implements 'P' (set the value of one
register) in i386-stub.c, I noted that the remote protocol does not
define a corresponding command to read a specific register.  I have
not had a chance to see if this would be useful in practice, but it
should be reasonablely easy to implement.  As 'p' is available, it
could be used to complete the sequence 'G'/'g'/'P'/'p' for all
combinations of reading and writing registers.

I was also thinking of some alternative to obtaining all registers
when a subset is needed.  I had two contexts in mind: obtaining just
the control registers when returning from a step or continue, and
avoiding transferring FP, MMU, MMX, etc. registers when those are 
not in use or on a processor varient that doesn't include them.  

A stub that implements the 'T' response eliminates some of need for
this, since it can return whatever "important" registers are needed.
However, register read/write commands that can write subsets of all
the registers may be useful.  They may be even more useful when the
remote protocol is being used with another front end (perhaps a
monitor-like control panel)

Some ideas:
     * Define register "sets" that define a particular registers.  The
       new register read/write commands would operate on a set in the
       same way the global read/write operate today.

       read registers:	R<set-id>
       reply		XX....X

       write regs:	W<set-id>=XX....X
       reply		OK / ENN

       Possible sets are:
       0 - all registers
       1 - integer registers
       2 - FP registers
       3 - control registers???
       4 - MMX/multimedia registers

       As each set is represented by a number, the commands will be
       short; but the stub will have to contain a mapping of what
       registers are in each set and what their offset is.

     * Use a bitmask that represents what registers will be read or
       written in the transaction.

       read registers:	R<bitmask>
       reply		XX....X

       write regs:	W<bitmask>=XX....X
       reply		OK / ENN

       The width of the bitmask would have to be sufficent to represent
       all registers on a machine.  This may be excessive on machines
       with lots of registers.

     * Use a scheme like the 'T' response to read/write a sequence of
       registers.

       read registers:	Rn...;r...;n...;r...;n...;r...
       reply		XX....X

       write regs:	Wn...;r...;n...;r...;n...;r...=XX....X
       or:		Wn...;r...=XX..X;n...;r...=XX..X;n...;r...=XX..X
       reply		OK / ENN

       There's not much to recommend this scheme, as it exchanges long
       responses with long commands.


Thoughts?

	--jtc



More information about the Gdb mailing list