Skip to contentSkip to conversation

FRV: Implement the GDB remote protocol 'p' command to retrieve a register

PATCH In review David Howells 4 participants 6 messages Jun 9, 2010 – Jun 28, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 FRV: Implement the GDB remote protocol 'p' command to retrieve a register

Implement the GDB remote protocol 'p' command to retrieve a single register value.

The 'p' command is tried by some gdb versions before they consider using the 'g' command (to batch-retrieve all the registers). Before the following commit:

	commit 7ca8b9c0dafd1cb36289aa4c92c7beae7adcd34f
	Author: David Howells <[email protected]>
	Date:   Mon May 24 14:32:54 2010 -0700
	Subject: frv: extend gdbstub to support more features of gdb

the 'p' command just returned an empty reply, which causes gdb to then go and use the 'g' command. However, since that commit, the 'p' command returns an error string, which causes gdb to abort its connection to the target.

Not all gdb versions are affected, some use try 'g' first, and if that works, don't bother with 'p', and so don't see the error.

---

 arch/frv/include/asm/gdb-stub.h |    2 +
 arch/frv/kernel/gdb-stub.c      |  116 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 118 insertions(+), 0 deletions(-)
arch/frv/include/asm/gdb-stub.h +2 -0
index e6bedd0..8bb0288 100644
@@ -60,6 +60,8 @@
 #define GDB_REG_SCR(N)	(141+(N))
 #define GDB_REG_LR	145
 #define GDB_REG_LCR	146
+#define GDB_REG_IACC0H	147
+#define GDB_REG_IACC0L	148
 #define GDB_REG_FSR0	149
 #define GDB_REG_ACC(N)	(150+(N))
 #define GDB_REG_ACCG(N)	(158+(N)/4)
arch/frv/kernel/gdb-stub.c +116 -0

134 lines not on this page · raw message

#1 lore raw
Quoted 3 lines · David Howells

Implement the GDB remote protocol 'p' command to retrieve a single register value.

Is there any value to this? Apparently it used to work just because that command never did anything (rather than return an error). Why not just reinstate that behavior instead?

There's doesn't seem to be any reason to implement the single-register case unless there is some legacy use of it. There's a good reason gdb tends to use the "register block" thing, and it tends to be easier to implement too (no crazy case statements etc).

Linus

#2 lore raw
Quoted 4 lines · Linus Torvalds
Quoted 2 lines

Implement the GDB remote protocol 'p' command to retrieve a single register value.

Is there any value to this? [...]

Sure, much less data to transfer across a slowish serial link.

- FChE

#3 lore raw
Quoted 2 lines · Frank Ch. Eigler

Sure, much less data to transfer across a slowish serial link.

Umm. Or more? If you look at one register, you tend to look at several. And we're not exactly talking kilobytes here.

Anyway, the existing patch is certainly easy to make a judgment on: it's not a regression fix but a new feature, so I'm not applying it. I was suggesting _making_ it a regression fix, but I really don't care.

Linus

#4 lore raw
In reply to Frank Ch. Eigler
Quoted 12 lines · Frank Ch. Eigler
Quoted 5 lines · Linus Torvalds
Quoted 3 lines

Implement the GDB remote protocol 'p' command to retrieve a single register value.

Is there any value to this? [...]

Sure, much less data to transfer across a slowish serial link.

I have actually measured this before using a yet to be posted for review
version which works for x86, arm and mips. The improvement is more
significant with the 64 bit archs vs the 32 because of the register sizing. The typical case of stepping is quite a bit more responsive when you only need to read the pc, stack pointer and frame pointer. At the point in time I post the patches, I can also post the data about the savings for two of the exact same work load sequences.

I had also tried out an implementation of the gdb extension which where you can pass the pc, stack pointer and frame pointer along with the stop code and this provides an additional speed up as well, but not nearly as much of a gain as implementing the 'p' packets.

I don't know if I will have it ready for 2.6.36 or not, but the generic use of the 'p' packet was also required so that the kdb shell could have a mechanism to individually read and write registers.

I am a bit curious if the frv arch had considered migrating to the kgdb
core, vs continuing to use the separate gdbstub? It would seem we are
duplicating the creation of the same sort of features. The frv architecture may not need it at all, but if you do make use of the kgdb core, you get other features like kdb for free, plus any of the interesting features you might want to add might be of interest to other consumers of the kernel debugger.

Cheers,
Jason.

#5 lore raw
In reply to Linus Torvalds
Quoted 6 lines · Linus Torvalds
Quoted 2 lines

Implement the GDB remote protocol 'p' command to retrieve a single register value.

Is there any value to this? Apparently it used to work just because that command never did anything (rather than return an error). Why not just reinstate that behavior instead?

That's a reasonable argument. The 'p' command would be more efficient if gdb uses it when required to get single values, but once it has decided to use the 'g' command, it seems to stick with it.

Quoted 4 lines

There's doesn't seem to be any reason to implement the single-register case unless there is some legacy use of it. There's a good reason gdb tends to use the "register block" thing, and it tends to be easier to implement too (no crazy case statements etc).

It's slower to use 'g', however, if we only want the value in one register, and I'm usually doing gdb protocol over serial.

However, as stated above, once it's decided to use 'g', gdb doesn't seem to want to use 'p' any more.

David