From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9073 invoked by alias); 14 Apr 2007 21:10:35 -0000 Received: (qmail 9064 invoked by uid 22791); 14 Apr 2007 21:10:34 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate8.de.ibm.com (HELO mtagate8.de.ibm.com) (195.212.29.157) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 14 Apr 2007 22:10:31 +0100 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate8.de.ibm.com (8.13.8/8.13.8) with ESMTP id l3ELATAX035786 for ; Sat, 14 Apr 2007 21:10:29 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 l3ELATLE4059354 for ; Sat, 14 Apr 2007 23:10:29 +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 l3ELASd5008361 for ; Sat, 14 Apr 2007 23:10:29 +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 l3ELASpq008358 for ; Sat, 14 Apr 2007 23:10:28 +0200 Message-Id: <200704142110.l3ELASpq008358@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Sat, 14 Apr 2007 23:10:28 +0200 Subject: [rfc/rft] [3/5] Untangle register_addr: CANNOT_FETCH/STORE_REGISTER To: gdb-patches@sourceware.org Date: Sat, 14 Apr 2007 21:11: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/msg00225.txt.bz2 Hello, this patch removes the calls to CANNOT_FETCH_REGISTER / CANNOT_STORE_REGISTER from within the inf_ptrace_trad_target routines. This is enabled by two changes to the register_u_offset callback: - the routine is allowed to return (CORE_ADDR)-1 to indicate the requested register cannot be accessed - the routine gains a new argument STORE_P that indicates whether the register is to be fetched or stored There are three users of inf_ptrace_trad_target, vax-ultrix (which does not have any CANNOT_FETCH_REGISTER / CANNOT_STORE_REGISTER anyway), and alpha-linux and mips-linux via linux_trad_target. For the latter, this patch simply updates their register_u_offset routines to add CANNOT_FETCH_REGISTER / CANNOT_STORE_REGISTER calls; this patch thus should not cause any change in behaviour. (Follow-on patches will further clean up those two targets.) Tested on i368-linux and powerpc-linux, and by verifying that alpha-linux, mips-linux and vax-ultrix native targets still build. Bye, Ulrich ChangeLog: * inf-ptrace.c (inf_ptrace_register_u_offset): Add STORE_P argument. (inf_ptrace_fetch_register): Update call. Check for (CORE_ADDR)-1 return value; replaces CANNOT_FETCH_REGISTER call. (inf_ptrace_store_register): Update call. Check for (CORE_ADDR)-1 return value; replaces CANNOT_STORE_REGISTER call. (inf_ptrace_trad_target): Update signature. * inf-ptrace.h (inf_ptrace_trad_target): Likewise. * linux-nat.c (linux_trad_target): Likewise. * linux-nat.h (linux_trad_target): Likewise. * alpha-linux-nat.c (alpha_linux_register_u_offset): Add STORE_P argument. Call CANNOT_STORE_REGISTER / CANNOT_FETCH_REGISTER. * mips-linux-nat.c (mips_linux_register_u_offset): Likewise. * vax-nat.c (vax_register_u_addr): Add STORE_P argument. diff -urNp gdb-orig/gdb/alpha-linux-nat.c gdb-head/gdb/alpha-linux-nat.c --- gdb-orig/gdb/alpha-linux-nat.c 2007-04-14 00:46:45.843259816 +0200 +++ gdb-head/gdb/alpha-linux-nat.c 2007-04-14 00:46:32.987217952 +0200 @@ -24,8 +24,11 @@ #include "gdbcore.h" static CORE_ADDR -alpha_linux_register_u_offset (int regno) +alpha_linux_register_u_offset (int regno, int store_p) { + if (store_p? CANNOT_STORE_REGISTER (regno) : 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). */ diff -urNp gdb-orig/gdb/inf-ptrace.c gdb-head/gdb/inf-ptrace.c --- gdb-orig/gdb/inf-ptrace.c 2007-04-12 16:12:54.000000000 +0200 +++ gdb-head/gdb/inf-ptrace.c 2007-04-14 00:46:32.992217192 +0200 @@ -607,7 +607,7 @@ inf_ptrace_target (void) /* Pointer to a function that returns the offset within the user area where a particular register is stored. */ -static CORE_ADDR (*inf_ptrace_register_u_offset)(int); +static CORE_ADDR (*inf_ptrace_register_u_offset)(int, int); /* Fetch register REGNUM from the inferior. */ @@ -619,7 +619,9 @@ inf_ptrace_fetch_register (int regnum) PTRACE_TYPE_RET *buf; int pid, i; - if (CANNOT_FETCH_REGISTER (regnum)) + /* This isn't really an address, but ptrace thinks of it as one. */ + addr = inf_ptrace_register_u_offset (regnum, 0); + if (addr == (CORE_ADDR)-1) { regcache_raw_supply (current_regcache, regnum, NULL); return; @@ -631,10 +633,7 @@ inf_ptrace_fetch_register (int regnum) if (pid == 0) pid = ptid_get_pid (inferior_ptid); - /* This isn't really an address, but ptrace thinks of it as one. */ - addr = inf_ptrace_register_u_offset (regnum); size = register_size (current_gdbarch, regnum); - gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0); buf = alloca (size); @@ -675,7 +674,9 @@ inf_ptrace_store_register (int regnum) PTRACE_TYPE_RET *buf; int pid, i; - if (CANNOT_STORE_REGISTER (regnum)) + /* This isn't really an address, but ptrace thinks of it as one. */ + addr = inf_ptrace_register_u_offset (regnum, 1); + if (addr == (CORE_ADDR)-1) return; /* Cater for systems like GNU/Linux, that implement threads as @@ -684,10 +685,7 @@ inf_ptrace_store_register (int regnum) if (pid == 0) pid = ptid_get_pid (inferior_ptid); - /* This isn't really an address, but ptrace thinks of it as one. */ - addr = inf_ptrace_register_u_offset (regnum); size = register_size (current_gdbarch, regnum); - gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0); buf = alloca (size); @@ -723,7 +721,7 @@ inf_ptrace_store_registers (int regnum) particular register is stored. */ struct target_ops * -inf_ptrace_trad_target (CORE_ADDR (*register_u_offset)(int)) +inf_ptrace_trad_target (CORE_ADDR (*register_u_offset)(int, int)) { struct target_ops *t = inf_ptrace_target(); diff -urNp gdb-orig/gdb/inf-ptrace.h gdb-head/gdb/inf-ptrace.h --- gdb-orig/gdb/inf-ptrace.h 2007-04-12 16:12:54.000000000 +0200 +++ gdb-head/gdb/inf-ptrace.h 2007-04-14 00:46:32.996216584 +0200 @@ -32,6 +32,6 @@ extern struct target_ops *inf_ptrace_tar particular register is stored. */ extern struct target_ops * - inf_ptrace_trad_target (CORE_ADDR (*register_u_offset)(int)); + inf_ptrace_trad_target (CORE_ADDR (*register_u_offset)(int, int)); #endif diff -urNp gdb-orig/gdb/linux-nat.c gdb-head/gdb/linux-nat.c --- gdb-orig/gdb/linux-nat.c 2007-04-14 00:46:45.941244920 +0200 +++ gdb-head/gdb/linux-nat.c 2007-04-14 00:46:33.005215216 +0200 @@ -3196,7 +3196,7 @@ linux_target (void) } struct target_ops * -linux_trad_target (CORE_ADDR (*register_u_offset)(int)) +linux_trad_target (CORE_ADDR (*register_u_offset)(int, int)) { struct target_ops *t; diff -urNp gdb-orig/gdb/linux-nat.h gdb-head/gdb/linux-nat.h --- gdb-orig/gdb/linux-nat.h 2007-04-14 00:46:45.946244160 +0200 +++ gdb-head/gdb/linux-nat.h 2007-04-14 00:46:33.046208984 +0200 @@ -91,7 +91,7 @@ struct target_ops * linux_target (void); /* Create a generic GNU/Linux target using traditional ptrace register access. */ struct target_ops * -linux_trad_target (CORE_ADDR (*register_u_offset)(int)); +linux_trad_target (CORE_ADDR (*register_u_offset)(int, int)); /* Register the customized GNU/Linux target. This should be used instead of calling add_target directly. */ 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 00:46:45.960242032 +0200 +++ gdb-head/gdb/mips-linux-nat.c 2007-04-14 00:46:33.062206552 +0200 @@ -251,8 +251,11 @@ mips64_linux_store_registers (int regnum REGNO. */ static CORE_ADDR -mips_linux_register_u_offset (int regno) +mips_linux_register_u_offset (int regno, int store_p) { + if (store_p? CANNOT_STORE_REGISTER (regno) : 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). */ diff -urNp gdb-orig/gdb/vax-nat.c gdb-head/gdb/vax-nat.c --- gdb-orig/gdb/vax-nat.c 2007-04-13 20:40:05.608266416 +0200 +++ gdb-head/gdb/vax-nat.c 2007-04-14 00:46:33.066205944 +0200 @@ -69,7 +69,7 @@ vax_register_u_addr (CORE_ADDR u_ar0, in } static CORE_ADDR -vax_register_u_offset (int regnum) +vax_register_u_offset (int regnum, int store_p) { size_t u_ar0_offset = offsetof (struct user, u_ar0); CORE_ADDR u_ar0; -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com