From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5367 invoked by alias); 27 Jun 2003 19:53:24 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 5359 invoked from network); 27 Jun 2003 19:53:23 -0000 Received: from unknown (HELO localhost.redhat.com) (216.129.200.2) by sources.redhat.com with SMTP; 27 Jun 2003 19:53:23 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 40EDA2B5F; Fri, 27 Jun 2003 15:53:23 -0400 (EDT) Message-ID: <3EFCA0B3.3020308@redhat.com> Date: Fri, 27 Jun 2003 19:53:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Fred Fish Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] Eliminate hard coded constant num_regs in mips_gdbarch_init References: <20030627172833.430618B5FD@bletchley.vert.intrinsity.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-06/txt/msg00828.txt.bz2 > It seems wrong to hard code the number of registers in > mips_gdbarch_init. Here is one way to fix it, for the case > "num_regs=90", and possibly for the "num_regs=71" case also. It's about par for the course :-( The code also assumes that mips_r3041_reg_names, mips_r3051_reg_names and mips_r3081_reg_names are the same size (90 - 32). If you're trying to add more than 90 registers, you've a bigger problem. The various MIPS_REGISTER_NAME definitions should all be part of a table. > However using sizeof(mips_generic_reg_names) is somewhat of a > misleading way to find the number of strings in MIPS_REGISTER_NAMES > and I'm not too thrilled about using a hard coded 32 instead of > something like "sizeof(mips_gpr_names)/sizeof(char*)". Try MIPS_NUMREGS. Andrew PS: Does Intrinsity have a disclaimer? > 2003-06-25 Fred Fish > > * mips-tdep.c (mips_gdbarch_init): Set num_regs to be the number > of base registers (32) plus the number of machine dependent > register names, which should equal the number of machine dependent > registers. > > Index: mips-tdep.c > =================================================================== > RCS file: /mips/newtools/fsf/gdb/gdb/mips-tdep.c,v > retrieving revision 1.21 > retrieving revision 1.22 > diff -c -p -r1.21 -r1.22 > *** mips-tdep.c 2003/06/23 14:31:26 1.21 > --- mips-tdep.c 2003/06/26 02:36:53 1.22 > *************** mips_gdbarch_init (struct gdbarch_info i > *** 5908,5914 **** > if (info.osabi == GDB_OSABI_IRIX) > num_regs = 71; > else > ! num_regs = 90; > set_gdbarch_num_regs (gdbarch, num_regs); > set_gdbarch_num_pseudo_regs (gdbarch, num_regs); > > --- 5908,5914 ---- > if (info.osabi == GDB_OSABI_IRIX) > num_regs = 71; > else > ! num_regs = 32 + sizeof(mips_generic_reg_names)/sizeof(char *); > set_gdbarch_num_regs (gdbarch, num_regs); > set_gdbarch_num_pseudo_regs (gdbarch, num_regs); > >