This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Adding %cs and %ss for AMD64 to GDB


Folks,

GDB doesn't handle %cs and %ss for AMD64 yet.  I'm not sure why they
were omitted (might be because they're not particularly useful in long
mode), but there are cases where we might need them.  I might add
these registers after the current last register (%mxcsr), but it just
seems so much more logical to have them close to the other segment
registers.  However, since GDB's register numbering influences the
remote interface, I cannot simply do this.

So here's my question: How bad would it be to change the remote
protocol for AMD64?

I'm proposing to add %cs and %ss just after %eflags.  This would mean
that the segment registers, the floating-point registers and the SSE
registers will shift.  Using a new GDB with an old gdbserver, or an
old remote stub, will mean those registers will contain bogus values.

I did a small survey of the Open Source projects that might make use
of GDB's remote interface to see what the impact would be:

* Linux kgdb doesn't use anything beyond %eflags yet.  Impact would be
  zero.

* FreeBSD kgdb supplies %cs and %ss in the slots that are now reserved
  for %ds and %es.  It provides zero for %fs and %gs (which it thinks
  are %ds and %es).  The impact would be positive!

* NetBSD kgdb doesn't seem to support remote debugging for AMD64 yet.

* Gdbserver supplies %cs and %ss in the slots that are now reserved
  for %ds and %es, %ds and %es in the slots for %fs and %gs, and %fs
  and %gs in the slots for %st0 and %st1.  So the situation for the
  segment registers would actually improve!  However, for the
  floating-point and SSE registers the situation would become worse,
  although right now the most important floating-point registers %st0
  and %st1 might be unreliable.

Note that the problems with gdbserver can be solved by simply
upgrading gdbserver on the remote machine, which in most cases won't
bee too difficult.  I can't imagine that there are many embedded AMD64
systems out there yet.

>From the above I conclude that it wouldn't be too bad to add the %cs
and %ss registers the way I propose.  However, don't hesitate to tell
me if you think differently.

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]