Re: [RFA/RFC/IRIX] Remove some deprecated_registers from irix5-nat.c

Andrew Cagney
2004-11-13T23:06:00Z

Joel Brobecker wrote:
> Hello,
>
> Here is a patch that removes most of the uses of deprecated_registers
> in irix5-nat.c. I am not too familiar with the regcache yet, I hope
> I got it right. There was also a small issue with type size, where
> I introduced a temporary (regval) to make sure that the buffer given
> to regcache_raw_read_signed would always be large enough. Not sure
> whether it was the best way to do it (this shows my lack of C knowledge).

You should consider a patch fixing fallout from the deletion of
deprecated_registers as "obvious".

> 2004-11-13 Joel Brobecker <brobecker@gnat.com>
>
> * irix5-nat.c (fill_gregset): Replace use of deprecated_registers
> with equivalent code.
> (fill_fpregset): Likewise.
>
> Tested on mips-irix. There is an occasional screwup during the execution
> of gdb.threads/killed.exp that causes the testsuite to abort before the
> end:
>
> ERROR: (DejaGnu) proc "(gdb) {$}" does not exist.
> The error code is NONE
> The info on the error is:
> close: invalid spawn id (8)
> while executing
> "close -i 8"
> invoked from within
> "catch "close -i $spawn_id""
>
> Given that the testsuite takes a fair bit of time to run on our
> IRIX machine, and given that it can happen several times in a row
> before I get a clean run, I am reluctant to retry.
>
> So it's a bit more difficult to compare the two testsuite results.
> But I verified that we didn't have any change in all the testsuite
> up until this point.
>
> OK to apply?
>
> The last couple of uses of deprecated_registers will be removed shortly.
> I decided to handle them separately because they are used when loading
> the registers from a core file. I wanted to evaluate the attached change
> first.

And set your baseline at "does it build" (as with deprecated_registers
deleted, it doesn't build yet alone run).

(thanks for fixing this)
Andrew

> Thanks,
>
>
> ------------------------------------------------------------------------
>
> Index: irix5-nat.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/irix5-nat.c,v
> retrieving revision 1.35
> diff -u -p -r1.35 irix5-nat.c
> --- irix5-nat.c 30 Oct 2004 22:36:34 -0000 1.35
> +++ irix5-nat.c 13 Nov 2004 22:33:07 -0000
> @@ -83,6 +83,7 @@ fill_gregset (gregset_t *gregsetp, int r
> {
> int regi;
> greg_t *regp = &(*gregsetp)[0];
> + LONGEST regval;
>
> /* Under Irix6, if GDB is built with N32 ABI and is debugging an O32
> executable, we have to sign extend the registers to 64 bits before
> @@ -90,30 +91,39 @@ fill_gregset (gregset_t *gregsetp, int r
>
> for (regi = 0; regi <= CTX_RA; regi++)
> if ((regno == -1) || (regno == regi))
> - *(regp + regi) =
> - extract_signed_integer (&deprecated_registers[DEPRECATED_REGISTER_BYTE (regi)],
> - register_size (current_gdbarch, regi));
> + {
> + regcache_raw_read_signed (current_regcache, regi, &regval);
> + *(regp + regi) = regval;
> + }
>
> if ((regno == -1) || (regno == PC_REGNUM))
> - *(regp + CTX_EPC) =
> - extract_signed_integer (&deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->pc)],
> - register_size (current_gdbarch, mips_regnum (current_gdbarch)->pc));
> + {
> + regcache_raw_read_signed
> + (current_regcache, mips_regnum (current_gdbarch)->pc, &regval);
> + *(regp + CTX_EPC) = regval;
> + }
>
> if ((regno == -1) || (regno == mips_regnum (current_gdbarch)->cause))
> - *(regp + CTX_CAUSE) =
> - extract_signed_integer (&deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->cause)],
> - register_size (current_gdbarch, mips_regnum (current_gdbarch)->cause));
> + {
> + regcache_raw_read_signed
> + (current_regcache, mips_regnum (current_gdbarch)->cause, &regval);
> + *(regp + CTX_CAUSE) = regval;
> + }
>
> if ((regno == -1)
> || (regno == mips_regnum (current_gdbarch)->hi))
> - *(regp + CTX_MDHI) =
> - extract_signed_integer (&deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->hi)],
> - register_size (current_gdbarch, mips_regnum (current_gdbarch)->hi));
> + {
> + regcache_raw_read_signed
> + (current_regcache, mips_regnum (current_gdbarch)->hi, &regval);
> + *(regp + CTX_MDHI) = regval;
> + }
>
> if ((regno == -1) || (regno == mips_regnum (current_gdbarch)->lo))
> - *(regp + CTX_MDLO) =
> - extract_signed_integer (&deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->lo)],
> - register_size (current_gdbarch, mips_regnum (current_gdbarch)->lo));
> + {
> + regcache_raw_read_signed
> + (current_regcache, mips_regnum (current_gdbarch)->lo, &regval);
> + *(regp + CTX_MDLO) = regval;
> + }
> }
>
> /*
> @@ -158,15 +168,16 @@ fill_fpregset (fpregset_t *fpregsetp, in
> {
> if ((regno == -1) || (regno == regi))
> {
> - from = (char *) &deprecated_registers[DEPRECATED_REGISTER_BYTE (regi)];
> to = (char *) &(fpregsetp->fp_r.fp_regs[regi - FP0_REGNUM]);
> - memcpy (to, from, register_size (current_gdbarch, regi));
> + regcache_raw_read (current_regcache, regi, to);
> }
> }
>
> if ((regno == -1)
> || (regno == mips_regnum (current_gdbarch)->fp_control_status))
> - fpregsetp->fp_csr = *(unsigned *) &deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->fp_control_status)];
> + regcache_raw_read (current_regcache,
> + mips_regnum (current_gdbarch)->fp_control_status,
> + &fpregsetp->fp_csr);
> }
>
>