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: [rfc]: Replace current_gdbarch in hppa


Markus Deuling wrote:

> > This is really the wrong check.  It should really just verify that
> > no out-of-bounds access to u_offsets happens, so the line should 
> > just be something like:
> > 
> >    if ((unsigned) regno >= ARRAY_SIZE (u_offsets))
> > 
> 
> yes, you're right. This check is much better :-)


> diff -urpN src/gdb/hppa-linux-nat.c dev/gdb/hppa-linux-nat.c
> --- src/gdb/hppa-linux-nat.c	2008-01-01 23:53:10.000000000 +0100
> +++ dev/gdb/hppa-linux-nat.c	2008-02-18 15:20:51.000000000 +0100
> @@ -149,11 +149,12 @@ static const int u_offsets[] =
>    };
>  
>  static CORE_ADDR
> -hppa_linux_register_addr (int regno, CORE_ADDR blockend)
> +hppa_linux_register_addr (struct gdbarch *gdbarch, int regno,
> +			  CORE_ADDR blockend)

With the changed test you do not need to modify this routine
to pass in an gdbarch parameter.

>  {
>    CORE_ADDR addr;
>  
> -  if ((unsigned) regno >= gdbarch_num_regs (current_gdbarch))
> +  if ((unsigned) regno >= ARRAY_SIZE (u_offsets))
>      error (_("Invalid register number %d."), regno);
>  
>    if (u_offsets[regno] == -1)



> @@ -229,7 +230,8 @@ fetch_register (struct regcache *regcach
>      tid = PIDGET (inferior_ptid); /* Not a threaded program.  */
>  
>    errno = 0;
> -  val = ptrace (PTRACE_PEEKUSER, tid, hppa_linux_register_addr (regno, 0), 0);
> +  val = ptrace (PTRACE_PEEKUSER, tid,
> +		hppa_linux_register_addr (gdbarch, regno, 0), 0);
>    if (errno != 0)
>      error (_("Couldn't read register %s (#%d): %s."), 
>  	   gdbarch_register_name (gdbarch, regno),
> @@ -257,7 +259,8 @@ store_register (const struct regcache *r
>  
>    errno = 0;
>    regcache_raw_collect (regcache, regno, &val);
> -  ptrace (PTRACE_POKEUSER, tid, hppa_linux_register_addr (regno, 0), val);
> +  ptrace (PTRACE_POKEUSER, tid,
> +	  hppa_linux_register_addr (gdbarch, regno, 0), val);
>    if (errno != 0)
>      error (_("Couldn't write register %s (#%d): %s."),
>  	   gdbarch_register_name (gdbarch, regno),

Likewise those changes can then go away.


Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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