From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27645 invoked by alias); 31 Oct 2007 10:48:10 -0000 Received: (qmail 27032 invoked by uid 22791); 31 Oct 2007 10:48:03 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate3.de.ibm.com (HELO mtagate3.de.ibm.com) (195.212.29.152) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 31 Oct 2007 10:47:44 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate3.de.ibm.com (8.13.8/8.13.8) with ESMTP id l9VAlf1a102154 for ; Wed, 31 Oct 2007 10:47:41 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.5) with ESMTP id l9VAlfJO2085080 for ; Wed, 31 Oct 2007 11:47:41 +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 l9VAlemx028449 for ; Wed, 31 Oct 2007 11:47:40 +0100 Received: from bbkeks.boeblingen.de.ibm.com (dyn-9-152-248-41.boeblingen.de.ibm.com [9.152.248.41]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id l9VAldxt028397 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 31 Oct 2007 11:47:40 +0100 Message-ID: <47285CE2.7040307@de.ibm.com> Date: Wed, 31 Oct 2007 11:59:00 -0000 From: Markus Deuling User-Agent: Thunderbird 2.0.0.6 (X11/20070728) MIME-Version: 1.0 To: GDB Patches CC: Ulrich Weigand Subject: [rfc] [08/15] Add gdbarch to register_name callback in sh64-tdep.c Content-Type: multipart/mixed; boundary="------------090706050505040807060303" 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: 2007-10/txt/msg00859.txt.bz2 This is a multi-part message in MIME format. --------------090706050505040807060303 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Content-length: 679 Hi, this patch adds gdbarch to register_name callback in sh64-tdep.c. It also replaces some trivial occurences of current_gdbarch. Is this ok to commit? ChangeLog: * sh64-tdep.c (sh64_register_name): Add gdbarch parameter. (sh64_compact_reg_base_num, sh64_register_convert_to_virtual) (sh64_register_convert_to_raw, sh64_fv_reg_base_num) (sh64_dr_reg_base_num, sh64_fpp_reg_base_num): Add gdbarch parameter and update caller. Replace current_gdbarch by gdbarch. (sh64_extract_return_value, sh64_store_return_value): Use get_regcache_arch to get at the current architecture by regcache. -- Markus Deuling GNU Toolchain for Linux on Cell BE deuling@de.ibm.com --------------090706050505040807060303 Content-Type: text/plain; name="diff-sh64-tdep" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diff-sh64-tdep" Content-length: 17012 diff -urpN src/gdb/sh64-tdep.c dev/gdb/sh64-tdep.c --- src/gdb/sh64-tdep.c 2007-10-08 14:57:04.000000000 +0200 +++ dev/gdb/sh64-tdep.c 2007-10-30 13:41:45.000000000 +0100 @@ -124,7 +124,7 @@ enum }; static const char * -sh64_register_name (int reg_nr) +sh64_register_name (struct gdbarch *gdbarch, int reg_nr) { static char *register_names[] = { @@ -685,34 +685,31 @@ gdb_print_insn_sh64 (bfd_vma memaddr, di /* For vectors of 4 floating point registers. */ static int -sh64_fv_reg_base_num (int fv_regnum) +sh64_fv_reg_base_num (struct gdbarch *gdbarch, int fv_regnum) { int fp_regnum; - fp_regnum = gdbarch_fp0_regnum (current_gdbarch) + - (fv_regnum - FV0_REGNUM) * 4; + fp_regnum = gdbarch_fp0_regnum (gdbarch) + (fv_regnum - FV0_REGNUM) * 4; return fp_regnum; } /* For double precision floating point registers, i.e 2 fp regs.*/ static int -sh64_dr_reg_base_num (int dr_regnum) +sh64_dr_reg_base_num (struct gdbarch *gdbarch, int dr_regnum) { int fp_regnum; - fp_regnum = gdbarch_fp0_regnum (current_gdbarch) + - (dr_regnum - DR0_REGNUM) * 2; + fp_regnum = gdbarch_fp0_regnum (gdbarch) + (dr_regnum - DR0_REGNUM) * 2; return fp_regnum; } /* For pairs of floating point registers */ static int -sh64_fpp_reg_base_num (int fpp_regnum) +sh64_fpp_reg_base_num (struct gdbarch *gdbarch, int fpp_regnum) { int fp_regnum; - fp_regnum = gdbarch_fp0_regnum (current_gdbarch) + - (fpp_regnum - FPP0_REGNUM) * 2; + fp_regnum = gdbarch_fp0_regnum (gdbarch) + (fpp_regnum - FPP0_REGNUM) * 2; return fp_regnum; } @@ -779,7 +776,7 @@ sh64_fpp_reg_base_num (int fpp_regnum) */ /* *INDENT-ON* */ static int -sh64_compact_reg_base_num (int reg_nr) +sh64_compact_reg_base_num (struct gdbarch *gdbarch, int reg_nr) { int base_regnum = reg_nr; @@ -791,20 +788,22 @@ sh64_compact_reg_base_num (int reg_nr) /* floating point register N maps to floating point register N */ else if (reg_nr >= FP0_C_REGNUM && reg_nr <= FP_LAST_C_REGNUM) - base_regnum = reg_nr - FP0_C_REGNUM + gdbarch_fp0_regnum (current_gdbarch); + base_regnum = reg_nr - FP0_C_REGNUM + gdbarch_fp0_regnum (gdbarch); /* double prec register N maps to base regnum for double prec register N */ else if (reg_nr >= DR0_C_REGNUM && reg_nr <= DR_LAST_C_REGNUM) - base_regnum = sh64_dr_reg_base_num (DR0_REGNUM + reg_nr - DR0_C_REGNUM); + base_regnum = sh64_dr_reg_base_num (gdbarch, + DR0_REGNUM + reg_nr - DR0_C_REGNUM); /* vector N maps to base regnum for vector register N */ else if (reg_nr >= FV0_C_REGNUM && reg_nr <= FV_LAST_C_REGNUM) - base_regnum = sh64_fv_reg_base_num (FV0_REGNUM + reg_nr - FV0_C_REGNUM); + base_regnum = sh64_fv_reg_base_num (gdbarch, + FV0_REGNUM + reg_nr - FV0_C_REGNUM); else if (reg_nr == PC_C_REGNUM) - base_regnum = gdbarch_pc_regnum (current_gdbarch); + base_regnum = gdbarch_pc_regnum (gdbarch); else if (reg_nr == GBR_C_REGNUM) base_regnum = 16; @@ -823,7 +822,7 @@ sh64_compact_reg_base_num (int reg_nr) base_regnum = FPSCR_REGNUM; /*???? this register is a mess. */ else if (reg_nr == FPUL_C_REGNUM) - base_regnum = gdbarch_fp0_regnum (current_gdbarch) + 32; + base_regnum = gdbarch_fp0_regnum (gdbarch) + 32; return base_regnum; } @@ -1203,15 +1202,16 @@ static void sh64_extract_return_value (struct type *type, struct regcache *regcache, void *valbuf) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); int len = TYPE_LENGTH (type); - + if (TYPE_CODE (type) == TYPE_CODE_FLT) { if (len == 4) { /* Return value stored in gdbarch_fp0_regnum */ regcache_raw_read (regcache, - gdbarch_fp0_regnum (current_gdbarch), valbuf); + gdbarch_fp0_regnum (gdbarch), valbuf); } else if (len == 8) { @@ -1221,7 +1221,7 @@ sh64_extract_return_value (struct type * regcache_cooked_read (regcache, DR0_REGNUM, buf); - if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE) + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword, buf, &val); else @@ -1240,8 +1240,8 @@ sh64_extract_return_value (struct type * at the most significant end. */ regcache_raw_read (regcache, DEFAULT_RETURN_REGNUM, buf); - if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) - offset = register_size (current_gdbarch, DEFAULT_RETURN_REGNUM) + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) + offset = register_size (gdbarch, DEFAULT_RETURN_REGNUM) - len; else offset = 0; @@ -1263,14 +1263,15 @@ static void sh64_store_return_value (struct type *type, struct regcache *regcache, const void *valbuf) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); char buf[64]; /* more than enough... */ int len = TYPE_LENGTH (type); if (TYPE_CODE (type) == TYPE_CODE_FLT) { - int i, regnum = gdbarch_fp0_regnum (current_gdbarch); + int i, regnum = gdbarch_fp0_regnum (gdbarch); for (i = 0; i < len; i += 4) - if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE) + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) regcache_raw_write (regcache, regnum++, (char *) valbuf + len - 4 - i); else @@ -1281,15 +1282,15 @@ sh64_store_return_value (struct type *ty int return_register = DEFAULT_RETURN_REGNUM; int offset = 0; - if (len <= register_size (current_gdbarch, return_register)) + if (len <= register_size (gdbarch, return_register)) { /* Pad with zeros. */ - memset (buf, 0, register_size (current_gdbarch, return_register)); - if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE) - offset = 0; /*register_size (current_gdbarch, + memset (buf, 0, register_size (gdbarch, return_register)); + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) + offset = 0; /*register_size (gdbarch, return_register) - len;*/ else - offset = register_size (current_gdbarch, return_register) - len; + offset = register_size (gdbarch, return_register) - len; memcpy (buf + offset, valbuf, len); regcache_raw_write (regcache, return_register, buf); @@ -1542,13 +1543,13 @@ sh64_register_type (struct gdbarch *gdba } static void -sh64_register_convert_to_virtual (int regnum, struct type *type, - char *from, char *to) +sh64_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum, + struct type *type, char *from, char *to) { - if (gdbarch_byte_order (current_gdbarch) != BFD_ENDIAN_LITTLE) + if (gdbarch_byte_order (gdbarch) != BFD_ENDIAN_LITTLE) { /* It is a no-op. */ - memcpy (to, from, register_size (current_gdbarch, regnum)); + memcpy (to, from, register_size (gdbarch, regnum)); return; } @@ -1567,13 +1568,13 @@ sh64_register_convert_to_virtual (int re } static void -sh64_register_convert_to_raw (struct type *type, int regnum, - const void *from, void *to) +sh64_register_convert_to_raw (struct gdbarch *gdbarch, struct type *type, + int regnum, const void *from, void *to) { - if (gdbarch_byte_order (current_gdbarch) != BFD_ENDIAN_LITTLE) + if (gdbarch_byte_order (gdbarch) != BFD_ENDIAN_LITTLE) { /* It is a no-op. */ - memcpy (to, from, register_size (current_gdbarch, regnum)); + memcpy (to, from, register_size (gdbarch, regnum)); return; } @@ -1602,7 +1603,7 @@ sh64_pseudo_register_read (struct gdbarc if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM) { - base_regnum = sh64_dr_reg_base_num (reg_nr); + base_regnum = sh64_dr_reg_base_num (gdbarch, reg_nr); /* Build the value in the provided buffer. */ /* DR regs are double precision registers obtained by @@ -1613,7 +1614,7 @@ sh64_pseudo_register_read (struct gdbarc + register_size (gdbarch, base_regnum) * portion)); /* We must pay attention to the endianness. */ - sh64_register_convert_to_virtual (reg_nr, + sh64_register_convert_to_virtual (gdbarch, reg_nr, register_type (gdbarch, reg_nr), temp_buffer, buffer); @@ -1622,7 +1623,7 @@ sh64_pseudo_register_read (struct gdbarc else if (reg_nr >= FPP0_REGNUM && reg_nr <= FPP_LAST_REGNUM) { - base_regnum = sh64_fpp_reg_base_num (reg_nr); + base_regnum = sh64_fpp_reg_base_num (gdbarch, reg_nr); /* Build the value in the provided buffer. */ /* FPP regs are pairs of single precision registers obtained by @@ -1636,7 +1637,7 @@ sh64_pseudo_register_read (struct gdbarc else if (reg_nr >= FV0_REGNUM && reg_nr <= FV_LAST_REGNUM) { - base_regnum = sh64_fv_reg_base_num (reg_nr); + base_regnum = sh64_fv_reg_base_num (gdbarch, reg_nr); /* Build the value in the provided buffer. */ /* FV regs are vectors of single precision registers obtained by @@ -1651,7 +1652,7 @@ sh64_pseudo_register_read (struct gdbarc else if (reg_nr >= R0_C_REGNUM && reg_nr <= T_C_REGNUM) { - base_regnum = sh64_compact_reg_base_num (reg_nr); + base_regnum = sh64_compact_reg_base_num (gdbarch, reg_nr); /* Build the value in the provided buffer. */ regcache_raw_read (regcache, base_regnum, temp_buffer); @@ -1663,7 +1664,7 @@ sh64_pseudo_register_read (struct gdbarc else if (reg_nr >= FP0_C_REGNUM && reg_nr <= FP_LAST_C_REGNUM) { - base_regnum = sh64_compact_reg_base_num (reg_nr); + base_regnum = sh64_compact_reg_base_num (gdbarch, reg_nr); /* Build the value in the provided buffer. */ /* Floating point registers map 1-1 to the media fp regs, @@ -1674,7 +1675,7 @@ sh64_pseudo_register_read (struct gdbarc else if (reg_nr >= DR0_C_REGNUM && reg_nr <= DR_LAST_C_REGNUM) { - base_regnum = sh64_compact_reg_base_num (reg_nr); + base_regnum = sh64_compact_reg_base_num (gdbarch, reg_nr); /* DR_C regs are double precision registers obtained by concatenating 2 single precision floating point registers. */ @@ -1684,7 +1685,7 @@ sh64_pseudo_register_read (struct gdbarc + register_size (gdbarch, base_regnum) * portion)); /* We must pay attention to the endianness. */ - sh64_register_convert_to_virtual (reg_nr, + sh64_register_convert_to_virtual (gdbarch, reg_nr, register_type (gdbarch, reg_nr), temp_buffer, buffer); } @@ -1692,7 +1693,7 @@ sh64_pseudo_register_read (struct gdbarc else if (reg_nr >= FV0_C_REGNUM && reg_nr <= FV_LAST_C_REGNUM) { - base_regnum = sh64_compact_reg_base_num (reg_nr); + base_regnum = sh64_compact_reg_base_num (gdbarch, reg_nr); /* Build the value in the provided buffer. */ /* FV_C regs are vectors of single precision registers obtained by @@ -1749,7 +1750,7 @@ sh64_pseudo_register_read (struct gdbarc else if (reg_nr == FPUL_C_REGNUM) { - base_regnum = sh64_compact_reg_base_num (reg_nr); + base_regnum = sh64_compact_reg_base_num (gdbarch, reg_nr); /* FPUL_C register is floating point register 32, same size, same endianness. */ @@ -1768,9 +1769,9 @@ sh64_pseudo_register_write (struct gdbar if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM) { - base_regnum = sh64_dr_reg_base_num (reg_nr); + base_regnum = sh64_dr_reg_base_num (gdbarch, reg_nr); /* We must pay attention to the endianness. */ - sh64_register_convert_to_raw (register_type (gdbarch, reg_nr), + sh64_register_convert_to_raw (gdbarch, register_type (gdbarch, reg_nr), reg_nr, buffer, temp_buffer); @@ -1785,7 +1786,7 @@ sh64_pseudo_register_write (struct gdbar else if (reg_nr >= FPP0_REGNUM && reg_nr <= FPP_LAST_REGNUM) { - base_regnum = sh64_fpp_reg_base_num (reg_nr); + base_regnum = sh64_fpp_reg_base_num (gdbarch, reg_nr); /* Write the real regs for which this one is an alias. */ for (portion = 0; portion < 2; portion++) @@ -1798,7 +1799,7 @@ sh64_pseudo_register_write (struct gdbar else if (reg_nr >= FV0_REGNUM && reg_nr <= FV_LAST_REGNUM) { - base_regnum = sh64_fv_reg_base_num (reg_nr); + base_regnum = sh64_fv_reg_base_num (gdbarch, reg_nr); /* Write the real regs for which this one is an alias. */ for (portion = 0; portion < 4; portion++) @@ -1813,7 +1814,7 @@ sh64_pseudo_register_write (struct gdbar else if (reg_nr >= R0_C_REGNUM && reg_nr <= T_C_REGNUM) { - base_regnum = sh64_compact_reg_base_num (reg_nr); + base_regnum = sh64_compact_reg_base_num (gdbarch, reg_nr); /* reg_nr is 32 bit here, and base_regnum is 64 bits. */ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) offset = 4; @@ -1833,18 +1834,19 @@ sh64_pseudo_register_write (struct gdbar else if (reg_nr >= FP0_C_REGNUM && reg_nr <= FP_LAST_C_REGNUM) { - base_regnum = sh64_compact_reg_base_num (reg_nr); + base_regnum = sh64_compact_reg_base_num (gdbarch, reg_nr); regcache_raw_write (regcache, base_regnum, buffer); } else if (reg_nr >= DR0_C_REGNUM && reg_nr <= DR_LAST_C_REGNUM) { - base_regnum = sh64_compact_reg_base_num (reg_nr); + base_regnum = sh64_compact_reg_base_num (gdbarch, reg_nr); for (portion = 0; portion < 2; portion++) { /* We must pay attention to the endianness. */ - sh64_register_convert_to_raw (register_type (gdbarch, reg_nr), + sh64_register_convert_to_raw (gdbarch, + register_type (gdbarch, reg_nr), reg_nr, buffer, temp_buffer); @@ -1858,7 +1860,7 @@ sh64_pseudo_register_write (struct gdbar else if (reg_nr >= FV0_C_REGNUM && reg_nr <= FV_LAST_C_REGNUM) { - base_regnum = sh64_compact_reg_base_num (reg_nr); + base_regnum = sh64_compact_reg_base_num (gdbarch, reg_nr); for (portion = 0; portion < 4; portion++) { @@ -1924,7 +1926,7 @@ sh64_pseudo_register_write (struct gdbar else if (reg_nr == FPUL_C_REGNUM) { - base_regnum = sh64_compact_reg_base_num (reg_nr); + base_regnum = sh64_compact_reg_base_num (gdbarch, reg_nr); regcache_raw_write (regcache, base_regnum, buffer); } } @@ -2035,7 +2037,7 @@ sh64_do_pseudo_register (struct gdbarch else if ((regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)) { - int fp_regnum = sh64_dr_reg_base_num (regnum); + int fp_regnum = sh64_dr_reg_base_num (gdbarch, regnum); fprintf_filtered (file, "dr%d\t0x%08x%08x\n", regnum - DR0_REGNUM, (unsigned) get_frame_register_unsigned (frame, fp_regnum), (unsigned) get_frame_register_unsigned (frame, fp_regnum + 1)); @@ -2043,7 +2045,7 @@ sh64_do_pseudo_register (struct gdbarch else if ((regnum >= DR0_C_REGNUM && regnum <= DR_LAST_C_REGNUM)) { - int fp_regnum = sh64_compact_reg_base_num (regnum); + int fp_regnum = sh64_compact_reg_base_num (gdbarch, regnum); fprintf_filtered (file, "dr%d_c\t0x%08x%08x\n", regnum - DR0_C_REGNUM, (unsigned) get_frame_register_unsigned (frame, fp_regnum), (unsigned) get_frame_register_unsigned (frame, fp_regnum + 1)); @@ -2051,7 +2053,7 @@ sh64_do_pseudo_register (struct gdbarch else if ((regnum >= FV0_REGNUM && regnum <= FV_LAST_REGNUM)) { - int fp_regnum = sh64_fv_reg_base_num (regnum); + int fp_regnum = sh64_fv_reg_base_num (gdbarch, regnum); fprintf_filtered (file, "fv%d\t0x%08x\t0x%08x\t0x%08x\t0x%08x\n", regnum - FV0_REGNUM, (unsigned) get_frame_register_unsigned (frame, fp_regnum), @@ -2062,7 +2064,7 @@ sh64_do_pseudo_register (struct gdbarch else if ((regnum >= FV0_C_REGNUM && regnum <= FV_LAST_C_REGNUM)) { - int fp_regnum = sh64_compact_reg_base_num (regnum); + int fp_regnum = sh64_compact_reg_base_num (gdbarch, regnum); fprintf_filtered (file, "fv%d_c\t0x%08x\t0x%08x\t0x%08x\t0x%08x\n", regnum - FV0_C_REGNUM, (unsigned) get_frame_register_unsigned (frame, fp_regnum), @@ -2073,7 +2075,7 @@ sh64_do_pseudo_register (struct gdbarch else if (regnum >= FPP0_REGNUM && regnum <= FPP_LAST_REGNUM) { - int fp_regnum = sh64_fpp_reg_base_num (regnum); + int fp_regnum = sh64_fpp_reg_base_num (gdbarch, regnum); fprintf_filtered (file, "fpp%d\t0x%08x\t0x%08x\n", regnum - FPP0_REGNUM, (unsigned) get_frame_register_unsigned (frame, fp_regnum), (unsigned) get_frame_register_unsigned (frame, fp_regnum + 1)); @@ -2081,7 +2083,7 @@ sh64_do_pseudo_register (struct gdbarch else if (regnum >= R0_C_REGNUM && regnum <= R_LAST_C_REGNUM) { - int c_regnum = sh64_compact_reg_base_num (regnum); + int c_regnum = sh64_compact_reg_base_num (gdbarch, regnum); fprintf_filtered (file, "r%d_c\t0x%08x\n", regnum - R0_C_REGNUM, (unsigned) get_frame_register_unsigned (frame, c_regnum)); } --------------090706050505040807060303--