From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22949 invoked by alias); 18 Feb 2008 14:37:12 -0000 Received: (qmail 22939 invoked by uid 22791); 18 Feb 2008 14:37:12 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate4.de.ibm.com (HELO mtagate4.de.ibm.com) (195.212.29.153) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 18 Feb 2008 14:36:50 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate4.de.ibm.com (8.13.8/8.13.8) with ESMTP id m1IEalhm156454 for ; Mon, 18 Feb 2008 14:36:47 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m1IEakZr2220052 for ; Mon, 18 Feb 2008 15:36:46 +0100 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m1IEahRc030608 for ; Mon, 18 Feb 2008 14:36:46 GMT Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id m1IEah6Z030589; Mon, 18 Feb 2008 14:36:43 GMT Message-Id: <200802181436.m1IEah6Z030589@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Mon, 18 Feb 2008 15:36:43 +0100 Subject: Re: [rfc]: Replace current_gdbarch in hppa To: deuling@de.ibm.com (Markus Deuling) Date: Mon, 18 Feb 2008 14:37:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org (GDB Patches) In-Reply-To: <47B99560.3020602@de.ibm.com> from "Markus Deuling" at Feb 18, 2008 03:25:36 PM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-02/txt/msg00290.txt.bz2 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