[PATCH] Move some common NetBSD target dependent code to nbsd-tdep.c

Jason R Thorpe thorpej@wasabisystems.com
Sat May 11 15:13:00 GMT 2002


Move some code that is (or will soon be) shared by multiple NetBSD
targets into a common file.

Committed to trunk.

        * Makefile.in (ALLDEPFILES): Add nbsd-tdep.c.
        (alphanbsd-tdep.o): Add nbsd-tdep.h to dependency list.
        (nbsd-tdep.o): New dependency list.
        * alphanbsd-tdep.c: Don't include solib-svr4.h.  Include
        nbsd-tdep.h.
        (alphanbsd_solib_svr4_fetch_link_map_offsets): Remove.
        (alphanbsd_init_abi): Use nbsd_lp64_solib_svr4_fetch_link_map_offsets.
        * nbsd-tdep.c: New file.
        * nbsd-tdep.h: New file.
        * shnbsd-tdep.c: Don't include solib-svr4.h.  Include
        nbsd-tdep.h.
        (shnbsd_solib_svr4_fetch_link_map_offsets): Remove.
        (shnbsd_init_abi): Use nbsd_ilp32_solib_svr4_fetch_link_map_offsets.
        * config/alpha/nbsd.mt (TDEPFILES): Add nbsd-tdep.o.
        * config/sh/nbsd.mt (TDEPFILES): Ditto.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>
-------------- next part --------------
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.183
diff -u -r1.183 Makefile.in
--- Makefile.in	11 May 2002 17:22:26 -0000	1.183
+++ Makefile.in	11 May 2002 22:04:36 -0000
@@ -1205,6 +1205,7 @@
 	mips-linux-nat.c mips-linux-tdep.c \
 	mips-nat.c \
 	mips-tdep.c mipsm3-nat.c mipsv4-nat.c \
+	nbsd-tdep.c \
 	nindy-share/Onindy.c nindy-share/nindy.c \
 	nindy-share/ttyflush.c nindy-tdep.c \
 	ns32k-tdep.c solib-osf.c \
@@ -1261,7 +1262,7 @@
 alphafbsd-tdep.o: alphafbsd-tdep.c $(defs_h) $(value_h) alpha-tdep.h
 
 alphanbsd-tdep.o: alphanbsd-tdep.c $(defs_h) $(gdbcore_h) $(regcache_h) \
-	$(value_h) alpha-tdep.h alphabsd-tdep.h
+	$(value_h) alpha-tdep.h alphabsd-tdep.h nbsd-tdep.h
 
 annotate.o: annotate.c $(defs_h) $(annotate_h) $(value_h) $(target_h) $(gdbtypes_h)
 
@@ -1798,6 +1799,8 @@
 monitor.o: monitor.c $(monitor_h) $(bfd_h) $(defs_h) $(gdbcmd_h) \
 	$(inferior_h) $(target_h) $(serial_h) $(terminal_h) $(gdb_string_h) \
 	$(regcache_h)
+
+nbsd-tdep.o: nbsd-tdep.c $(defs_h) solib-svr4.h
 
 Onindy.o: nindy-share/Onindy.c gdb_wait.h nindy-share/block_io.h \
 	nindy-share/env.h
Index: alphanbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alphanbsd-tdep.c,v
retrieving revision 1.4
diff -u -r1.4 alphanbsd-tdep.c
--- alphanbsd-tdep.c	11 May 2002 16:56:16 -0000	1.4
+++ alphanbsd-tdep.c	11 May 2002 22:04:37 -0000
@@ -23,10 +23,10 @@
 #include "gdbcore.h"
 #include "regcache.h"
 #include "value.h"
-#include "solib-svr4.h"
 
 #include "alpha-tdep.h"
 #include "alphabsd-tdep.h"
+#include "nbsd-tdep.h"
 
 static void
 fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
@@ -117,47 +117,6 @@
   NULL					/* next */
 };
 
