This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Invalid segment resister value on x86_64-windows
> Date: Wed, 2 May 2012 10:57:24 -0700
> From: Joel Brobecker <brobecker@adacore.com>
>
> > I'm not sure we can make those changes. The default layout for the
> > registers in the target description is chosen such that it is
> > compatible with the "old" register cache layout used for stubs that
> > didn't provide a target description. That layout is still extensively
> > used by kernel stubs such as the ones in the Linux and NetBSD kernels.
> > I don't think breaking those would be acceptable, as kernel debugging
> > is where the segment registers actually matter!
>
> That's something I was concerned about. Here is another approach, which
> adds special handling for those registers for Windows. The issue was
> that the same code was used for both 32bit and 64bit Windows, so
> I needed to extend the tdep structure to be able to determine whether
> register N was a segment register or not.
>
> Does the attached patch look good to you?
Hmm, it should be possible to do this without changing any of the
-tdep.c code, but if you prefer to do it this way, can you rename the
new field into cs_regnum, change the comment into "Register number for
%cs", and move it somewhere around the other _regnum variables that
are already part of the struct? That makes things a bit more
consistent.
> gdb/ChangeLog:
>
> * i386-tdep.h (struct gdbarch_tdep): New field
> `first_segment_regnum'.
> * amd64-tdep.c (amd64_init_abi): Set tdep->first_segment_regnum.
> * i386-tdep.c (i386_gdbarch_init): Likewise.
> * windows-nat.c (do_windows_fetch_inferior_registers): Only
> read the first 16 bits of segment register values.