Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Remote protocol extension for register ranges
@ 2000-03-22  5:51 Fernando Nasser
  2000-04-01  0:00 ` J.T. Conklin
  0 siblings, 1 reply; 3+ messages in thread
From: Fernando Nasser @ 2000-03-22  5:51 UTC (permalink / raw)
  To: gdb, jtc, Andrew Cagney, taruna, Eric Bachalo

Presently, the remote protocol can only read all registers of a target. 
This is OK for the context registers (the ones that are saved by the OD
on a context switch) but this is a serious limitation for machines that
have lots of additional registers.  It is just not feasible to read them
all at every "g" packet.

I would like to add parameters to the "g" packet.  Something similar has
been proposed before -- the only difference is that I would like the
parameters to be a register number or a register number range range.  

For instance: 

g82      Reads register 82
g31-40   Reads registers 31-40

Gdb would test for the acceptance of these types of packets by the stub
and fall back to the less efficient form if not (like it does for "P"
packets).

I really need this feature as do other people that are dealing with one
of the numerous microprocessors that have too many extra registers.  And
it is becoming quite urgent now.

What is the current thinking about this?  Are there other proposals I am
not aware of?  What are the maintainers position?

-- 
Fernando Nasser
Red Hat, Inc. - Toronto                 E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300           Tel:  416-482-2661 ext. 311
Toronto, Ontario   M4P 2C9              Fax:  416-482-6299
From jtc@redback.com Wed Mar 22 08:26:00 2000
From: jtc@redback.com (J.T. Conklin)
To: Fernando Nasser <fnasser@redhat.com>
Cc: gdb@sourceware.cygnus.com, Andrew Cagney <cagney@cygnus.com>, taruna@redhat.com, Eric Bachalo <ebachalo@cygnus.com>
Subject: Re: Remote protocol extension for register ranges
Date: Wed, 22 Mar 2000 08:26:00 -0000
Message-id: <5m66ufj7ii.fsf@jtc.redbacknetworks.com>
References: <38D8CFA4.C3535C93@redhat.com>
X-SW-Source: 2000-03/msg00306.html
Content-length: 4736

>>>>> "Fernando" == Fernando Nasser <fnasser@redhat.com> writes:
Fernando> Presently, the remote protocol can only read all registers
Fernando> of a target.  This is OK for the context registers (the ones
Fernando> that are saved by the OD on a context switch) but this is a
Fernando> serious limitation for machines that have lots of additional
Fernando> registers.  It is just not feasible to read them all at
Fernando> every "g" packet.

If a target has so many registers that you don't want to read them all
with the "g" command packet, I believe you are going to need something
similar for the "G" command packet.  Otherwise, any read/modify/write
operations GDB does will end up reading and writing the entire set.

Fernando> I would like to add parameters to the "g" packet.  Something
Fernando> similar has been proposed before -- the only difference is
Fernando> that I would like the parameters to be a register number or
Fernando> a register number range range.

You could probably get away with adding parameters to the "g" command
packet --- as far as I can tell none of the sample stubs completely
parse the command.  But if GDB sent "g" command packet containing a
register range to such stubs, it would get the entire register set.
You would have to write a some sort of run time test to determine
whether it handled register ranges.

Adding parameters to the "G" command packet is more troublesome ---
the register values immediately follow the command character.

For these reasons, I recommend implementing a new set of commands
which would deprecate G/g/P/p.

Perhaps something like:

   Get Registers:
        y<start>,<end>

   Set Registers:
        Y<start>,<end>,<register-contents>

But while we are adding commands, we might want to consider whether
there are any other arguments we should add.  

One that comes to mind is a thread-id.  Currently, when we want to get
the registers from several threads on the target, GDB has to issue a 
set thread command before each store/fetch register command.  If the
thread-id was part of the request, it could significantly improve 
remote protocol performance, especially on low-bandwidth and/or high
latency connections.

For amusement purposes only, I've enclosed the store and fetch
sections from the specification I've been writing for a replacement
remote protocol.  Other than the register ranges being specified by
offset and length, it's pretty much the same as the above.

        --jtc


4.1 REGISTER FETCH

input:
	context_t	id;
	int		offset;		offset within register data
	int		length;		length of transfer

output:
	int		status;
	char		data[];

This command may yeild unpredicable results if context <id> has not
been suspended.

issues:
	This assumes a single flat address space for all registers.
	It might be convienent to have separate (but potentially
	overlapping) register files for integer registers, floating
	point registers, system registers, miscellaneous registers,
	etc.  

        For example, one register file could contain the PC, FP, SP,
        and whatever other registers are needed on a particular
	architecture for GDB after a signal/exception/breakpoint
	event.  This would solve the problem of what to return in 
	those events.


4.2 REGISTER STORE

input:
	context_t	id;
	int		offset;		offset within register data
	int		length;		length of transfer
	char		data[];

output:
	int		status;

This command may cause unpredictable behavior if context <id> has not
been suspended.

issues:
	see also register fetch.


4.3 MEMORY FETCH

input:
	addr_t		address;	address of transfer
	int		length;		length of transfer
	mode_t		mode;

output:
	int		status;
	char		data[length];

description:
	Returns the contents of the memory region at <address> through
	<address> + <length>.

This command may yeild unpredictable results if all contexts which
access this memory region have not been suspended (unless some mutual
exclusion mechanism is employed).

issues:
	should this command take a "address space" argument?  This
	might be useful for I/O space and bus spaces.  If so, should
	registers simply be considered a "space".

issues:
	should this command take a context id argument as well?  This
	might be desirable if different contexts can have different
	memory mappings.


4.4 MEMORY STORE

input:
	addr_t		address;	address of transfer
	int		length;		length of transfer
	mode_t		mode;
	char		data[length];

output:
	int		status;

description:
	Writes data[] at <address> through <address> + <length>

This command may cause unpredictable results if all contexts which
access this memory have not been suspended (unless some mutual
exclusion mechanisms is employed).

issues:
	see also memory fetch.


-- 
J.T. Conklin
RedBack Networks
From eliz@delorie.com Wed Mar 22 10:10:00 2000
From: Eli Zaretskii <eliz@delorie.com>
To: Jim Blandy <jimb@zwingli.cygnus.com>
Cc: hjl@lucon.org, gdb@sourceware.cygnus.com, gdb-patches@sourceware.cygnus.com
Subject: Re: Problems with hardware watchpoint on ia32.
Date: Wed, 22 Mar 2000 10:10:00 -0000
Message-id: <200003221806.NAA14225@indy.delorie.com>
References: <20000307132401.A20282@valinux.com> <200003081008.FAA16481@indy.delorie.com> <20000308084304.A3150@lucon.org> <200003091210.HAA19857@indy.delorie.com> <npya7c6zn7.fsf@zwingli.cygnus.com>
X-SW-Source: 2000-03/msg00307.html
Content-length: 724

> Eli's test of the value's type is incorrect if the watch expression
> contains a structure comparison, like (foo == bar) || (something
> else), where foo and bar are structures.  In that case, there will be
> a value of type "struct", not at the end of the value list, but which
> should be watched in its entirety.

Errr... do you have an actual example program where this happens?

I seem to be unable to reproduce the problem, at least in a C program:
whenever I say "watch foo == bar" (where foo and bar are structs), GDB
curses thusly:

	Structure has no component named operator==.

Am I missing something?

In case it matters, I tested this with a DJGPP-compiled program; DJGPP
by default uses COFF debugging info.
From fnasser@redhat.com Wed Mar 22 11:41:00 2000
From: Fernando Nasser <fnasser@redhat.com>
To: jtc@redback.com
Cc: gdb@sourceware.cygnus.com, Andrew Cagney <cagney@cygnus.com>, taruna@redhat.com, Eric Bachalo <ebachalo@cygnus.com>
Subject: Re: Remote protocol extension for register ranges
Date: Wed, 22 Mar 2000 11:41:00 -0000
Message-id: <38D921AC.A133F89D@redhat.com>
References: <38D8CFA4.C3535C93@redhat.com> <5m66ufj7ii.fsf@jtc.redbacknetworks.com>
X-SW-Source: 2000-03/msg00308.html
Content-length: 3811

"J.T. Conklin" wrote:
> 
> >>>>> "Fernando" == Fernando Nasser <fnasser@redhat.com> writes:
> Fernando> Presently, the remote protocol can only read all registers
> Fernando> of a target.  This is OK for the context registers (the ones
> Fernando> that are saved by the OD on a context switch) but this is a
> Fernando> serious limitation for machines that have lots of additional
> Fernando> registers.  It is just not feasible to read them all at
> Fernando> every "g" packet.
> 
> If a target has so many registers that you don't want to read them all
> with the "g" command packet, I believe you are going to need something
> similar for the "G" command packet.  Otherwise, any read/modify/write
> operations GDB does will end up reading and writing the entire set.
> 
I agree.  But as you say below, the G packet is a little more complex
and 
we have the P packet already.  I was planning on using P for writes.



> Fernando> I would like to add parameters to the "g" packet.  Something
> Fernando> similar has been proposed before -- the only difference is
> Fernando> that I would like the parameters to be a register number or
> Fernando> a register number range range.
> 
> You could probably get away with adding parameters to the "g" command
> packet --- as far as I can tell none of the sample stubs completely
> parse the command.  But if GDB sent "g" command packet containing a
> register range to such stubs, it would get the entire register set.
> You would have to write a some sort of run time test to determine
> whether it handled register ranges.
> 
Yes, the run time test (as it is done for P packets) is the idea.


> Adding parameters to the "G" command packet is more troublesome ---
> the register values immediately follow the command character.
> 
I was thinking of using 'P'...


> For these reasons, I recommend implementing a new set of commands
> which would deprecate G/g/P/p.
> 
> Perhaps something like:
> 
>    Get Registers:
>         y<start>,<end>
> 
>    Set Registers:
>         Y<start>,<end>,<register-contents>
> 

This may be a nice option, and I would not discard it for the future 
(although I am not sure how I would use it from gdb without mixing some
different levels of information).

I am just planning on making a very small change to gdb and one of the 
stubs so the registers can be shown.  I don't think I will be given much
time to do that so I have to keep it very simple.  That is why I would
still
rather do the 'g' extension (for now) to be able to work with register
numbers
(while an eventual "yY" would work with byte offsets).

Note that this does not precludes the implementation of "yY" later, as
they
have different parameter types (regno's and offsets).  And we extend the
existing
command with the current type of arguments while the new ones, when
implemented,
will have a different type.

> But while we are adding commands, we might want to consider whether
> there are any other arguments we should add.
> 
> One that comes to mind is a thread-id.  Currently, when we want to get
> the registers from several threads on the target, GDB has to issue a
> set thread command before each store/fetch register command.  If the
> thread-id was part of the request, it could significantly improve
> remote protocol performance, especially on low-bandwidth and/or high
> latency connections.
> 
This looks like a time saving operation.  But other people that are
doing
threads work will know better than me.

We can eventually add "t=NNNN,".  Its acceptance can be tested at run
time like the other optimizations/extensions.



-- 
Fernando Nasser
Red Hat, Inc. - Toronto                 E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300           Tel:  416-482-2661 ext. 311
Toronto, Ontario   M4P 2C9              Fax:  416-482-6299
From msnyder@cygnus.com Wed Mar 22 12:41:00 2000
From: Michael Snyder <msnyder@cygnus.com>
To: Eli Zaretskii <eliz@is.elta.co.il>
Cc: Jim Blandy <jimb@cygnus.com>, hjl@lucon.org, gdb@sourceware.cygnus.com, gdb-patches@sourceware.cygnus.com
Subject: Re: Problems with hardware watchpoint on ia32.
Date: Wed, 22 Mar 2000 12:41:00 -0000
Message-id: <38D92F29.A3D@cygnus.com>
References: <20000307132401.A20282@valinux.com> <200003081008.FAA16481@indy.delorie.com> <20000308084304.A3150@lucon.org> <200003091210.HAA19857@indy.delorie.com> <npya7c6zn7.fsf@zwingli.cygnus.com> <200003221806.NAA14225@indy.delorie.com>
X-SW-Source: 2000-03/msg00309.html
Content-length: 759

Eli Zaretskii wrote:
> 
> > Eli's test of the value's type is incorrect if the watch expression
> > contains a structure comparison, like (foo == bar) || (something
> > else), where foo and bar are structures.  In that case, there will be
> > a value of type "struct", not at the end of the value list, but which
> > should be watched in its entirety.
> 
> Errr... do you have an actual example program where this happens?
> 
> I seem to be unable to reproduce the problem, at least in a C program:
> whenever I say "watch foo == bar" (where foo and bar are structs), GDB
> curses thusly:
> 
>         Structure has no component named operator==.

Argh... gdb does not seem to know that struct compare
is permitted.  I'll publish a patch.

				Michael Snyder
From jtc@redback.com Wed Mar 22 15:54:00 2000
From: jtc@redback.com (J.T. Conklin)
To: Fernando Nasser <fnasser@redhat.com>
Cc: gdb@sourceware.cygnus.com, Andrew Cagney <cagney@cygnus.com>, taruna@redhat.com, Eric Bachalo <ebachalo@cygnus.com>
Subject: Re: Remote protocol extension for register ranges
Date: Wed, 22 Mar 2000 15:54:00 -0000
Message-id: <5mwvmuef3j.fsf@jtc.redbacknetworks.com>
References: <38D8CFA4.C3535C93@redhat.com> <5m66ufj7ii.fsf@jtc.redbacknetworks.com> <38D921AC.A133F89D@redhat.com>
X-SW-Source: 2000-03/msg00310.html
Content-length: 3384

>>>>> "Fernando" == Fernando Nasser <fnasser@redhat.com> writes:
>> If a target has so many registers that you don't want to read them all
>> with the "g" command packet, I believe you are going to need something
>> similar for the "G" command packet.  Otherwise, any read/modify/write
>> operations GDB does will end up reading and writing the entire set.

Fernando> I agree.  But as you say below, the G packet is a little
Fernando> more complex and we have the P packet already.  I was
Fernando> planning on using P for writes.

How are you planning on changing remote.c to issue your new fetch
multiple registers command?  The target interface for fetching and
storing registers only supports fetch/storing one or all registers?
There's a deferred store mechanism in the sparc port, but I can not
see anything that fetches a subset of registers.

I'm concerned that if you have a fetch multiple registers command
without a corresponding store multiple registers command, you might
see situations where after reading and modifying a set of registers,
GDB may have to issue many, many P commands.  As a result, fetching
and storing all registers could yeild better overall performance due
to command latency.  I saw this doing inferior function calls with
powerpc-eabi-gdb when I added support for P command packet to our
debug stub.

>> For these reasons, I recommend implementing a new set of commands
>> which would deprecate G/g/P/p.
>> 
>> Perhaps something like:
>> 
>> Get Registers:
>> y<start>,<end>
>> 
>> Set Registers:
>> Y<start>,<end>,<register-contents>
>> 

Fernando> This may be a nice option, and I would not discard it for
Fernando> the future (although I am not sure how I would use it from
Fernando> gdb without mixing some different levels of information).

Fernando> I am just planning on making a very small change to gdb and
Fernando> one of the stubs so the registers can be shown.  I don't
Fernando> think I will be given much time to do that so I have to keep
Fernando> it very simple.  That is why I would still rather do the 'g'
Fernando> extension (for now) to be able to work with register numbers
Fernando> (while an eventual "yY" would work with byte offsets).

Whether register numbers vs. byte offsets and lengths are used is not
that important.  Although my protocol description used offsets, after
thinking about it a while I think I prefer register numbers.  Numbers
are already used in the P command packet, and they avoid any issues
with ranges that contain only parts of registers.

I would think that using new command packets would be the fastest way
to accomplish what you want.  You won't have to autonegotiate whether
a debug stub's 'g' command supports a register range.  

Regardless of whether this is implemented as a new command or as a
extension of the 'g' command, I believe it should always specify a
register range.  If you need to fetch a single register, send a range
where that register is both the start and end point; or implement the
'p' command --- fetch single register.

IMO whether you have a day or a year to implement this change has no
bearing on whether a change to the remote protocol should be made.
Every protocol change has a permanence that goes far beyond today's
deadlines.  Far too many changes have been made to the protocol
without full consideration.

        --jtc

-- 
J.T. Conklin
RedBack Networks
From ac131313@cygnus.com Wed Mar 22 23:53:00 2000
From: Andrew Cagney <ac131313@cygnus.com>
To: Fernando Nasser <fnasser@redhat.com>, "J.T. Conklin" <jtc@redbacknetworks.com>
Cc: gdb@sourceware.cygnus.com
Subject: Re: Remote protocol extension for register ranges
Date: Wed, 22 Mar 2000 23:53:00 -0000
Message-id: <38D9CADE.2FF02871@cygnus.com>
References: <38D8CFA4.C3535C93@redhat.com>
X-SW-Source: 2000-03/msg00311.html
Content-length: 3795

Fernando Nasser wrote:
> 
> Presently, the remote protocol can only read all registers of a target.
> This is OK for the context registers (the ones that are saved by the OD
> on a context switch) but this is a serious limitation for machines that
> have lots of additional registers.  It is just not feasible to read them
> all at every "g" packet.
> 
> I would like to add parameters to the "g" packet.  Something similar has
> been proposed before -- the only difference is that I would like the
> parameters to be a register number or a register number range range.
> 
> For instance:
> 
> g82      Reads register 82
> g31-40   Reads registers 31-40
> 
> Gdb would test for the acceptance of these types of packets by the stub
> and fall back to the less efficient form if not (like it does for "P"
> packets).
> 
> I really need this feature as do other people that are dealing with one
> of the numerous microprocessors that have too many extra registers.  And
> it is becoming quite urgent now.
> 
> What is the current thinking about this?  Are there other proposals I am
> not aware of?  What are the maintainers position?

FYI, I had two potential ideas in mind.  Which I prefer depends on the
target I'm hacking on.

1.	gG like mM

	Treat the target register file like
	a separate section of memory.

	Without arguments, gG would transfer
	the first few registers.

	With arguments (offset, length) a
	sub section of the register file
	could be transfered.

	If read section was supported, write
	section had to also be supported.

	The first obvious optomization
	would be to read a packet of registers
	when ever a single register was
	requested.

	The problem is that the data
	is very raw.  Embedded hardware
	stores registers in target byte-ordered
	register files.  Remote simulators
	and ICEs like to handle host
	ordered structures.  That raw target
	offset would have to be maped onto
	a sequence of host array elements.


2.	like pP

	The second option would be to
	extend/fix the pP packets (or
	a successor) so that they could
	take a range of registers
	and would use *NETWORK* byte
	ordering.

	Such a system would be good
	for small register transfers
	It could certainly be taught
	to pull in a range of registers
	when only one is asked for.
	The target could even be
	given that freedom: Register
	six please; Certainly, along
	with registers 0..5, 7..9.

	It would be more natural to
	simulators, ICEs and the like
	where the raw data tends to
	come in host structured chunks.

	I guess I could also live with
	pP just being extended.

	Be wary of ``-''.  In some
	situtations the stub can parse it
	as a negative number.


Refering to follow-on threads^D^D^D^D postings:

I note the gG proposal above is like J.T.s ``Y'' proposal - perhaphs
J.T.s posted his suggestion before and I've just picked it up :-/ 
W.R.T. detecting support in the ``gG'' packet, provided the fetch works,
the send would have to work.

The idea to include the ``context'' (J.T.s word) in the request is
interesting.  At present, switching ``contexts'' implicitly switches
both the address space and the register file.  We'd need to figure out
if all commands should take that.  J.T. Have you ever thought of a cpu
as a context?  Considered the possibility of different contexts having
different architectures?

When it comes to:
        It might be convienent to have separate (but potentially
        overlapping) register files for integer registers, floating
        point registers, system registers, miscellaneous registers,
        etc.
I think the register file should contain the raw minimum (no
overlapping).  GDB has to get its act to gether and better handle
overlapping registers.
	
What would I suggest?  Both of course .... :-)  They are solving
different problems.

	Andrew
From guo@cup.hp.com Thu Mar 23 11:53:00 2000
From: Jimmy Guo <guo@cup.hp.com>
To: gdb@sourceware.cygnus.com
Subject: gdb.gdbtk tests
Date: Thu, 23 Mar 2000 11:53:00 -0000
Message-id: <Pine.LNX.4.10.10003231245280.9146-100000@hpcll168.cup.hp.com>
X-SW-Source: 2000-03/msg00312.html
Content-length: 565

These tests apparently require top level tk/, tix/, itcl/, and libgui/
(the Cygnus GUI) components be present in the source tree (per
gdb/testsuite/lib/gdb.exp (gdbtk_start)).  Will these components be part
of public tree any time soon?

Besides, it's better to have a sanity check routine testing all
dependencies before even trying gdb_compile, like the skip_hp_tests one.

Some codes like below will be better:

set path [file join <whatever path>]
if ![file isdirectory $path] {
   perror <error message>
   return 1 (or exit 1)
}

- Jimmy Guo, guo@cup.hp.com


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

end of thread, other threads:[~2000-04-01  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-22  5:51 Remote protocol extension for register ranges Fernando Nasser
2000-04-01  0:00 ` J.T. Conklin
2000-04-01  0:00   ` Fernando Nasser

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