From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5347 invoked by alias); 18 Mar 2003 23:41:58 -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 5239 invoked from network); 18 Mar 2003 23:41:57 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 18 Mar 2003 23:41:57 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h2INfuQ27356 for ; Tue, 18 Mar 2003 18:41:56 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h2INfuV15648 for ; Tue, 18 Mar 2003 18:41:56 -0500 Received: from localhost.localdomain (vpn50-21.rdu.redhat.com [172.16.50.21]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h2INfu021058 for ; Tue, 18 Mar 2003 18:41:56 -0500 Received: (from kev@localhost) by localhost.localdomain (8.11.6/8.11.6) id h2INfoe25966 for gdb-patches@sources.redhat.com; Tue, 18 Mar 2003 16:41:50 -0700 Date: Tue, 18 Mar 2003 23:41:00 -0000 From: Kevin Buettner Message-Id: <1030318234150.ZM25965@localhost.localdomain> To: gdb-patches@sources.redhat.com Subject: [RFA] Use correct register names for MIPS n32/n64 ABIs MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-03/txt/msg00416.txt.bz2 For an Irix 6 target, when debugging an o32 program, gdb does not provide the correct register names when using "info registers". It does however, use the correct names for n32/n64. Conversely, for all other MIPS targets, o32 register names are always used regardless of the ABI. The patch below causes the correct ABI-dependent register names to be used. I considered at least one other approach for fixing this problem. I considered providing new register name arrays for each of the ABIs, but that seemed unwieldy, and quite unnecessary too since the GPR register numbers are always 0-31. Also, all mips cores (that gdb knows about) agree on what these names should be for the o32 ABI. As such, it seemed easier to remap just the names of the GPRs in mips_register_name(). Another follow on patch to this one would be to encode the knowledge of what the GPRs should be entirely within mips_register_name() and relegate the register name arrays to describing (only) the names of registers whose numbers are 32 or greater. (I'll wait to do this until I find out the reaction to the patch below.) Okay? * mips-tdep.c (mips_register_name): Provide correct names for n32/n64 ABI. * config/mips/tm-irix6.h (MIPS_REGISTER_NAMES): Change names to those used by o32 ABI. The correct names for the n32/n64 ABIs are now handled by mips_register_name(). Index: mips-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/mips-tdep.c,v retrieving revision 1.172 diff -u -p -r1.172 mips-tdep.c --- mips-tdep.c 14 Mar 2003 16:05:35 -0000 1.172 +++ mips-tdep.c 18 Mar 2003 23:19:13 -0000 @@ -368,7 +368,23 @@ char **mips_processor_reg_names = mips_g static const char * mips_register_name (int i) { - return mips_processor_reg_names[i]; + static char *mips_n32_n64_gpr_names[] = { + "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", + "a4", "a5", "a6", "a7", "t0", "t1", "t2", "t3", + "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", + "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra" + }; + enum mips_abi abi = mips_abi (current_gdbarch); + + /* The MIPS general purpose registers are always mapped from 0 to 31. The + names of the registers (which reflects the conventions regarding + register use) vary depending on the ABI. We assume that the names + accessible via mips_processor_reg_names[] are always the non-n32/n64 + names. */ + if (i < 32 && (abi == MIPS_ABI_N32 || abi == MIPS_ABI_N64)) + return mips_n32_n64_gpr_names[i]; + else + return mips_processor_reg_names[i]; } /* *INDENT-OFF* */ /* Names of IDT R3041 registers. */ Index: config/mips/tm-irix6.h =================================================================== RCS file: /cvs/src/src/gdb/config/mips/tm-irix6.h,v retrieving revision 1.9 diff -u -p -r1.9 tm-irix6.h --- config/mips/tm-irix6.h 13 Dec 2002 18:09:30 -0000 1.9 +++ config/mips/tm-irix6.h 18 Mar 2003 23:19:14 -0000 @@ -35,11 +35,15 @@ #undef FCRIR_REGNUM /* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ + There should be NUM_REGS strings in this initializer. + + Note: These are actually the names used by the o32 ABI. + mips_register_name() in mips-tdep.c is responsible for remapping + the names which differ in the n32/n64 ABI. */ #define MIPS_REGISTER_NAMES \ { "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", \ - "a4", "a5", "a6", "a7", "t0", "t1", "t2", "t3", \ + "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", \ "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", \ "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra", \ "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \