Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [commit] Clean up proc-service includes in gdbserver
@ 2006-03-15 16:36 Daniel Jacobowitz
  2006-03-15 22:28 ` Michael Snyder
  2006-03-15 22:39 ` Mark Kettenis
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2006-03-15 16:36 UTC (permalink / raw)
  To: gdb-patches

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  <dan@codesourcery.com>

	* 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 <sys/procfs.h>
-       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 @@
+/* <proc_service.h> 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 <sys/types.h>
+
+#ifdef HAVE_PROC_SERVICE_H
+#include <proc_service.h>
+#else
+
+#ifdef HAVE_SYS_PROCFS_H
+#include <sys/procfs.h>
+#endif
+
+/* Not all platforms bring in <linux/elf.h> via <sys/procfs.h>.  If
+   <sys/procfs.h> 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 <linux/elf.h>
+# 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 <linux/elf.h>
-   via <sys/procfs.h>.  */
-#ifdef HAVE_LINUX_ELF_H   
-#include <linux/elf.h>    
-#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 <linux/elf.h>
-   via <sys/procfs.h>.  */
-#ifdef HAVE_LINUX_ELF_H   
-#include <linux/elf.h>    
-#endif
-#endif
-   
-#include "../gdb_proc_service.h"
+#include "gdb_proc_service.h"
 
 #include <sys/ptrace.h>
 
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 <linux/elf.h>
-   via <sys/procfs.h>.  */
-#ifdef HAVE_LINUX_ELF_H   
-#include <linux/elf.h>    
-#endif
-#endif
-   
-#include "../gdb_proc_service.h"
+#include "gdb_proc_service.h"
 
 #include <sys/reg.h>
 #include <sys/procfs.h>
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 <thread_db.h>
 #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 <linux/elf.h>
-   via <sys/procfs.h>.  */
-#ifdef HAVE_LINUX_ELF_H
-#include <linux/elf.h>
-#endif
-#endif
-
-#include "../gdb_proc_service.h"
+#include "gdb_proc_service.h"
 
 /* Structure that identifies the child process for the
    <proc_service.h> interface.  */


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [commit] Clean up proc-service includes in gdbserver
  2006-03-15 16:36 [commit] Clean up proc-service includes in gdbserver Daniel Jacobowitz
@ 2006-03-15 22:28 ` Michael Snyder
  2006-03-15 22:36   ` Daniel Jacobowitz
  2006-03-15 22:39 ` Mark Kettenis
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Snyder @ 2006-03-15 22:28 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel Jacobowitz wrote:
> 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.
> 

If gdb_proc_service.h is shared between gdb and gdbserver,
should we move it up to ../include/gdb?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [commit] Clean up proc-service includes in gdbserver
  2006-03-15 22:28 ` Michael Snyder
@ 2006-03-15 22:36   ` Daniel Jacobowitz
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2006-03-15 22:36 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb-patches

On Wed, Mar 15, 2006 at 11:48:09AM -0800, Michael Snyder wrote:
> Daniel Jacobowitz wrote:
> >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.
> >
> 
> If gdb_proc_service.h is shared between gdb and gdbserver,
> should we move it up to ../include/gdb?

That might be a good idea if they wanted to keep the same versions,
yes; but I've just diverged them, which I think will be simpler.
The GDB copy includes "gregset.h" and messes around with bits
from the GDB native configuration - bit hard to reuse.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [commit] Clean up proc-service includes in gdbserver
  2006-03-15 16:36 [commit] Clean up proc-service includes in gdbserver Daniel Jacobowitz
  2006-03-15 22:28 ` Michael Snyder
@ 2006-03-15 22:39 ` Mark Kettenis
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Kettenis @ 2006-03-15 22:39 UTC (permalink / raw)
  To: gdb-patches

> Date: Wed, 15 Mar 2006 11:16:33 -0500
> From: Daniel Jacobowitz <drow@false.org>
> 
> 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.

Heh, thanks.  This certainly looks like an improvement!

Mark


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-03-15 22:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-15 16:36 [commit] Clean up proc-service includes in gdbserver Daniel Jacobowitz
2006-03-15 22:28 ` Michael Snyder
2006-03-15 22:36   ` Daniel Jacobowitz
2006-03-15 22:39 ` Mark Kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox