From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23301 invoked by alias); 29 Mar 2004 21:50:42 -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 23260 invoked from network); 29 Mar 2004 21:50:40 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 29 Mar 2004 21:50:40 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i2TLoe1X016051 for ; Mon, 29 Mar 2004 16:50:40 -0500 Received: from zenia.home.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i2TLobj09252; Mon, 29 Mar 2004 16:50:37 -0500 To: gdb-patches@sources.redhat.com Subject: RFA: use single debug->gdb register number func for rs6000 family From: Jim Blandy Date: Mon, 29 Mar 2004 21:50:00 -0000 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-03/txt/msg00735.txt.bz2 It turns out that the gdbarch_tdep structure has all the information necessary to do the job; there's no need to have separate functions. Tested with no regressions on powerpc-unknown-linux-gnu. 2004-03-28 Jim Blandy * rs6000-tdep.c (rs6000_dwarf2_stab_reg_to_regnum): New, unified function for register numbers on all the rs6000-derived targets. (rs6000_gdbarch_init): Don't register a separate gdbarch_dwarf2_reg_to_regnum function for the E500. Use rs6000_dwarf2_stab_reg_to_regnum for both Dwarf 2 and stabs on all variants. Index: gdb/rs6000-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v retrieving revision 1.190 diff -c -r1.190 rs6000-tdep.c *** gdb/rs6000-tdep.c 29 Mar 2004 03:41:56 -0000 1.190 --- gdb/rs6000-tdep.c 29 Mar 2004 07:29:44 -0000 *************** *** 1556,1599 **** } } ! /* Convert a dwarf2 register number to a gdb REGNUM. */ static int ! e500_dwarf2_reg_to_regnum (int num) { ! int regnum; if (0 <= num && num <= 31) ! return num + gdbarch_tdep (current_gdbarch)->ppc_gp0_regnum; ! else ! return num; ! } ! /* Convert a dbx stab register number (from `r' declaration) to a gdb ! REGNUM. */ ! static int ! rs6000_stab_reg_to_regnum (int num) ! { ! int regnum; ! switch (num) ! { ! case 64: ! regnum = gdbarch_tdep (current_gdbarch)->ppc_mq_regnum; ! break; ! case 65: ! regnum = gdbarch_tdep (current_gdbarch)->ppc_lr_regnum; ! break; ! case 66: ! regnum = gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum; ! break; ! case 76: ! regnum = gdbarch_tdep (current_gdbarch)->ppc_xer_regnum; ! break; ! default: ! regnum = num; ! break; ! } ! return regnum; } static void rs6000_store_return_value (struct type *type, char *valbuf) { --- 1556,1606 ---- } } ! ! /* Convert a dbx stab or Dwarf 2 register number (from `r' ! declaration) to a gdb REGNUM. */ static int ! rs6000_dwarf2_stab_reg_to_regnum (int num) { ! struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); ! if (0 <= num && num <= 31) ! return tdep->ppc_gp0_regnum + num; ! else if (32 <= num && num <= 63) ! return FP0_REGNUM + (num - 32); ! else if (1200 <= num && num < 1200 + 32) ! return tdep->ppc_ev0_regnum + (num - 1200); ! else ! switch (num) ! { ! case 64: ! return tdep->ppc_mq_regnum; ! case 65: ! return tdep->ppc_lr_regnum; ! case 66: ! return tdep->ppc_ctr_regnum; ! case 76: ! return tdep->ppc_xer_regnum; ! case 109: ! return tdep->ppc_vrsave_regnum; ! default: ! return num; ! } ! ! /* FIXME: jimb/2004-03-28: Doesn't something need to be done here ! for the Altivec registers, too? ! ! Looking at GCC, the headers in config/rs6000 never define a ! DBX_REGISTER_NUMBER macro, so the debug info uses the same ! numbers GCC does internally. Then, looking at the REGISTER_NAMES ! macro defined in config/rs6000/rs6000.h, it seems that GCC gives ! v0 -- v31 the numbers 77 -- 108. But we number them 119 -- 150. ! I don't have a way to test this ready to hand, but I noticed it ! and thought I should include a note. */ } + static void rs6000_store_return_value (struct type *type, char *valbuf) { *************** *** 2599,2605 **** set_gdbarch_pc_regnum (gdbarch, 0); set_gdbarch_sp_regnum (gdbarch, tdep->ppc_gp0_regnum + 1); set_gdbarch_deprecated_fp_regnum (gdbarch, tdep->ppc_gp0_regnum + 1); - set_gdbarch_dwarf2_reg_to_regnum (gdbarch, e500_dwarf2_reg_to_regnum); set_gdbarch_pseudo_register_read (gdbarch, e500_pseudo_register_read); set_gdbarch_pseudo_register_write (gdbarch, e500_pseudo_register_write); break; --- 2606,2611 ---- *************** *** 2674,2680 **** set_gdbarch_deprecated_register_convertible (gdbarch, rs6000_register_convertible); set_gdbarch_deprecated_register_convert_to_virtual (gdbarch, rs6000_register_convert_to_virtual); set_gdbarch_deprecated_register_convert_to_raw (gdbarch, rs6000_register_convert_to_raw); ! set_gdbarch_stab_reg_to_regnum (gdbarch, rs6000_stab_reg_to_regnum); /* Note: kevinb/2002-04-12: I'm not convinced that rs6000_push_arguments() is correct for the SysV ABI when the wordsize is 8, but I'm also fairly certain that ppc_sysv_abi_push_arguments() will give even --- 2680,2687 ---- set_gdbarch_deprecated_register_convertible (gdbarch, rs6000_register_convertible); set_gdbarch_deprecated_register_convert_to_virtual (gdbarch, rs6000_register_convert_to_virtual); set_gdbarch_deprecated_register_convert_to_raw (gdbarch, rs6000_register_convert_to_raw); ! set_gdbarch_stab_reg_to_regnum (gdbarch, rs6000_dwarf2_stab_reg_to_regnum); ! set_gdbarch_dwarf2_reg_to_regnum (gdbarch, rs6000_dwarf2_stab_reg_to_regnum); /* Note: kevinb/2002-04-12: I'm not convinced that rs6000_push_arguments() is correct for the SysV ABI when the wordsize is 8, but I'm also fairly certain that ppc_sysv_abi_push_arguments() will give even