This is the mail archive of the gdb-patches@sourceware.org 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]

Re: [PATCH 03/15 v2] Make gdbserver CORE_ADDR unsigned


On Thu, 17 Jul 2014, Pedro Alves wrote:

> The only issue that I think might come out of this is
> that on MIPS, addresses are signed, so pointers are sign
> extended.  But we can definitely handle whatever fallout this
> may cause, if any, when we see it.  Clearly if GDB's native
> targets can handle that, so should gdbserver's, and in any
> case the issue should be pretty localized.  Just pointing it
> out FYI, to keep an eye out for it.

 Also SH64 AFAICT, it defines `elf_backend_sign_extend_vma' to true in 
bfd/elf32-sh64.c.  We have the following comment in gdb/mips-tdep.c:

/* MIPS believes that the PC has a sign extended value.  Perhaps the
   all registers should be sign extended for simplicity?  */

which is of course true in that we need to sign-extend all integer 
registers (that includes GPRs and CP0 registers; maybe some control 
registers as well); where applicable that is, i.e. debugging a strict 
32-bit ABI on 64-bit hardware.  Then on the other hand the values in these 
registers should already have been truncated to 32 bits and then 
sign-extended before they have been written in the first place.

 Overall it's tricky, hardware does not always enforce proper 
sign-extension required by the ABI, e.g. an o32 kernel-mode program is 
free to set GPRs or the PC to a value outside the range supported by the 
ABI (the Linux kernel sometimes takes advantage of this possibility), and 
we have no way I believe to make the user aware of this happening, while 
that might be The Bug they're after.

  Maciej


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