-/* Fetch (and possibly build) an appropriate link_map_offsets
-   structure for NetBSD/alpha targets using the struct offsets
-   defined in <link.h> (but without actual reference to that file).
-
-   This makes it possible to access NetBSD/alpha shared libraries
-   from a GDB that was not built on a NetBSD/alpha host (for cross
-   debugging).  */
-
-static struct link_map_offsets *
-alphanbsd_solib_svr4_fetch_link_map_offsets (void)
-{
-  static struct link_map_offsets lmo;
-  static struct link_map_offsets *lmp = NULL;
-
-  if (lmp == NULL)
-    {
-      lmp = &lmo;
-
-      lmo.r_debug_size = 32;
-
-      lmo.r_map_offset = 8;
-      lmo.r_map_size   = 8;
-
-      lmo.link_map_size = 40;
-
-      lmo.l_addr_offset = 0;
-      lmo.l_addr_size   = 8;
-
-      lmo.l_name_offset = 8;
-      lmo.l_name_size   = 8;
-
-      lmo.l_next_offset = 24;
-      lmo.l_next_size   = 8;
-
-      lmo.l_prev_offset = 32;
-      lmo.l_prev_size   = 8;
-    }
-
-  return lmp;
-}
-
 /* Under NetBSD/alpha, signal handler invocations can be identified by the
    designated code sequence that is used to return from a signal handler.
    In particular, the return address of a signal handler points to the
@@ -233,7 +192,7 @@
   set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
 
   set_solib_svr4_fetch_link_map_offsets (gdbarch,
-                                  alphanbsd_solib_svr4_fetch_link_map_offsets);
+                                 nbsd_lp64_solib_svr4_fetch_link_map_offsets);
 
   tdep->dynamic_sigtramp_offset = alphanbsd_sigtramp_offset;
 
Index: nbsd-tdep.c
===================================================================
RCS file: nbsd-tdep.c
diff -N nbsd-tdep.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ nbsd-tdep.c	11 May 2002 22:04:40 -0000
@@ -0,0 +1,99 @@
+/* Common target-dependent code for NetBSD systems.
+   Copyright 2002 Free Software Foundation, Inc.
+   Contributed by Wasabi Systems, 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.  */
+
+#include "defs.h"
+#include "solib-svr4.h"
+
+/* Fetch (and possibly build) an appropriate link_map_offsets
+   structure for NetBSD/sh targets using the struct offsets
+   defined in <link.h> (but without actual reference to that file).
+  
+   This makes it possible to access NetBSD/sh shared libraries
+   from a GDB that was not built on a NetBSD/sh host (for cross
+   debugging).
+
+   We provide versions for ILP32 and LP64 NetBSD targets here.  */
+  
+struct link_map_offsets *
+nbsd_ilp32_solib_svr4_fetch_link_map_offsets (void)
+{
+  static struct link_map_offsets lmo;
+  static struct link_map_offsets *lmp = NULL;
+
+  if (lmp == NULL)
+    {
+      lmp = &lmo;
+
+      lmo.r_debug_size = 16;
+
+      lmo.r_map_offset = 4;
+      lmo.r_map_size   = 4;
+
+      lmo.link_map_size = 20;
+
+      lmo.l_addr_offset = 0;
+      lmo.l_addr_size   = 4;
+
+      lmo.l_name_offset = 4;
+      lmo.l_name_size   = 4;
+
+      lmo.l_next_offset = 12;
+      lmo.l_next_size   = 4;
+
+      lmo.l_prev_offset = 16;
+      lmo.l_prev_size   = 4;
+    }
+
+  return lmp;
+}
+
+struct link_map_offsets *
+nbsd_lp64_solib_svr4_fetch_link_map_offsets (void)
+{
+  static struct link_map_offsets lmo;
+  static struct link_map_offsets *lmp = NULL;
+
+  if (lmp == NULL)
+    {
+      lmp = &lmo;
+
+      lmo.r_debug_size = 32;
+
+      lmo.r_map_offset = 8;
+      lmo.r_map_size   = 8;
+
+      lmo.link_map_size = 40;
+
+      lmo.l_addr_offset = 0;
+      lmo.l_addr_size   = 8;
+
+      lmo.l_name_offset = 8;
+      lmo.l_name_size   = 8;
+
+      lmo.l_next_offset = 24;
+      lmo.l_next_size   = 8;
+
+      lmo.l_prev_offset = 32;
+      lmo.l_prev_size   = 8;
+    }
+
+  return lmp;
+}
Index: nbsd-tdep.h
===================================================================
RCS file: nbsd-tdep.h
diff -N nbsd-tdep.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ nbsd-tdep.h	11 May 2002 22:04:40 -0000
@@ -0,0 +1,28 @@
+/* Common target-dependent definitions for NetBSD systems.
+   Copyright 2002 Free Software Foundation, Inc.
+   Contributed by Wasabi Systems, 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 NBSD_TDEP_H
+#define NBSD_TDEP_H
+
+struct link_map_offsets *nbsd_ilp32_solib_svr4_fetch_link_map_offsets (void);
+struct link_map_offsets *nbsd_lp64_solib_svr4_fetch_link_map_offsets (void);
+
+#endif /* NBSD_TDEP_H */
Index: shnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/shnbsd-tdep.c,v
retrieving revision 1.2
diff -u -r1.2 shnbsd-tdep.c
--- shnbsd-tdep.c	11 May 2002 19:30:27 -0000	1.2
+++ shnbsd-tdep.c	11 May 2002 22:04:40 -0000
@@ -23,8 +23,8 @@
 #include "gdbcore.h"
 #include "regcache.h"
 #include "value.h"
