From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9389 invoked by alias); 14 Apr 2007 21:11:15 -0000 Received: (qmail 9379 invoked by uid 22791); 14 Apr 2007 21:11:13 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate5.de.ibm.com (HELO mtagate5.de.ibm.com) (195.212.29.154) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 14 Apr 2007 22:11:08 +0100 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate5.de.ibm.com (8.13.8/8.13.8) with ESMTP id l3ELB6g7190950 for ; Sat, 14 Apr 2007 21:11:06 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.3) with ESMTP id l3ELB5rb4059372 for ; Sat, 14 Apr 2007 23:11:05 +0200 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 l3ELB5Xw008876 for ; Sat, 14 Apr 2007 23:11:05 +0200 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 l3ELB5ci008873 for ; Sat, 14 Apr 2007 23:11:05 +0200 Message-Id: <200704142111.l3ELB5ci008873@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Sat, 14 Apr 2007 23:11:05 +0200 Subject: [rfc/rft] [4/5] Untangle register_addr: mips-linux To: gdb-patches@sourceware.org Date: Sat, 14 Apr 2007 21:12:00 -0000 From: "Ulrich Weigand" 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: 2007-04/txt/msg00226.txt.bz2 Hello, this patch performs further cleanup of the mips-linux target, enabled by the previous patches in the series. In particular, the mips versions of register_addr, CANNOT_FETCH_REGISTER, and CANNOT_STORE_REGISTER are inlined into mips_linux_register_u_offset. This means that config/mips/nm-linux.h no longer needs to define CANNOT_FETCH_REGISTER / CANNOT_STORE_REGISTER and thus can be removed. Also, mips-linux-tdep.c used to use a per-gdbarch function pointer to provide different versions of register_addr. This patch changes that to simply check mips_abi_regsize (current_gdbarch), which should have the same effect -- note that this is probably still not quite right, as the ptrace register offsets generally depend on the bit-ness of the GDB process that issues the ptrace call, and not on the bit-ness of the target process; most likely an #ifdef __mips64__ or so would be the correct test. I'll leave that to someone who actually has a mips-linux native target ... Tested only by verifying a mips-linux native target still builds. I'd much appreciate if someone could test it on a real mips-linux target. Bye, Ulrich ChangeLog: * config/mips/linux.mh (NAT_FILE): Set to config/nm-linux.h. * config/mips/nm-linux.h: Delete file. * mips-linux-nat.c: No longer include "gdbcore.h". (mips_linux_cannot_fetch_register): Make static. (mips_linux_cannot_store_register): Likewise. (mips_linux_register_addr): Move from mips-linux-tdep.c. (mips64_linux_register_addr): Likewise. (mips_linux_register_u_offset): Call mips_linux_cannot_fetch_register and mips_linux_cannot_store_register instead of CANNOT_FETCH_REGISTER and CANNOT_STORE_REGISTER. Call mips_linux_register_addr or mips64_linux_register_addr instead of register_addr. * mips-linux-tdep.c (mips_linux_register_addr, mips64_linux_register_addr): Move to mips-linux-nat.c. (register_addr): Remove. (register_addr_data, init_register_addr_data): Remove. (_initialize_mips_linux_tdep): Do not initialize register_addr_data. (set_mips_linux_register_addr): Remove. (mips_linux_init_abi): Do not call it. diff -urNp gdb-orig/gdb/config/mips/linux.mh gdb-head/gdb/config/mips/linux.mh --- gdb-orig/gdb/config/mips/linux.mh 2007-04-12 16:12:54.000000000 +0200 +++ gdb-head/gdb/config/mips/linux.mh 2007-04-14 01:30:55.708201016 +0200 @@ -1,5 +1,5 @@ # Host: Linux/MIPS -NAT_FILE= nm-linux.h +NAT_FILE= config/nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o mips-linux-nat.o \ linux-thread-db.o proc-service.o gcore.o \ linux-nat.o linux-fork.o diff -urNp gdb-orig/gdb/config/mips/nm-linux.h gdb-head/gdb/config/mips/nm-linux.h --- gdb-orig/gdb/config/mips/nm-linux.h 2007-04-13 20:40:05.492284048 +0200 +++ gdb-head/gdb/config/mips/nm-linux.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,32 +0,0 @@ -/* Native-dependent definitions for GNU/Linux on MIPS. - - Copyright 1996, 2001, 2002, 2003, 2007 Free Software Foundation, Inc. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef NM_MIPSLINUX_H -#define NM_MIPSLINUX_H - -#include "config/nm-linux.h" - -int mips_linux_cannot_fetch_register (int regno); -int mips_linux_cannot_store_register (int regno); -#define CANNOT_FETCH_REGISTER(regno) mips_linux_cannot_fetch_register (regno) -#define CANNOT_STORE_REGISTER(regno) mips_linux_cannot_store_register (regno) - -#endif /* NM_MIPSLINUX_H */ diff -urNp gdb-orig/gdb/mips-linux-nat.c gdb-head/gdb/mips-linux-nat.c --- gdb-orig/gdb/mips-linux-nat.c 2007-04-14 01:31:06.608274736 +0200 +++ gdb-head/gdb/mips-linux-nat.c 2007-04-14 01:32:43.113249568 +0200 @@ -26,7 +26,6 @@ #include "target.h" #include "linux-nat.h" #include "mips-linux-tdep.h" -#include "gdbcore.h" #include "gdb_proc_service.h" @@ -51,7 +50,7 @@ void (*super_store_registers) (int); setting MIPS_ZERO_REGNUM. We also can not set BADVADDR, CAUSE, or FCRIR via ptrace(). */ -int +static int mips_linux_cannot_fetch_register (int regno) { if (regno > MIPS_ZERO_REGNUM && regno < MIPS_ZERO_REGNUM + 32) @@ -71,7 +70,7 @@ mips_linux_cannot_fetch_register (int re return 1; } -int +static int mips_linux_cannot_store_register (int regno) { if (regno > MIPS_ZERO_REGNUM && regno < MIPS_ZERO_REGNUM + 32) @@ -87,6 +86,75 @@ mips_linux_cannot_store_register (int re return 1; } +/* Map gdb internal register number to ptrace ``address''. + These ``addresses'' are normally defined in . */ + +static CORE_ADDR +mips_linux_register_addr (int regno) +{ + int regaddr; + + if (regno < 0 || regno >= NUM_REGS) + error (_("Bogon register number %d."), regno); + + if (regno < 32) + regaddr = regno; + else if ((regno >= mips_regnum (current_gdbarch)->fp0) + && (regno < mips_regnum (current_gdbarch)->fp0 + 32)) + regaddr = FPR_BASE + (regno - mips_regnum (current_gdbarch)->fp0); + else if (regno == mips_regnum (current_gdbarch)->pc) + regaddr = PC; + else if (regno == mips_regnum (current_gdbarch)->cause) + regaddr = CAUSE; + else if (regno == mips_regnum (current_gdbarch)->badvaddr) + regaddr = BADVADDR; + else if (regno == mips_regnum (current_gdbarch)->lo) + regaddr = MMLO; + else if (regno == mips_regnum (current_gdbarch)->hi) + regaddr = MMHI; + else if (regno == mips_regnum (current_gdbarch)->fp_control_status) + regaddr = FPC_CSR; + else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision) + regaddr = FPC_EIR; + else + error (_("Unknowable register number %d."), regno); + + return regaddr; +} + +static CORE_ADDR +mips64_linux_register_addr (int regno) +{ + int regaddr; + + if (regno < 0 || regno >= NUM_REGS) + error (_("Bogon register number %d."), regno); + + if (regno < 32) + regaddr = regno; + else if ((regno >= mips_regnum (current_gdbarch)->fp0) + && (regno < mips_regnum (current_gdbarch)->fp0 + 32)) + regaddr = MIPS64_FPR_BASE + (regno - FP0_REGNUM); + else if (regno == mips_regnum (current_gdbarch)->pc) + regaddr = MIPS64_PC; + else if (regno == mips_regnum (current_gdbarch)->cause) + regaddr = MIPS64_CAUSE; + else if (regno == mips_regnum (current_gdbarch)->badvaddr) + regaddr = MIPS64_BADVADDR; + else if (regno == mips_regnum (current_gdbarch)->lo) + regaddr = MIPS64_MMLO; + else if (regno == mips_regnum (current_gdbarch)->hi) + regaddr = MIPS64_MMHI; + else if (regno == mips_regnum (current_gdbarch)->fp_control_status) + regaddr = MIPS64_FPC_CSR; + else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision) + regaddr = MIPS64_FPC_EIR; + else + error (_("Unknowable register number %d."), regno); + + return regaddr; +} + /* Fetch the thread-local storage pointer for libthread_db. */ ps_err_e @@ -253,13 +321,14 @@ mips64_linux_store_registers (int regnum static CORE_ADDR mips_linux_register_u_offset (int regno, int store_p) { - if (store_p? CANNOT_STORE_REGISTER (regno) : CANNOT_FETCH_REGISTER (regno)) + if (store_p? mips_linux_cannot_store_register (regno) + : mips_linux_cannot_fetch_register (regno)) return (CORE_ADDR)-1; - /* FIXME drow/2005-09-04: The hardcoded use of register_addr should go - away. This requires disentangling the various definitions of it - (particularly alpha-nat.c's). */ - return register_addr (regno, 0); + if (mips_abi_regsize (current_gdbarch) == 8) + return mips64_linux_register_addr (regno); + else + return mips_linux_register_addr (regno); } void _initialize_mips_linux_nat (void); diff -urNp gdb-orig/gdb/mips-linux-tdep.c gdb-head/gdb/mips-linux-tdep.c --- gdb-orig/gdb/mips-linux-tdep.c 2007-04-12 16:12:54.000000000 +0200 +++ gdb-head/gdb/mips-linux-tdep.c 2007-04-14 01:30:55.755193872 +0200 @@ -218,42 +218,6 @@ mips_fill_fpregset (mips_elf_fpregset_t } } -/* Map gdb internal register number to ptrace ``address''. - These ``addresses'' are normally defined in . */ - -static CORE_ADDR -mips_linux_register_addr (int regno, CORE_ADDR blockend) -{ - int regaddr; - - if (regno < 0 || regno >= NUM_REGS) - error (_("Bogon register number %d."), regno); - - if (regno < 32) - regaddr = regno; - else if ((regno >= mips_regnum (current_gdbarch)->fp0) - && (regno < mips_regnum (current_gdbarch)->fp0 + 32)) - regaddr = FPR_BASE + (regno - mips_regnum (current_gdbarch)->fp0); - else if (regno == mips_regnum (current_gdbarch)->pc) - regaddr = PC; - else if (regno == mips_regnum (current_gdbarch)->cause) - regaddr = CAUSE; - else if (regno == mips_regnum (current_gdbarch)->badvaddr) - regaddr = BADVADDR; - else if (regno == mips_regnum (current_gdbarch)->lo) - regaddr = MMLO; - else if (regno == mips_regnum (current_gdbarch)->hi) - regaddr = MMHI; - else if (regno == mips_regnum (current_gdbarch)->fp_control_status) - regaddr = FPC_CSR; - else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision) - regaddr = FPC_EIR; - else - error (_("Unknowable register number %d."), regno); - - return regaddr; -} - /* Support for 64-bit ABIs. */ /* Figure out where the longjmp will land. @@ -487,42 +451,6 @@ mips64_fill_fpregset (mips64_elf_fpregse } -/* Map gdb internal register number to ptrace ``address''. - These ``addresses'' are normally defined in . */ - -static CORE_ADDR -mips64_linux_register_addr (int regno, CORE_ADDR blockend) -{ - int regaddr; - - if (regno < 0 || regno >= NUM_REGS) - error (_("Bogon register number %d."), regno); - - if (regno < 32) - regaddr = regno; - else if ((regno >= mips_regnum (current_gdbarch)->fp0) - && (regno < mips_regnum (current_gdbarch)->fp0 + 32)) - regaddr = MIPS64_FPR_BASE + (regno - FP0_REGNUM); - else if (regno == mips_regnum (current_gdbarch)->pc) - regaddr = MIPS64_PC; - else if (regno == mips_regnum (current_gdbarch)->cause) - regaddr = MIPS64_CAUSE; - else if (regno == mips_regnum (current_gdbarch)->badvaddr) - regaddr = MIPS64_BADVADDR; - else if (regno == mips_regnum (current_gdbarch)->lo) - regaddr = MIPS64_MMLO; - else if (regno == mips_regnum (current_gdbarch)->hi) - regaddr = MIPS64_MMHI; - else if (regno == mips_regnum (current_gdbarch)->fp_control_status) - regaddr = MIPS64_FPC_CSR; - else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision) - regaddr = MIPS64_FPC_EIR; - else - error (_("Unknowable register number %d."), regno); - - return regaddr; -} - /* Use a local version of this function to get the correct types for regsets, until multi-arch core support is ready. */ @@ -584,35 +512,6 @@ static struct core_fns regset_core_fns = NULL /* next */ }; -/* Handle for obtaining pointer to the current register_addr() - function for a given architecture. */ -static struct gdbarch_data *register_addr_data; - -CORE_ADDR -register_addr (int regno, CORE_ADDR blockend) -{ - CORE_ADDR (*register_addr_ptr) (int, CORE_ADDR) = - gdbarch_data (current_gdbarch, register_addr_data); - - gdb_assert (register_addr_ptr != 0); - - return register_addr_ptr (regno, blockend); -} - -static void -set_mips_linux_register_addr (struct gdbarch *gdbarch, - CORE_ADDR (*register_addr_ptr) (int, - CORE_ADDR)) -{ - deprecated_set_gdbarch_data (gdbarch, register_addr_data, - register_addr_ptr); -} - -static void * -init_register_addr_data (struct gdbarch *gdbarch) -{ - return 0; -} /* Check the code at PC for a dynamic linker lazy resolution stub. Because they aren't in the .plt section, we pattern-match on the @@ -1139,7 +1038,6 @@ mips_linux_init_abi (struct gdbarch_info mips_linux_get_longjmp_target); set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_ilp32_fetch_link_map_offsets); - set_mips_linux_register_addr (gdbarch, mips_linux_register_addr); tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_sigframe); tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_rt_sigframe); break; @@ -1148,7 +1046,6 @@ mips_linux_init_abi (struct gdbarch_info mips_linux_get_longjmp_target); set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_ilp32_fetch_link_map_offsets); - set_mips_linux_register_addr (gdbarch, mips64_linux_register_addr); set_gdbarch_long_double_bit (gdbarch, 128); /* These floatformats should probably be renamed. MIPS uses the same 128-bit IEEE floating point format that IA-64 uses, @@ -1162,7 +1059,6 @@ mips_linux_init_abi (struct gdbarch_info mips64_linux_get_longjmp_target); set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_lp64_fetch_link_map_offsets); - set_mips_linux_register_addr (gdbarch, mips64_linux_register_addr); set_gdbarch_long_double_bit (gdbarch, 128); /* These floatformats should probably be renamed. MIPS uses the same 128-bit IEEE floating point format that IA-64 uses, @@ -1191,9 +1087,6 @@ _initialize_mips_linux_tdep (void) { const struct bfd_arch_info *arch_info; - register_addr_data = - gdbarch_data_register_post_init (init_register_addr_data); - for (arch_info = bfd_lookup_arch (bfd_arch_mips, 0); arch_info != NULL; arch_info = arch_info->next) -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com