From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6553 invoked by alias); 14 Apr 2007 21:08:39 -0000 Received: (qmail 6544 invoked by uid 22791); 14 Apr 2007 21:08:37 -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:08:31 +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 l3EL8Sms197636 for ; Sat, 14 Apr 2007 21:08:28 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 l3EL8S6t4124778 for ; Sat, 14 Apr 2007 23:08:28 +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 l3EL8RPb007244 for ; Sat, 14 Apr 2007 23:08:27 +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 l3EL8RHn007241 for ; Sat, 14 Apr 2007 23:08:27 +0200 Message-Id: <200704142108.l3EL8RHn007241@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Sat, 14 Apr 2007 23:08:27 +0200 Subject: [rfc/rft] [1/5] Untangle register_addr: core-aout.c To: gdb-patches@sourceware.org Date: Sat, 14 Apr 2007 21:09: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/msg00223.txt.bz2 Hello, this patch attempts to untangle some of the definitions of register_addr, and the related macros KERNEL_U_SIZE, U_REGS_OFFSET, KERNEL_U_ADDR, and REGISTER_U_ADDR. Most of these are in fact already obsolete ... In particular, the patch gets rid of the core-aout.c file, which isn't actually used anywhere to handle core files any more, but is still required on a number of native targets for the sake of the register_addr definition it provides. First, a look at the macro definitions and uses: KERNEL_U_SIZE is solely used in infptrace.c (udot_info). The only remaining infptrace targets are AIX and OSF, which provide an implementation kernel_u_size in rs6000-nat.c and alpha-nat.c, via rs6000/nm-rs6000.h and alpha/nm-osf2.h respectively. Thus the definitions in arm/nm-linux.h, i386/nm-linux.h, m68k/nm-linux.h, mips/nm-linux.h, powerpc/nm-linux.h and associated implementations in arm-linux-nat.c, i368-linux-nat.c, m68k-linux-nat.c and ppc-linux-nat.c are obsolete. Remaining definitions: alpha/nm-osf2.h, rs6000/nm-rs6000.h. U_REGS_OFFSET is used in m68klinux-nat.c (fetch_register, store_register), where always the definition to 0 in m68k/nm-linux.h applies, and in infptrace.c (fetch_register, store_register), which is only used by OSF (AIX already has its own fetch_register and store_register). Thus all other definitions in pa/nm-linux.h, arm/nm-linux.h, mips/nm-linux.h, alpha/nm-linux.h as well as the default in infptrace.c are obsolete. Remaining definitions: alpha/nm-osf.h. KERNEL_U_ADDR is used in the (obsolete) default definition of U_REGS_OFFSET in infptrace.c and in core-aout.c (fetch_core_registers). core-aout.c is used solely by the vax, i386-linux and m68k-linux targets. Thus the definitions in arm/nm-linux.h and powerpc/nm-linux.h are obsolete. Note the vax targets already have their own core file handling, and do not use the core-aout.c register_addr either, so the use of core-aout.c on vax and thus the definition in vax/nm-vax.h is already obsolete. Furthermore, the i386-linux and m68k-linux targets also provide their own core file handling, and pull in core-aout.c solely for its definition of a register_addr function. Thus, when that is fixed, the definitions in i386/nm-linux.h and m68k/nm-linux.h will be obsolete, too. (There is also a default definition in gdbcore.h which is broken as it refers to the nowhere defined variable kernel_u_addr; but since the default definition is never used, this doesn't really matter.) Remaining definitions: none REGISTER_U_ADDR is solely used in core-aout.c (register_addr). As the file is used solely by the vax, i386-linux and m68k-linux targets, the definitions in mips/nm-irix5.h and mips/nm-linux.h are obsolete. As mentioned above, the use by the vax targets is already obsolete anyway. Once the use of the core-aout.c register_addr routine is fixed in the linux targets, the i386/nm-linux.h and m68k/nm-linux.h definitions will be obsolete as well. Remaining definitions: none Now, to register_addr. There are currently four files that define this, and seven files that use it. The following combinations actually occur: core-aout.c definition -> Used on m68k-linux in m68klinux-nat.c; in this case it will always use REGISTER_U_ADDR from m68k_linux_register_u_addr (m68klinux-nat.c) via m68k/nm-linux.h -- this can be inlined directly. -> Used on i368-linux in i386-linux-nat.c; in this case it will always use REGISTER_U_ADDR from register_u_addr (i386-linux-nat.c) via i386/nm-linux.h -- this can be inlined directly. -> Used in fetch_core_registers in core-aout.c itself; once all users of core-aout.c are gone, the whole file can be eliminated. alpha-nat.c definition -> Used on alpha-osf in infptrace.c -- leave it for now, OSF needs to be rewritten using inf-ptrace.c instead. -> Used on alpha-linux in linux-nat.c by linux_target () -- to be addressed by a follow-on patch. mips-linux-tdep.c definition -> Used on mips-linux in linux-nat.c by linux_target () -- to be addressed by a follow-on patch. FIXME: It's somewhat broken to define this in a tdep file! hppa-linux-nat.c definition -> This is only used on hppa-linux in the same file hppa-linux-nat.c, and can just be made static or inlined. As those are native-target changes, it's a bit difficular to fully test. I did a full regular test on i386-linux and powerpc-linux. In addition, I verified that alpha-linux, arm-linux, m68k-linux, mips-linux, hppa-linux, and vax-ultrix native targets still build (working around issues relating to missing kernel headers). Bye, Ulrich ChangeLog: * core-aout.c: Delete file. * Makefile.in (ALLDEPFILES): Remove core-aout.c. (core-aout.o): Delete rule. * gdbcore.h (kernel_u_addr, KERNEL_U_ADDR): Remove. * config/alpha/nm-linux.h (U_REGS_OFFSET): Remove. * arm-linux-nat.c (arm_linux_kernel_u_size): Remove. * config/arm/nm-linux.h (U_REGS_OFFSET, KERNEL_U_SIZE, KERNEL_U_ADDR): Remove. * i386-linux-nat.c (register_u_addr, kernel_u_size): Remove. (cannot_fetch_register, cannot_store_register): Remove. (fetch_register): Inline cannot_fetch_register and register_addr. (store_register): Inline cannot_store_register and register_addr. * config/i386/linux.mh (NATDEPFILES): Remove core-aout.o. * config/i386/nm-linux.h (KERNEL_U_SIZE, KERNEL_U_ADDR, REGISTER_U_ADDR, CANNOT_FETCH_REGISTER, CANNOT_STORE_REGISTER): Remove. * m68klinux-nat.c (m68k_linux_register_u_addr, kernel_u_size): Remove. (fetch_register): Inline register_addr. (store_register): Inline register_addr. * config/m68k/linux.mh (NATDEPFILES): Remove core-aout.o. * config/m68k/nm-linux.h (KERNEL_U_SIZE, KERNEL_U_ADDR, U_REGS_OFFSET, REGISTER_U_ADDR): Remove. * config/mips/nm-irix5.h (REGISTER_U_ADDR): Remove. * config/mips/nm-linux.h (KERNEL_U_SIZE, U_REGS_OFFSET, REGISTER_U_ADDR): Remove. * hppa-linux-nat.c (register_addr): Rename to ... (hppa_linux_register_addr): ... this. Make static. (fetch_register, store_register): Adapt callers. * config/pa/nm-linux.h (U_REGS_OFFSET): Remove. * ppc-linux-nat.c (kernel_u_size): Remove. * config/powerpc/nm-linux.h (KERNEL_U_SIZE, KERNEL_U_ADDR): Remove. * vax-nat.c (vax_kernel_u_addr, vax_register_u_addr): Make static. * config/vax/vax.mh (NATDEPFILES): Remove core-aout.o. (NAT_FILE): Remove. * config/vax/nm-vax.h: Delete file. diff -urNp gdb-orig/gdb/arm-linux-nat.c gdb-head/gdb/arm-linux-nat.c --- gdb-orig/gdb/arm-linux-nat.c 2007-04-13 20:37:56.593175800 +0200 +++ gdb-head/gdb/arm-linux-nat.c 2007-04-13 19:54:34.669194560 +0200 @@ -529,12 +529,6 @@ supply_fpregset (gdb_fpregset_t *fpregse arm_linux_supply_nwfpe (NULL, current_regcache, -1, fpregsetp, 0); } -int -arm_linux_kernel_u_size (void) -{ - return (sizeof (struct user)); -} - /* Fetch the thread-local storage pointer for libthread_db. */ ps_err_e diff -urNp gdb-orig/gdb/config/alpha/nm-linux.h gdb-head/gdb/config/alpha/nm-linux.h --- gdb-orig/gdb/config/alpha/nm-linux.h 2007-04-13 20:37:56.598175040 +0200 +++ gdb-head/gdb/config/alpha/nm-linux.h 2007-04-13 19:54:34.673193952 +0200 @@ -25,10 +25,6 @@ #include "config/nm-linux.h" -/* ptrace register ``addresses'' are absolute. */ - -#define U_REGS_OFFSET 0 - /* Given a pointer to either a gregset_t or fpregset_t, return a pointer to the first register. */ #define ALPHA_REGSET_BASE(regsetp) ((long *) (regsetp)) diff -urNp gdb-orig/gdb/config/arm/nm-linux.h gdb-head/gdb/config/arm/nm-linux.h --- gdb-orig/gdb/config/arm/nm-linux.h 2007-04-13 20:37:56.602174432 +0200 +++ gdb-head/gdb/config/arm/nm-linux.h 2007-04-13 19:54:34.678193192 +0200 @@ -23,18 +23,6 @@ #include "config/nm-linux.h" -/* ptrace register ``addresses'' are absolute. */ - -#define U_REGS_OFFSET 0 - -/* Return sizeof user struct to callers in less machine dependent routines */ -extern int kernel_u_size (void); -#define KERNEL_U_SIZE arm_linux_kernel_u_size() - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ -#define KERNEL_U_ADDR 0x0 - /* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ #define FETCH_INFERIOR_REGISTERS diff -urNp gdb-orig/gdb/config/i386/linux.mh gdb-head/gdb/config/i386/linux.mh --- gdb-orig/gdb/config/i386/linux.mh 2007-04-13 20:37:56.606173824 +0200 +++ gdb-head/gdb/config/i386/linux.mh 2007-04-13 19:54:34.682192584 +0200 @@ -2,7 +2,7 @@ NAT_FILE= nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o corelow.o \ - core-aout.o i386-nat.o i386-linux-nat.o \ + i386-nat.o i386-linux-nat.o \ proc-service.o linux-thread-db.o gcore.o \ linux-nat.o linux-fork.o diff -urNp gdb-orig/gdb/config/i386/nm-linux.h gdb-head/gdb/config/i386/nm-linux.h --- gdb-orig/gdb/config/i386/nm-linux.h 2007-04-13 20:37:56.610173216 +0200 +++ gdb-head/gdb/config/i386/nm-linux.h 2007-04-13 19:54:34.687191824 +0200 @@ -29,20 +29,6 @@ #include "i386/nm-i386.h" #include "config/nm-linux.h" -/* Support for the user area. */ - -/* Return the size of the user struct. */ -extern int kernel_u_size (void); -#define KERNEL_U_SIZE kernel_u_size() - -/* This is the amount to substract from u.u_ar0 to get the offset in - the core file of the register values. */ -#define KERNEL_U_ADDR 0 - -extern CORE_ADDR register_u_addr (CORE_ADDR blockend, int regnum); -#define REGISTER_U_ADDR(addr, blockend, regnum) \ - (addr) = register_u_addr (blockend, regnum) - /* Provide access to the i386 hardware debugging registers. */ extern void i386_linux_dr_set_control (unsigned long control); @@ -65,15 +51,6 @@ extern unsigned long i386_linux_dr_get_s /* Override copies of {fetch,store}_inferior_registers in `infptrace.c'. */ #define FETCH_INFERIOR_REGISTERS -/* Nevertheless, define CANNOT_{FETCH,STORE}_REGISTER, because we - might fall back on the code `infptrace.c' (well a copy of that code - in `i386-linux-nat.c' for now) and we can access only the - general-purpose registers in that way. */ -extern int cannot_fetch_register (int regno); -extern int cannot_store_register (int regno); -#define CANNOT_FETCH_REGISTER(regno) cannot_fetch_register (regno) -#define CANNOT_STORE_REGISTER(regno) cannot_store_register (regno) - #ifdef HAVE_PTRACE_GETFPXREGS /* Include register set support for the SSE registers. */ #define FILL_FPXREGSET diff -urNp gdb-orig/gdb/config/m68k/linux.mh gdb-head/gdb/config/m68k/linux.mh --- gdb-orig/gdb/config/m68k/linux.mh 2007-04-13 20:37:56.615172456 +0200 +++ gdb-head/gdb/config/m68k/linux.mh 2007-04-13 19:54:34.691191216 +0200 @@ -2,7 +2,7 @@ NAT_FILE= nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o \ - corelow.o core-aout.o m68klinux-nat.o gcore.o \ + corelow.o m68klinux-nat.o gcore.o \ proc-service.o linux-thread-db.o linux-nat.o linux-fork.o # The dynamically loaded libthread_db needs access to symbols in the diff -urNp gdb-orig/gdb/config/m68k/nm-linux.h gdb-head/gdb/config/m68k/nm-linux.h --- gdb-orig/gdb/config/m68k/nm-linux.h 2007-04-13 20:37:56.619171848 +0200 +++ gdb-head/gdb/config/m68k/nm-linux.h 2007-04-13 19:54:34.695190608 +0200 @@ -23,22 +23,6 @@ #include "config/nm-linux.h" -/* Return sizeof user struct to callers in less machine dependent routines */ - -#define KERNEL_U_SIZE kernel_u_size() -extern int kernel_u_size (void); - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ -#define KERNEL_U_ADDR 0x0 - -#define U_REGS_OFFSET 0 - -#define REGISTER_U_ADDR(addr, blockend, regno) \ - (addr) = m68k_linux_register_u_addr ((blockend),(regno)); - -extern int m68k_linux_register_u_addr (int, int); - /* Override copies of {fetch,store}_inferior_registers in `infptrace.c'. */ #define FETCH_INFERIOR_REGISTERS diff -urNp gdb-orig/gdb/config/mips/nm-irix5.h gdb-head/gdb/config/mips/nm-irix5.h --- gdb-orig/gdb/config/mips/nm-irix5.h 2007-04-13 20:37:56.624171088 +0200 +++ gdb-head/gdb/config/mips/nm-irix5.h 2007-04-13 19:54:34.699190000 +0200 @@ -49,9 +49,3 @@ extern int procfs_set_watchpoint (ptid_t #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(SIZE) 1 -/* Override register locations in upage for SGI machines */ -#define REGISTER_U_ADDR(addr, blockend, regno) \ - if (regno < PC_REGNUM) \ - addr = regno; \ - else \ - addr = regno + NSIG_HNDLRS; /* Skip over signal handlers */ 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:37:56.628170480 +0200 +++ gdb-head/gdb/config/mips/nm-linux.h 2007-04-13 19:54:34.703189392 +0200 @@ -24,18 +24,6 @@ #include "config/nm-linux.h" -/* Return sizeof user struct to callers in less machine dependent - routines. Hard coded for cross-compilation friendliness. */ - -#define KERNEL_U_SIZE 504 - -/* ptrace register ``addresses'' are absolute. */ - -#define U_REGS_OFFSET 0 - -#define REGISTER_U_ADDR(addr, blockend, regno) \ - (addr) = mips_register_addr ((regno),(blockend)) - 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) diff -urNp gdb-orig/gdb/config/pa/nm-linux.h gdb-head/gdb/config/pa/nm-linux.h --- gdb-orig/gdb/config/pa/nm-linux.h 2007-04-13 20:37:56.632169872 +0200 +++ gdb-head/gdb/config/pa/nm-linux.h 2007-04-13 19:54:34.707188784 +0200 @@ -23,8 +23,6 @@ #include "config/nm-linux.h" -#define U_REGS_OFFSET 0 - /* Override copies of {fetch,store}_inferior_registers in `infptrace.c'. */ #define FETCH_INFERIOR_REGISTERS diff -urNp gdb-orig/gdb/config/powerpc/nm-linux.h gdb-head/gdb/config/powerpc/nm-linux.h --- gdb-orig/gdb/config/powerpc/nm-linux.h 2007-04-13 20:37:56.636169264 +0200 +++ gdb-head/gdb/config/powerpc/nm-linux.h 2007-04-13 19:54:34.711188176 +0200 @@ -23,15 +23,6 @@ Foundation, Inc., 675 Mass Ave, Cambridg #define NM_LINUX_H -/* Return sizeof user struct to callers in less machine dependent routines */ - -#define KERNEL_U_SIZE kernel_u_size() -extern int kernel_u_size (void); - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ -#define KERNEL_U_ADDR 0x0 - #define FETCH_INFERIOR_REGISTERS #endif /* #ifndef NM_LINUX_H */ diff -urNp gdb-orig/gdb/config/vax/nm-vax.h gdb-head/gdb/config/vax/nm-vax.h --- gdb-orig/gdb/config/vax/nm-vax.h 2007-04-13 20:37:56.640168656 +0200 +++ gdb-head/gdb/config/vax/nm-vax.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,32 +0,0 @@ -/* Native-dependent definitions for VAXen under 4.2 BSD and ULTRIX. - - Copyright 1986, 1987, 1989, 1992, 2004, 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_VAX_H -#define NM_VAX_H - -extern CORE_ADDR vax_kernel_u_addr; -#define KERNEL_U_ADDR vax_kernel_u_addr - -extern CORE_ADDR vax_register_u_addr (CORE_ADDR u_ar0, int regnum); -#define REGISTER_U_ADDR(addr, u_ar0, regnum) \ - (addr) = vax_register_u_addr (u_ar0, regnum) - -#endif /* nm-vax.h */ diff -urNp gdb-orig/gdb/config/vax/vax.mh gdb-head/gdb/config/vax/vax.mh --- gdb-orig/gdb/config/vax/vax.mh 2007-04-13 20:37:56.643168200 +0200 +++ gdb-head/gdb/config/vax/vax.mh 2007-04-13 19:54:34.733184832 +0200 @@ -1,4 +1,2 @@ # Host: VAX running 4.2BSD or Ultrix -NATDEPFILES= vax-nat.o fork-child.o inf-ptrace.o \ - corelow.o core-aout.o -NAT_FILE= nm-vax.h +NATDEPFILES= vax-nat.o fork-child.o inf-ptrace.o corelow.o diff -urNp gdb-orig/gdb/core-aout.c gdb-head/gdb/core-aout.c --- gdb-orig/gdb/core-aout.c 2007-04-13 20:37:56.647167592 +0200 +++ gdb-head/gdb/core-aout.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,144 +0,0 @@ -/* Extract registers from a "standard" core file, for GDB. - Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, - 1999, 2000, 2001, 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* Typically used on systems that have a.out format executables. - corefile.c is supposed to contain the more machine-independent - aspects of reading registers from core files, while this file is - more machine specific. */ - -#include "defs.h" - -#ifdef HAVE_PTRACE_H -#include -#else -#ifdef HAVE_SYS_PTRACE_H -#include -#endif -#endif - -#include -#include -#include "gdbcore.h" -#include "value.h" -#include "regcache.h" - -/* These are needed on various systems to expand REGISTER_U_ADDR. */ -#include "gdb_dirent.h" -#include -#include "gdb_stat.h" -#include - -#ifndef CORE_REGISTER_ADDR -#define CORE_REGISTER_ADDR(regno, regptr) register_addr(regno, regptr) -#endif /* CORE_REGISTER_ADDR */ - -#ifdef NEED_SYS_CORE_H -#include -#endif - -static void fetch_core_registers (char *, unsigned, int, CORE_ADDR); - -void _initialize_core_aout (void); - -/* Extract the register values out of the core file and store - them where `read_register' will find them. - - CORE_REG_SECT points to the register values themselves, read into memory. - CORE_REG_SIZE is the size of that area. - WHICH says which set of registers we are handling (0 = int, 2 = float - on machines where they are discontiguous). - REG_ADDR is the offset from u.u_ar0 to the register values relative to - core_reg_sect. This is used with old-fashioned core files to - locate the registers in a large upage-plus-stack ".reg" section. - Original upage address X is at location core_reg_sect+x+reg_addr. - */ - -static void -fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, - CORE_ADDR reg_addr) -{ - int regno; - CORE_ADDR addr; - int bad_reg = -1; - CORE_ADDR reg_ptr = -reg_addr; /* Original u.u_ar0 is -reg_addr. */ - int numregs = NUM_REGS; - - /* If u.u_ar0 was an absolute address in the core file, relativize it now, - so we can use it as an offset into core_reg_sect. When we're done, - "register 0" will be at core_reg_sect+reg_ptr, and we can use - CORE_REGISTER_ADDR to offset to the other registers. If this is a modern - core file without a upage, reg_ptr will be zero and this is all a big - NOP. */ - if (reg_ptr > core_reg_size) - reg_ptr -= KERNEL_U_ADDR; - - for (regno = 0; regno < numregs; regno++) - { - addr = CORE_REGISTER_ADDR (regno, reg_ptr); - if (addr >= core_reg_size - && bad_reg < 0) - bad_reg = regno; - else - regcache_raw_supply (current_regcache, regno, core_reg_sect + addr); - } - - if (bad_reg >= 0) - error (_("Register %s not found in core file."), REGISTER_NAME (bad_reg)); -} - - -#ifdef REGISTER_U_ADDR - -/* Return the address in the core dump or inferior of register REGNO. - BLOCKEND is the address of the end of the user structure. */ - -CORE_ADDR -register_addr (int regno, CORE_ADDR blockend) -{ - CORE_ADDR addr; - - if (regno < 0 || regno >= NUM_REGS) - error (_("Invalid register number %d."), regno); - - REGISTER_U_ADDR (addr, blockend, regno); - - return addr; -} - -#endif /* REGISTER_U_ADDR */ - - -/* Register that we are able to handle aout (trad-core) file formats. */ - -static struct core_fns aout_core_fns = -{ - bfd_target_unknown_flavour, /* core_flavour */ - default_check_format, /* check_format */ - default_core_sniffer, /* core_sniffer */ - fetch_core_registers, /* core_read_registers */ - NULL /* next */ -}; - -void -_initialize_core_aout (void) -{ - deprecated_add_core_fns (&aout_core_fns); -} diff -urNp gdb-orig/gdb/gdbcore.h gdb-head/gdb/gdbcore.h --- gdb-orig/gdb/gdbcore.h 2007-04-13 20:37:56.652166832 +0200 +++ gdb-head/gdb/gdbcore.h 2007-04-13 19:54:34.742183464 +0200 @@ -130,11 +130,6 @@ extern void validate_files (void); extern CORE_ADDR register_addr (int regno, CORE_ADDR blockend); -#if !defined (KERNEL_U_ADDR) -extern CORE_ADDR kernel_u_addr; -#define KERNEL_U_ADDR kernel_u_addr -#endif - /* The target vector for core files. */ extern struct target_ops core_ops; diff -urNp gdb-orig/gdb/hppa-linux-nat.c gdb-head/gdb/hppa-linux-nat.c --- gdb-orig/gdb/hppa-linux-nat.c 2007-04-13 20:37:56.657166072 +0200 +++ gdb-head/gdb/hppa-linux-nat.c 2007-04-13 19:54:34.747182704 +0200 @@ -153,8 +153,8 @@ static const int u_offsets[] = PT_FR31, PT_FR31 + 4, }; -CORE_ADDR -register_addr (int regno, CORE_ADDR blockend) +static CORE_ADDR +hppa_linux_register_addr (int regno, CORE_ADDR blockend) { CORE_ADDR addr; @@ -233,7 +233,7 @@ fetch_register (int regno) tid = PIDGET (inferior_ptid); /* Not a threaded program. */ errno = 0; - val = ptrace (PTRACE_PEEKUSER, tid, register_addr (regno, 0), 0); + val = ptrace (PTRACE_PEEKUSER, tid, hppa_linux_register_addr (regno, 0), 0); if (errno != 0) error (_("Couldn't read register %s (#%d): %s."), REGISTER_NAME (regno), regno, safe_strerror (errno)); @@ -259,7 +259,7 @@ store_register (int regno) errno = 0; regcache_raw_collect (current_regcache, regno, &val); - ptrace (PTRACE_POKEUSER, tid, register_addr (regno, 0), val); + ptrace (PTRACE_POKEUSER, tid, hppa_linux_register_addr (regno, 0), val); if (errno != 0) error (_("Couldn't write register %s (#%d): %s."), REGISTER_NAME (regno), regno, safe_strerror (errno)); diff -urNp gdb-orig/gdb/i386-linux-nat.c gdb-head/gdb/i386-linux-nat.c --- gdb-orig/gdb/i386-linux-nat.c 2007-04-13 20:37:56.664165008 +0200 +++ gdb-head/gdb/i386-linux-nat.c 2007-04-13 19:54:34.753181792 +0200 @@ -137,26 +137,6 @@ int have_ptrace_getfpxregs = ; -/* Support for the user struct. */ - -/* Return the address of register REGNUM. BLOCKEND is the value of - u.u_ar0, which should point to the registers. */ - -CORE_ADDR -register_u_addr (CORE_ADDR blockend, int regnum) -{ - return (blockend + 4 * regmap[regnum]); -} - -/* Return the size of the user struct. */ - -int -kernel_u_size (void) -{ - return (sizeof (struct user)); -} - - /* Accessing registers through the U area, one at a time. */ /* Fetch one register. */ @@ -168,7 +148,7 @@ fetch_register (int regno) int val; gdb_assert (!have_ptrace_getregs); - if (cannot_fetch_register (regno)) + if (regmap[regno] == -1) { regcache_raw_supply (current_regcache, regno, NULL); return; @@ -180,7 +160,7 @@ fetch_register (int regno) tid = PIDGET (inferior_ptid); /* Not a threaded program. */ errno = 0; - val = ptrace (PTRACE_PEEKUSER, tid, register_addr (regno, 0), 0); + val = ptrace (PTRACE_PEEKUSER, tid, 4 * regmap[regno], 0); if (errno != 0) error (_("Couldn't read register %s (#%d): %s."), REGISTER_NAME (regno), regno, safe_strerror (errno)); @@ -197,7 +177,7 @@ store_register (int regno) int val; gdb_assert (!have_ptrace_getregs); - if (cannot_store_register (regno)) + if (regmap[regno] == -1) return; /* GNU/Linux LWP ID's are process ID's. */ @@ -207,7 +187,7 @@ store_register (int regno) errno = 0; regcache_raw_collect (current_regcache, regno, &val); - ptrace (PTRACE_POKEUSER, tid, register_addr (regno, 0), val); + ptrace (PTRACE_POKEUSER, tid, 4 * regmap[regno], val); if (errno != 0) error (_("Couldn't write register %s (#%d): %s."), REGISTER_NAME (regno), regno, safe_strerror (errno)); @@ -458,25 +438,6 @@ static int store_fpxregs (int tid, int r /* Transferring arbitrary registers between GDB and inferior. */ -/* Check if register REGNO in the child process is accessible. - If we are accessing registers directly via the U area, only the - general-purpose registers are available. - All registers should be accessible if we have GETREGS support. */ - -int -cannot_fetch_register (int regno) -{ - gdb_assert (regno >= 0 && regno < NUM_REGS); - return (!have_ptrace_getregs && regmap[regno] == -1); -} - -int -cannot_store_register (int regno) -{ - gdb_assert (regno >= 0 && regno < NUM_REGS); - return (!have_ptrace_getregs && regmap[regno] == -1); -} - /* Fetch register REGNO from the child process. If REGNO is -1, do this for all registers (including the floating point and SSE registers). */ diff -urNp gdb-orig/gdb/m68klinux-nat.c gdb-head/gdb/m68klinux-nat.c --- gdb-orig/gdb/m68klinux-nat.c 2007-04-13 20:37:56.670164096 +0200 +++ gdb-head/gdb/m68klinux-nat.c 2007-04-13 19:54:34.758181032 +0200 @@ -92,16 +92,6 @@ int have_ptrace_getregs = -/* BLOCKEND is the value of u.u_ar0, and points to the place where GS - is stored. */ - -int -m68k_linux_register_u_addr (int blockend, int regnum) -{ - return (blockend + 4 * regmap[regnum]); -} - - /* Fetching registers directly from the U area, one at a time. */ /* FIXME: This duplicates code from `inptrace.c'. The problem is that we @@ -127,7 +117,6 @@ fetch_register (int regno) CORE_ADDR regaddr; char mess[128]; /* For messages */ int i; - unsigned int offset; /* Offset of registers within the u area. */ char buf[MAX_REGISTER_SIZE]; int tid; @@ -143,9 +132,7 @@ fetch_register (int regno) if (tid == 0) tid = PIDGET (inferior_ptid); /* no thread id, just use process id */ - offset = U_REGS_OFFSET; - - regaddr = register_addr (regno, offset); + regaddr = 4 * regmap[regno]; for (i = 0; i < register_size (current_gdbarch, regno); i += sizeof (PTRACE_TYPE_RET)) { @@ -192,7 +179,6 @@ store_register (int regno) CORE_ADDR regaddr; char mess[128]; /* For messages */ int i; - unsigned int offset; /* Offset of registers within the u area. */ int tid; char buf[MAX_REGISTER_SIZE]; @@ -206,9 +192,7 @@ store_register (int regno) if (tid == 0) tid = PIDGET (inferior_ptid); /* no thread id, just use process id */ - offset = U_REGS_OFFSET; - - regaddr = register_addr (regno, offset); + regaddr = 4 * regmap[regno]; /* Put the contents of regno into a local buffer */ regcache_raw_collect (current_regcache, regno, buf); @@ -595,12 +579,6 @@ fetch_core_registers (char *core_reg_sec } -int -kernel_u_size (void) -{ - return (sizeof (struct user)); -} - /* Register that we are able to handle GNU/Linux ELF core file formats. */ diff -urNp gdb-orig/gdb/Makefile.in gdb-head/gdb/Makefile.in --- gdb-orig/gdb/Makefile.in 2007-04-13 20:37:56.695160296 +0200 +++ gdb-head/gdb/Makefile.in 2007-04-13 19:54:34.784177080 +0200 @@ -1433,7 +1433,7 @@ ALLDEPFILES = \ armnbsd-nat.c armbsd-tdep.c armnbsd-tdep.c armobsd-tdep.c \ avr-tdep.c \ bsd-uthread.c bsd-kvm.c \ - core-regset.c core-aout.c corelow.c \ + core-regset.c corelow.c \ dcache.c exec.c \ fbsd-nat.c \ fork-child.c \ @@ -1876,8 +1876,6 @@ completer.o: completer.c $(defs_h) $(sym $(filenames_h) $(language_h) $(cli_decode_h) $(gdbcmd_h) \ $(readline_h) $(completer_h) copying.o: copying.c $(defs_h) $(command_h) $(gdbcmd_h) -core-aout.o: core-aout.c $(defs_h) $(gdbcore_h) $(value_h) $(regcache_h) \ - $(gdb_dirent_h) $(gdb_stat_h) corefile.o: corefile.c $(defs_h) $(gdb_string_h) $(inferior_h) $(symtab_h) \ $(command_h) $(gdbcmd_h) $(bfd_h) $(target_h) $(gdbcore_h) \ $(dis_asm_h) $(gdb_stat_h) $(completer_h) $(exceptions_h) diff -urNp gdb-orig/gdb/ppc-linux-nat.c gdb-head/gdb/ppc-linux-nat.c --- gdb-orig/gdb/ppc-linux-nat.c 2007-04-13 20:37:56.703159080 +0200 +++ gdb-head/gdb/ppc-linux-nat.c 2007-04-13 19:54:34.829170240 +0200 @@ -152,12 +152,6 @@ static CORE_ADDR last_stopped_data_addre error. */ int have_ptrace_getsetevrregs = 1; -int -kernel_u_size (void) -{ - return (sizeof (struct user)); -} - /* *INDENT-OFF* */ /* registers layout, as presented by the ptrace interface: PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7, diff -urNp gdb-orig/gdb/vax-nat.c gdb-head/gdb/vax-nat.c --- gdb-orig/gdb/vax-nat.c 2007-04-13 20:37:56.707158472 +0200 +++ gdb-head/gdb/vax-nat.c 2007-04-13 19:54:34.833169632 +0200 @@ -48,7 +48,7 @@ /* Address of the user structure. This is the the value for 32V; 3BSD uses a different value, but hey, who's still using those systems? */ -CORE_ADDR vax_kernel_u_addr = 0x80020000; +static CORE_ADDR vax_kernel_u_addr = 0x80020000; /* Location of the user's stored registers; usage is `u.u_ar0[XX]'. For 4.2BSD and ULTRIX these are negative! See . */ @@ -59,7 +59,7 @@ static int vax_register_index[] = AP, FP, SP, PC, PS }; -CORE_ADDR +static CORE_ADDR vax_register_u_addr (CORE_ADDR u_ar0, int regnum) { gdb_assert (regnum >= 0 && regnum < ARRAY_SIZE (vax_register_index)); -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com