-#include "solib-svr4.h"
 
+#include "nbsd-tdep.h"
 #include "shnbsd-tdep.h"
 
 /* Convert an r0-r15 register number into an offset into a ptrace
@@ -107,47 +107,6 @@
     }
 }
 
-/* Fetch (and possibly build) an appropriate link_map_offsets
-   structure for NetBSD/sh targets using the struct offsets
-   defined in <link.h> (but without actual reference to that file).
-
-   This makes it possible to access NetBSD/sh shared libraries
-   from a GDB that was not built on a NetBSD/sh host (for cross
-   debugging).  */
-
-static struct link_map_offsets *
-shnbsd_solib_svr4_fetch_link_map_offsets (void)
-{
-  static struct link_map_offsets lmo;
-  static struct link_map_offsets *lmp = NULL;
-
-  if (lmp == NULL)
-    {
-      lmp = &lmo;
-
-      lmo.r_debug_size = 16;
-
-      lmo.r_map_offset = 4;
-      lmo.r_map_size   = 4;
-
-      lmo.link_map_size = 20;
-
-      lmo.l_addr_offset = 0;
-      lmo.l_addr_size   = 4;
-
-      lmo.l_name_offset = 4;
-      lmo.l_name_size   = 4;
-
-      lmo.l_next_offset = 12;
-      lmo.l_next_size   = 4;
-
-      lmo.l_prev_offset = 16;
-      lmo.l_prev_size   = 4;
-    }
-
-  return lmp;
-}
-
 static void
 fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
                       int which, CORE_ADDR ignore)
@@ -208,7 +167,7 @@
                   struct gdbarch *gdbarch)
 {
   set_solib_svr4_fetch_link_map_offsets (gdbarch,
-		                   shnbsd_solib_svr4_fetch_link_map_offsets);
+		                nbsd_ilp32_solib_svr4_fetch_link_map_offsets);
 }
 
 void
Index: config/alpha/nbsd.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/alpha/nbsd.mt,v
retrieving revision 1.3
diff -u -r1.3 nbsd.mt
--- config/alpha/nbsd.mt	11 May 2002 21:46:16 -0000	1.3
+++ config/alpha/nbsd.mt	11 May 2002 22:04:41 -0000
@@ -1,4 +1,4 @@
 # Target: Alpha running NetBSD
 TDEPFILES= alpha-tdep.o alphabsd-tdep.o alphanbsd-tdep.o corelow.o \
-	solib.o solib-svr4.o
+	nbsd-tdep.o solib.o solib-svr4.o
 TM_FILE= tm-nbsd.h
Index: config/sh/nbsd.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/sh/nbsd.mt,v
retrieving revision 1.2
diff -u -r1.2 nbsd.mt
--- config/sh/nbsd.mt	8 May 2002 16:18:41 -0000	1.2
+++ config/sh/nbsd.mt	11 May 2002 22:04:41 -0000
@@ -1,5 +1,5 @@
 # Target: SuperH running NetBSD
-TDEPFILES= sh-tdep.o shnbsd-tdep.o corelow.o solib.o solib-svr4.o
+TDEPFILES= sh-tdep.o shnbsd-tdep.o corelow.o nbsd-tdep.o solib.o solib-svr4.o
 TM_FILE= tm-nbsd.h
 
 SIM_OBS = remote-sim.o


More information about the Gdb-patches mailing list