From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10944 invoked by alias); 15 Mar 2006 16:16:40 -0000 Received: (qmail 10935 invoked by uid 22791); 15 Mar 2006 16:16:38 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Wed, 15 Mar 2006 16:16:36 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1FJYfp-00043j-TH for gdb-patches@sourceware.org; Wed, 15 Mar 2006 11:16:34 -0500 Date: Wed, 15 Mar 2006 16:36:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sourceware.org Subject: [commit] Clean up proc-service includes in gdbserver Message-ID: <20060315161633.GA15527@nevyn.them.org> Mail-Followup-To: gdb-patches@sourceware.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.8i X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-03/txt/msg00189.txt.bz2 A while ago, I posted MIPS and ARM NPTL support for gdbserver. Before I got around to checking it in, Mark K. looked at one of them and went "ewwww..."; it was just copied from three other places in gdbserver, but I totally agree with his reaction. So this patch un-ewwws things a bit. Instead of borrowing gdb_proc_service.h from gdb, this patch gives gdbserver its own, slightly different copy. We don't use the prfpregset_t functions at all, so we can lose some old autoconf checks, too. Tested and committed. -- Daniel Jacobowitz CodeSourcery 2006-03-15 Daniel Jacobowitz * configure.ac: Remove checks for prfpregset_t. * gdb_proc_service.h: New file. * linux-i386-low.c, linux-x86-64-low.c, thread-db.c: Use the new "gdb_proc_service.h". * proc-service.c: Likewise. (ps_pglobal_lookup, ps_pdread, ps_pdwrite): Use psaddr_t. (ps_lgetfpregs, ps_lsetfpregs): Use a void* argument. * Makefile.in (gdb_proc_service_h): Updated. * configure, config.in: Regenerated. Index: src/gdb/gdbserver/configure.ac =================================================================== --- src.orig/gdb/gdbserver/configure.ac 2006-03-14 15:44:32.000000000 -0500 +++ src/gdb/gdbserver/configure.ac 2006-03-14 16:24:45.000000000 -0500 @@ -1,5 +1,6 @@ dnl Autoconf configure script for GDB server. -dnl Copyright (C) 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +dnl Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006 +dnl Free Software Foundation, Inc. dnl dnl This file is part of GDB. dnl @@ -88,35 +89,6 @@ if test "$ac_cv_header_sys_procfs_h" = y BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t) BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t) BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t) - BFD_HAVE_SYS_PROCFS_TYPE(prfpregset_t) - - dnl Check for broken prfpregset_t type - - dnl For Linux/i386, glibc 2.1.3 was released with a bogus - dnl prfpregset_t type (it's a typedef for the pointer to a struct - dnl instead of the struct itself). We detect this here, and work - dnl around it in gdb_proc_service.h. - - if test $bfd_cv_have_sys_procfs_type_prfpregset_t = yes; then - AC_MSG_CHECKING(whether prfpregset_t type is broken) - AC_CACHE_VAL(gdb_cv_prfpregset_t_broken, - [AC_TRY_RUN([#include - int main () - { - if (sizeof (prfpregset_t) == sizeof (void *)) - return 1; - return 0; - }], - gdb_cv_prfpregset_t_broken=no, - gdb_cv_prfpregset_t_broken=yes, - gdb_cv_prfpregset_t_broken=yes)]) - AC_MSG_RESULT($gdb_cv_prfpregset_t_broken) - if test $gdb_cv_prfpregset_t_broken = yes; then - AC_DEFINE(PRFPREGSET_T_BROKEN, 1, - [Define if the prfpregset_t type is broken.]) - fi - fi - BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t) fi Index: src/gdb/gdbserver/gdb_proc_service.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ src/gdb/gdbserver/gdb_proc_service.h 2006-03-14 16:22:01.000000000 -0500 @@ -0,0 +1,75 @@ +/* replacement for systems that don't have it. + Copyright (C) 2000, 2006 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. */ + +#ifndef GDB_PROC_SERVICE_H +#define GDB_PROC_SERVICE_H + +#include + +#ifdef HAVE_PROC_SERVICE_H +#include +#else + +#ifdef HAVE_SYS_PROCFS_H +#include +#endif + +/* Not all platforms bring in via . If + wasn't enough to find elf_fpregset_t, try the kernel + headers also (but don't if we don't need to). */ +#ifndef HAVE_ELF_FPREGSET_T +# ifdef HAVE_LINUX_ELF_H +# include +# endif +#endif + +typedef enum +{ + PS_OK, /* Success. */ + PS_ERR, /* Generic error. */ + PS_BADPID, /* Bad process handle. */ + PS_BADLID, /* Bad LWP id. */ + PS_BADADDR, /* Bad address. */ + PS_NOSYM, /* Symbol not found. */ + PS_NOFREGS /* FPU register set not available. */ +} ps_err_e; + +#ifndef HAVE_LWPID_T +typedef unsigned int lwpid_t; +#endif + +#ifndef HAVE_PSADDR_T +typedef unsigned long psaddr_t; +#endif + +#ifndef HAVE_PRGREGSET_T +typedef elf_gregset_t prgregset_t; +#endif + +#endif /* HAVE_PROC_SERVICE_H */ + +/* Structure that identifies the target process. */ +struct ps_prochandle +{ + /* The process id is all we need. */ + pid_t pid; +}; + +#endif /* gdb_proc_service.h */ Index: src/gdb/gdbserver/proc-service.c =================================================================== --- src.orig/gdb/gdbserver/proc-service.c 2006-03-14 15:44:32.000000000 -0500 +++ src/gdb/gdbserver/proc-service.c 2006-03-14 16:27:51.000000000 -0500 @@ -1,5 +1,5 @@ /* libthread_db helper functions for the remote server for GDB. - Copyright (C) 2002, 2004, 2005 + Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by MontaVista Software. @@ -29,19 +29,7 @@ #include "linux-low.h" -/* Correct for all GNU/Linux targets (for quite some time). */ -#define GDB_GREGSET_T elf_gregset_t -#define GDB_FPREGSET_T elf_fpregset_t - -#ifndef HAVE_ELF_FPREGSET_T -/* Make sure we have said types. Not all platforms bring in - via . */ -#ifdef HAVE_LINUX_ELF_H -#include -#endif -#endif - -#include "../gdb_proc_service.h" +#include "gdb_proc_service.h" typedef struct ps_prochandle *gdb_ps_prochandle_t; typedef void *gdb_ps_read_buf_t; @@ -75,14 +63,14 @@ gregset_info(void) ps_err_e ps_pglobal_lookup (gdb_ps_prochandle_t ph, const char *obj, - const char *name, paddr_t *sym_addr) + const char *name, psaddr_t *sym_addr) { CORE_ADDR addr; if (look_up_one_symbol (name, &addr) == 0) return PS_NOSYM; - *sym_addr = (paddr_t) (unsigned long) addr; + *sym_addr = (psaddr_t) (unsigned long) addr; return PS_OK; } @@ -90,20 +78,20 @@ ps_pglobal_lookup (gdb_ps_prochandle_t p them into BUF. */ ps_err_e -ps_pdread (gdb_ps_prochandle_t ph, paddr_t addr, +ps_pdread (gdb_ps_prochandle_t ph, psaddr_t addr, gdb_ps_read_buf_t buf, gdb_ps_size_t size) { - read_inferior_memory (addr, buf, size); + read_inferior_memory ((unsigned long) addr, buf, size); return PS_OK; } /* Write SIZE bytes from BUF into the target process PH at address ADDR. */ ps_err_e -ps_pdwrite (gdb_ps_prochandle_t ph, paddr_t addr, +ps_pdwrite (gdb_ps_prochandle_t ph, psaddr_t addr, gdb_ps_write_buf_t buf, gdb_ps_size_t size) { - return write_inferior_memory (addr, buf, size); + return write_inferior_memory ((unsigned long) addr, buf, size); } /* Get the general registers of LWP LWPID within the target process PH @@ -149,8 +137,7 @@ ps_lsetregs (gdb_ps_prochandle_t ph, lwp process PH and store them in FPREGSET. */ ps_err_e -ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, - gdb_prfpregset_t *fpregset) +ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, void *fpregset) { /* Unneeded. */ return PS_ERR; @@ -160,8 +147,7 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, l process PH from FPREGSET. */ ps_err_e -ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, - const gdb_prfpregset_t *fpregset) +ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, void *fpregset) { /* Unneeded. */ return PS_ERR; Index: src/gdb/gdbserver/Makefile.in =================================================================== --- src.orig/gdb/gdbserver/Makefile.in 2006-03-14 15:44:32.000000000 -0500 +++ src/gdb/gdbserver/Makefile.in 2006-03-14 16:15:15.000000000 -0500 @@ -242,7 +242,7 @@ version.o: version.c $(server_h) # will remove them. MAKEOVERRIDES= -gdb_proc_service_h = $(srcdir)/../gdb_proc_service.h $(srcdir)/../gregset.h +gdb_proc_service_h = $(srcdir)/gdb_proc_service.h regdat_sh = $(srcdir)/../regformats/regdat.sh regdef_h = $(srcdir)/../regformats/regdef.h regcache_h = $(srcdir)/regcache.h Index: src/gdb/gdbserver/linux-i386-low.c =================================================================== --- src.orig/gdb/gdbserver/linux-i386-low.c 2006-03-14 15:44:32.000000000 -0500 +++ src/gdb/gdbserver/linux-i386-low.c 2006-03-14 16:27:40.000000000 -0500 @@ -1,5 +1,5 @@ /* GNU/Linux/i386 specific low level interface, for the remote server for GDB. - Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2004, 2005 + Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -23,19 +23,7 @@ #include "linux-low.h" #include "i387-fp.h" -/* Correct for all GNU/Linux targets (for quite some time). */ -#define GDB_GREGSET_T elf_gregset_t -#define GDB_FPREGSET_T elf_fpregset_t - -#ifndef HAVE_ELF_FPREGSET_T -/* Make sure we have said types. Not all platforms bring in - via . */ -#ifdef HAVE_LINUX_ELF_H -#include -#endif -#endif - -#include "../gdb_proc_service.h" +#include "gdb_proc_service.h" #include Index: src/gdb/gdbserver/linux-x86-64-low.c =================================================================== --- src.orig/gdb/gdbserver/linux-x86-64-low.c 2006-03-14 15:44:32.000000000 -0500 +++ src/gdb/gdbserver/linux-x86-64-low.c 2006-03-14 16:27:44.000000000 -0500 @@ -1,6 +1,6 @@ /* GNU/Linux/x86-64 specific low level interface, for the remote server for GDB. - Copyright (C) 2002, 2004, 2005 + Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -24,19 +24,7 @@ #include "linux-low.h" #include "i387-fp.h" -/* Correct for all GNU/Linux targets (for quite some time). */ -#define GDB_GREGSET_T elf_gregset_t -#define GDB_FPREGSET_T elf_fpregset_t - -#ifndef HAVE_ELF_FPREGSET_T -/* Make sure we have said types. Not all platforms bring in - via . */ -#ifdef HAVE_LINUX_ELF_H -#include -#endif -#endif - -#include "../gdb_proc_service.h" +#include "gdb_proc_service.h" #include #include Index: src/gdb/gdbserver/thread-db.c =================================================================== --- src.orig/gdb/gdbserver/thread-db.c 2006-03-14 15:44:32.000000000 -0500 +++ src/gdb/gdbserver/thread-db.c 2006-03-14 16:27:49.000000000 -0500 @@ -1,5 +1,5 @@ /* Thread management interface, for the remote server for GDB. - Copyright (C) 2002, 2004, 2005 + Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by MontaVista Software. @@ -31,19 +31,7 @@ extern int debug_threads; #include #endif -/* Correct for all GNU/Linux targets (for quite some time). */ -#define GDB_GREGSET_T elf_gregset_t -#define GDB_FPREGSET_T elf_fpregset_t - -#ifndef HAVE_ELF_FPREGSET_T -/* Make sure we have said types. Not all platforms bring in - via . */ -#ifdef HAVE_LINUX_ELF_H -#include -#endif -#endif - -#include "../gdb_proc_service.h" +#include "gdb_proc_service.h" /* Structure that identifies the child process for the interface. */