Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* byte word and int(32) safe memory access?
@ 2008-08-22 14:30 Robin den Hertog
  2008-08-22 14:32 ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Robin den Hertog @ 2008-08-22 14:30 UTC (permalink / raw)
  To: gdb

hey,

I would like to be able to send bytes words and int's that are
read/written as such to my embedded target.
(some fpga's and other peripheral hardware need their registers to be
read/written in one action).
the protocol doesn't support this, what is more the way the `m' packet
is defined it is unsure how it will handle the read at all.
the gdb user manual says this about the m|M packet:

The stub need not use any particular size or alignment when gathering
data from memory for the response; even if addr is word-aligned and
length is a multiple of the word size, the stub is free to use byte
accesses, or not. For this reason, this packet may not be suitable for
accessing memory-mapped I/O devices.

I suggest a new u|U packet.
(i suggest the packet uses binary data as some of the targets this
could be used for don't have powerful processors and any(cpu) overhead
we can spare is good in my book)
i suggest using the first 3 bits of the first byte to describe the
size of the data (000 for 8 bts 001 for 16 bits 010 for 64 bits, wich
leaves plenty of room for the future)
Then the last 5 bits to indicate the length.
Then 2 bytes for the start address, and then the data (if any, none
for read commands).

i might be implementing something like this for my internship project
(it would be nice if it was an accepted packet in the gdb protocol,
instead of a add on that doesn't make it in).
i say might because the decision to use gdb hasn't been made yet, but
gdb is supported by more and more companies to talk to their chips so
it would be nice to use gdb.
the alternative is a simple custom application that allows remote
read/write access, and possibly gdb server as well to allow for
debugging.
you could say i would be misusing gdb but the potential for faster
development and testing (trough a scripting enviroment thath sends
read/write commands to gdb) is there.

what do you think?

Robin

-- 
Never fear, for I is here!


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

* Re: byte word and int(32) safe memory access?
  2008-08-22 14:30 byte word and int(32) safe memory access? Robin den Hertog
@ 2008-08-22 14:32 ` Daniel Jacobowitz
  2008-08-22 14:34   ` Robin den Hertog
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2008-08-22 14:32 UTC (permalink / raw)
  To: Robin den Hertog; +Cc: gdb

On Fri, Aug 22, 2008 at 10:35:20AM +0200, Robin den Hertog wrote:
> hey,
> 
> I would like to be able to send bytes words and int's that are
> read/written as such to my embedded target.
> (some fpga's and other peripheral hardware need their registers to be
> read/written in one action).
> the protocol doesn't support this, what is more the way the `m' packet
> is defined it is unsure how it will handle the read at all.

What problem, exactly, are you solving here?  In practice, if you tell
GDB to read an int it will read an int; if you tell it to read a byte
it will read a byte.  It's only when accessing multi-word structures
that you get a problem.  And in those cases it's sometimes possible to
teach the stub to handle it transparently.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: byte word and int(32) safe memory access?
  2008-08-22 14:32 ` Daniel Jacobowitz
@ 2008-08-22 14:34   ` Robin den Hertog
  2008-08-22 14:43     ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Robin den Hertog @ 2008-08-22 14:34 UTC (permalink / raw)
  To: gdb, drow

On Fri, Aug 22, 2008 at 1:23 PM, Daniel Jacobowitz <drow@false.org> wrote:
> On Fri, Aug 22, 2008 at 10:35:20AM +0200, Robin den Hertog wrote:
>> hey,
>>
>> I would like to be able to send bytes words and int's that are
>> read/written as such to my embedded target.
>> (some fpga's and other peripheral hardware need their registers to be
>> read/written in one action).
>> the protocol doesn't support this, what is more the way the `m' packet
>> is defined it is unsure how it will handle the read at all.
>
> What problem, exactly, are you solving here?  In practice, if you tell
> GDB to read an int it will read an int; if you tell it to read a byte
> it will read a byte.  It's only when accessing multi-word structures
> that you get a problem.  And in those cases it's sometimes possible to
> teach the stub to handle it transparently.
>
> --
> Daniel Jacobowitz
> CodeSourcery

i want to use gdb server to debug my device drivers and the ability to
send read/write commands from a script environment running on the host
executed (preferably by gdb) on the target. I am using memory mapped
devices.

the documentation and code of gdb lead me to believe the only time you
read memory larger than a byte at once is for speed optimization.
but you're saying that is i request an address with the length at  2
bytes it will always be read in ONE read action ($m40,2#xx)?
or
does it depend on the address size?
"even if addr is word-aligned and length is a multiple of the word
size, the stub is free to use byte accesses"
I figured that meant even $m00004040,4#xx and any length above that
(but still dividable by 4) you would still be unsure how it is read.

changing the stub could still mean that as soon as you connect a
different fpga (to the same cpu) you have to rewrite your stub ?.


-- 
Never fear, for I is here!


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

* Re: byte word and int(32) safe memory access?
  2008-08-22 14:34   ` Robin den Hertog
@ 2008-08-22 14:43     ` Daniel Jacobowitz
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2008-08-22 14:43 UTC (permalink / raw)
  To: Robin den Hertog; +Cc: gdb

On Fri, Aug 22, 2008 at 03:16:48PM +0200, Robin den Hertog wrote:
> the documentation and code of gdb lead me to believe the only time you
> read memory larger than a byte at once is for speed optimization.
> but you're saying that is i request an address with the length at  2
> bytes it will always be read in ONE read action ($m40,2#xx)?
> or
> does it depend on the address size?
> "even if addr is word-aligned and length is a multiple of the word
> size, the stub is free to use byte accesses"
> I figured that meant even $m00004040,4#xx and any length above that
> (but still dividable by 4) you would still be unsure how it is read.
> 
> changing the stub could still mean that as soon as you connect a
> different fpga (to the same cpu) you have to rewrite your stub ?.

In practice GDB will never do byte accesses if you ask for a word.
What your stub does with them is up to the stub.  But you're in
control of the stub, presumably?

-- 
Daniel Jacobowitz
CodeSourcery


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

end of thread, other threads:[~2008-08-22 13:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-22 14:30 byte word and int(32) safe memory access? Robin den Hertog
2008-08-22 14:32 ` Daniel Jacobowitz
2008-08-22 14:34   ` Robin den Hertog
2008-08-22 14:43     ` Daniel Jacobowitz

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