[rfa/c] Signed read_register()

Andrew Cagney ac131313@cygnus.com
Mon Jul 10 20:52:00 GMT 2000


Michael Snyder wrote:
> 
> Andrew Cagney wrote:
> >
> > Hello,
> >
> > The attatched patch adds a signed version of the read_register{,_pid}()
> > functions (read_signed_register{,_pid}()).  MIPS uses this when reading
> > registers such as the PC/SP (well it will when I check in a few other
> > changes :-).
> >
> > I think the existing read_register*() functions should be explicitly
> > re-named to read_unsigned_register() but that is another story :-)
> >
> > Ok?  MichaelS, regcache.c is yours.
> 
> Attachment missing.  The idea is OK.
> Is it possible that read_signed_register could be implemented
> using read_register, or vice versa, to avoid code duplication?
> 
> Side issue #1: Shall we change the return type of
> read_register from CORE_ADDR to LONGEST?  Or better
> still, define a new INTREG_TYPE?

To do this it would need to return a ``struct type *'' - the register
size can change at runtime.

Actually, as one of those long term objectives, I think having a
read_register() that returned a ``struct type *'' would be a good thing,
it would break the requirement that a register could fit in a LONGEST.

> Side issue #2: Why can't the caller simply sign-extend?
> Esp. if the return type is of the correct size?

FYI, it started out as a function burried in mips-tdep.c. By moving it
to findvar.c (... ;-) to keep the reg code in one place.

As for merging read_{signed,}_register(), again yep, a second pass.

	Andrew


More information about the Gdb-patches mailing list