This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[rfc] Move #define GDB_MULTI_ARCH into configure*


Hello,

The attached patch is a first cut at moving the definition of
GDB_MULTI_ARCH out of tm.h and into config.h.  Remember, in a GDB that
supports more than one architecture, tm.h isn't really applicable. 
Consider, for instance, a GDB that supports SPARC and D10V.  Under the
current scheme, tm.h would need to point at both config/sparc/tm-sparc.h
and config/d10v/tm-d10v.h :-/.

This patch also adds ``GDB_MULTI_ARCH_PURE'' and when defined "tm.h" is
not even included.  No existing targets manage to do this although the
d10v comes >this< close.

With the patch applied, a multi-arch target can either:

	tweak configure.tgt to set gdb_multi_arch

		This is preferred.

	tweak config/${target}/*.mt to set GDB_MULTI_ARCH

		This is a cop-out so that partially
		converted targets can override configure.tgt

I've included patches to update SH, MIPS, D10V and SPARC.  I may tweak
it a bit more so that it is more backward compatible (Allow
*/*/tm-*.h:#define GDB_MULTI_ARCH ...).

Comments?

	Andrew
Wed Jul 26 17:22:53 2000  Andrew Cagney  <cagney@b1.cygnus.com>

	* config/sparc/sun4sol2.mt, config/sparc/sp64.mt: Set
 	GDB_MULTI_ARCH to 2.

	* configure.in (GDB_MULTI_ARCH): Define from configure.tgt
 	or makefile fragment.
	* acconfig.h (GDB_MULTI_ARCH): Add.
	* config.in, configure: Regenerate.
	
	* gdbarch.sh (GDB_MULTI_ARCH): Delete definition, moved to
 	configure.in and defs.h.  Use GDB_MULTI_ARCH_TM,
 	GDB_MULTI_ARCH_PARTIAL and GDB_MULTI_ARCH_PURE in tests.
	* gdbarch.h, gdbarch.c: Regenerate.

	* defs.h (GDB_MULTI_ARCH_PARTIAL, GDB_MULTI_ARCH_TM, ,
 	GDB_MULTI_ARCH_PURE): Define.  Only include "tm.h" when the target
 	is less than pure multi-arch.
	(GDB_MULTI_ARCH): Default to zero.

	* configure.tgt (d10v-*-*, mips*-*-*, sh*-*-*): Set
 	gdb_multi_arch=1.

Index: acconfig.h
===================================================================
RCS file: /cvs/src/src/gdb/acconfig.h,v
retrieving revision 1.9
diff -p -r1.9 acconfig.h
*** acconfig.h	2000/06/08 04:00:56	1.9
--- acconfig.h	2000/07/26 10:19:21
***************
*** 121,123 ****
--- 121,127 ----
  
  /* BFD's default target vector. */
  #undef DEFAULT_BFD_VEC
+ 
+ /* Multi-arch enabled. */
+ #undef GDB_MULTI_ARCH
+ 
Index: configure.in
===================================================================
RCS file: /cvs/src/src/gdb/configure.in,v
retrieving revision 1.39
diff -p -r1.39 configure.in
*** configure.in	2000/07/05 10:55:17	1.39
--- configure.in	2000/07/26 10:19:38
*************** targetfile=`sed -n '
*** 1003,1008 ****
--- 1003,1012 ----
  s/TM_FILE[ 	]*=[ 	]*\([^ 	]*\)/\1/p
  ' ${target_makefile_frag}`
  
+ GDB_MULTI_ARCH=`sed -n '
+ s/GDB_MULTI_ARCH[ 	]*=[ 	]*\([^ 	]*\)[ 	]*/\1/p
+ ' ${target_makefile_frag}`
+ 
  # these really aren't orthogonal true/false values of the same condition,
  # but shells are slow enough that I like to reuse the test conditions
  # whenever possible
*************** s/NAT_FILE[ 	]*=[ 	]*\([^ 	]*\)/\1/p
*** 1015,1020 ****
--- 1019,1051 ----
  # configdirs=`echo $configdirs | sed 's/gdbserver//'`
  fi
  changequote([,])
+ 
+ # New targets should just set gdb_multi_arch=yes in configure.tgt.
+ # Old targets being converted can either do that or set GDB_MULTI_ARCH
+ # in the target specific makefile frag.  Eventually gdb_multi_arch=yes
+ # will be the default.
+ if test x"${GDB_MULTI_ARCH}" = x ; then
+     case "${gdb_multi_arch}" in
+     yes ) GDB_MULTI_ARCH=GDB_MULTI_ARCH_PURE ;;
+     no ) GDB_MULTI_ARCH=0 ;;
+     0|1|2 ) GDB_MULTI_ARCH=${gdb_multi_arch} ;;
+     esac
+ fi
+ if test x"${GDB_MULTI_ARCH}" != x ; then
+     AC_DEFINE_UNQUOTED(GDB_MULTI_ARCH, ${GDB_MULTI_ARCH})
+ fi
+ # Warn the user when they use an old pratice
+ case "${GDB_MULTI_ARCH}" in
+     "" ) ;;
+     0 | GDB_MULTI_ARCH_PARTIAL | 1 | GDB_MULTI_ARCH_TM | 2 )
+ 	AC_MSG_WARN("GDB: Target is not pure multi-arch") ;;
+     GDB_MULTI_ARCH_PURE )
+ 	if test x"${targetfile}" != x ; then
+ 	    AC_MSG_WARN("GDB: Ingoring TM_FILE in ${target_makefile_frag}")
+ 	fi ;;
+     *)  AC_MSG_ERROR("GDB: Unknown GDB_MULTI_ARCH value ${GDB_MULTI_ARCH}");;
+ esac
+ 
  
  SUBDIRS="doc testsuite nlm"
  if test "${enable_multi_ice}" = "yes"; then
Index: configure.tgt
===================================================================
RCS file: /cvs/src/src/gdb/configure.tgt,v
retrieving revision 1.12
diff -p -r1.12 configure.tgt
*** configure.tgt	2000/06/13 15:21:27	1.12
--- configure.tgt	2000/07/26 10:19:38
*************** arm*-*-* | thumb*-*-* | strongarm*-*-*)
*** 62,67 ****
--- 62,68 ----
  # OBSOLETE c2-*-*)		gdb_target=convex ;;
  
  d10v-*-*)		gdb_target=d10v ;;
+ 
  d30v-*-*)		gdb_target=d30v ;;
  
  h8300-*-*)		gdb_target=h8300 ;;
*************** z8k-*-coff*)		gdb_target=z8k ;;
*** 299,301 ****
--- 300,308 ----
  
  esac
  
+ # gdb_multi_arch=yes
+ case ${target} in
+ d10v*-*-* )		gdb_multi_arch=1 ;;
+ mips*-*-* )		gdb_multi_arch=1 ;;
+ sh*-*-* )		gdb_multi_arch=1 ;;
+ esac
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.27
diff -p -r1.27 defs.h
*** defs.h	2000/07/10 06:16:51	1.27
--- defs.h	2000/07/26 10:19:43
***************
*** 65,70 ****
--- 65,95 ----
  /* For BFD64 and bfd_vma.  */
  #include "bfd.h"
  
+ 
+ /* The target is partially multi-arched.  Both "tm.h" and the
+    multi-arch vector provide definitions.  "tm.h" normally overrides
+    the multi-arch vector (but there are a few exceptions).  */
+ 
+ #define GDB_MULTI_ARCH_PARTIAL 1
+ 
+ /* The target is multi-arched.  The MULTI-ARCH vector provides all
+    definitions.  "tm.h" is included and may provide definitions of
+    non- multi-arch macros..  */
+ 
+ #define GDB_MULTI_ARCH_TM 2
+ 
+ /* The target is pure multi-arch.  The MULTI-ARCH vector provides all
+    definitions.  "tm.h" is NOT included. */
+ 
+ #define GDB_MULTI_ARCH_PURE 3
+ 
+ /* GDB_MULTI_ARCH is normally set by configure.in. */
+ 
+ #ifndef GDB_MULTI_ARCH
+ #define GDB_MULTI_ARCH 0
+ #endif
+ 
+ 
  /* An address in the program being debugged.  Host byte order.  Rather
     than duplicate all the logic in BFD which figures out what type
     this is (long, long long, etc.) and whether it needs to be 64
*************** enum val_prettyprint
*** 703,709 ****
--- 728,736 ----
  /* Target machine definition.  This will be a symlink to one of the
     tm-*.h files, built by the `configure' script.  */
  
+ #if (GDB_MULTI_ARCH < GDB_MULTI_ARCH_PURE)
  #include "tm.h"
+ #endif
  
  /* If the xm.h file did not define the mode string used to open the
     files, assume that binary files are opened the same way as text
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.31
diff -p -r1.31 gdbarch.sh
*** gdbarch.sh	2000/07/24 14:29:23	1.31
--- gdbarch.sh	2000/07/26 10:19:54
*************** struct frame_info;
*** 498,514 ****
  struct value;
  
  
- #ifndef GDB_MULTI_ARCH
- #define GDB_MULTI_ARCH 0
- #endif
- 
  extern struct gdbarch *current_gdbarch;
  
  
- /* See gdb/doc/gdbint.texi for a discussion of the GDB_MULTI_ARCH
-    macro */
- 
- 
  /* If any of the following are defined, the target wasn't correctly
     converted. */
  
--- 498,506 ----
*************** do
*** 537,543 ****
  	echo "extern ${returntype} gdbarch_${function} (struct gdbarch *gdbarch);"
  	echo "/* set_gdbarch_${function}() - not applicable - pre-initialized. */"
  	echo "#if GDB_MULTI_ARCH"
! 	echo "#if (GDB_MULTI_ARCH > 1) || !defined (${macro})"
  	echo "#define ${macro} (gdbarch_${function} (current_gdbarch))"
  	echo "#endif"
  	echo "#endif"
--- 529,535 ----
  	echo "extern ${returntype} gdbarch_${function} (struct gdbarch *gdbarch);"
  	echo "/* set_gdbarch_${function}() - not applicable - pre-initialized. */"
  	echo "#if GDB_MULTI_ARCH"
! 	echo "#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (${macro})"
  	echo "#define ${macro} (gdbarch_${function} (current_gdbarch))"
  	echo "#endif"
  	echo "#endif"
*************** do
*** 555,571 ****
  	echo ""
  	echo "#if defined (${macro})"
  	echo "/* Legacy for systems yet to multi-arch ${macro} */"
! #	echo "#if (GDB_MULTI_ARCH <= 2) && defined (${macro})"
  	echo "#define ${macro}_P() (1)"
  	echo "#endif"
  	echo ""
  	echo "/* Default predicate for non- multi-arch targets. */"
! 	echo "#if (GDB_MULTI_ARCH == 0) && !defined (${macro}_P)"
  	echo "#define ${macro}_P() (0)"
  	echo "#endif"
  	echo ""
  	echo "extern int gdbarch_${function}_p (struct gdbarch *gdbarch);"
! 	echo "#if (GDB_MULTI_ARCH > 1) || !defined (${macro}_P)"
  	echo "#define ${macro}_P() (gdbarch_${function}_p (current_gdbarch))"
  	echo "#endif"
      fi
--- 547,563 ----
  	echo ""
  	echo "#if defined (${macro})"
  	echo "/* Legacy for systems yet to multi-arch ${macro} */"
! #	echo "#if (GDB_MULTI_ARCH <= GDB_MULTI_ARCH_PARTIAL) && defined (${macro})"
  	echo "#define ${macro}_P() (1)"
  	echo "#endif"
  	echo ""
  	echo "/* Default predicate for non- multi-arch targets. */"
! 	echo "#if (!GDB_MULTI_ARCH) && !defined (${macro}_P)"
  	echo "#define ${macro}_P() (0)"
  	echo "#endif"
  	echo ""
  	echo "extern int gdbarch_${function}_p (struct gdbarch *gdbarch);"
! 	echo "#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (${macro}_P)"
  	echo "#define ${macro}_P() (gdbarch_${function}_p (current_gdbarch))"
  	echo "#endif"
      fi
*************** do
*** 575,581 ****
  	then
  	    echo ""
  	    echo "/* Default (value) for non- multi-arch platforms. */"
! 	    echo "#if (GDB_MULTI_ARCH == 0) && !defined (${macro})"
  	    echo "#define ${macro} (${fallbackdefault})" \
  		| sed -e 's/\([^a-z_]\)\(gdbarch[^a-z_]\)/\1current_\2/g'
  	    echo "#endif"
--- 567,573 ----
  	then
  	    echo ""
  	    echo "/* Default (value) for non- multi-arch platforms. */"
! 	    echo "#if (!GDB_MULTI_ARCH) && !defined (${macro})"
  	    echo "#define ${macro} (${fallbackdefault})" \
  		| sed -e 's/\([^a-z_]\)\(gdbarch[^a-z_]\)/\1current_\2/g'
  	    echo "#endif"
*************** do
*** 584,590 ****
  	echo "extern ${returntype} gdbarch_${function} (struct gdbarch *gdbarch);"
  	echo "extern void set_gdbarch_${function} (struct gdbarch *gdbarch, ${returntype} ${function});"
  	echo "#if GDB_MULTI_ARCH"
! 	echo "#if (GDB_MULTI_ARCH > 1) || !defined (${macro})"
  	echo "#define ${macro} (gdbarch_${function} (current_gdbarch))"
  	echo "#endif"
  	echo "#endif"
--- 576,582 ----
  	echo "extern ${returntype} gdbarch_${function} (struct gdbarch *gdbarch);"
  	echo "extern void set_gdbarch_${function} (struct gdbarch *gdbarch, ${returntype} ${function});"
  	echo "#if GDB_MULTI_ARCH"
! 	echo "#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (${macro})"
  	echo "#define ${macro} (gdbarch_${function} (current_gdbarch))"
  	echo "#endif"
  	echo "#endif"
*************** do
*** 595,601 ****
  	then
  	    echo ""
  	    echo "/* Default (function) for non- multi-arch platforms. */"
! 	    echo "#if (GDB_MULTI_ARCH == 0) && !defined (${macro})"
  	    if [ "${fallbackdefault}" = "0" ]
  	    then
  		echo "#define ${macro}(${actual}) (internal_error (\"${macro}\"), 0)"
--- 587,593 ----
  	then
  	    echo ""
  	    echo "/* Default (function) for non- multi-arch platforms. */"
! 	    echo "#if (!GDB_MULTI_ARCH) && !defined (${macro})"
  	    if [ "${fallbackdefault}" = "0" ]
  	    then
  		echo "#define ${macro}(${actual}) (internal_error (\"${macro}\"), 0)"
*************** do
*** 616,622 ****
  	fi
  	echo "extern void set_gdbarch_${function} (struct gdbarch *gdbarch, gdbarch_${function}_ftype *${function});"
  	echo "#if GDB_MULTI_ARCH"
! 	echo "#if (GDB_MULTI_ARCH > 1) || !defined (${macro})"
  	if [ "${actual}" = "" ]
  	then
  	  echo "#define ${macro}() (gdbarch_${function} (current_gdbarch))"
--- 608,614 ----
  	fi
  	echo "extern void set_gdbarch_${function} (struct gdbarch *gdbarch, gdbarch_${function}_ftype *${function});"
  	echo "#if GDB_MULTI_ARCH"
! 	echo "#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (${macro})"
  	if [ "${actual}" = "" ]
  	then
  	  echo "#define ${macro}() (gdbarch_${function} (current_gdbarch))"
*************** static void
*** 1171,1177 ****
  verify_gdbarch (struct gdbarch *gdbarch)
  {
    /* Only perform sanity checks on a multi-arch target. */
!   if (GDB_MULTI_ARCH <= 0)
      return;
    /* fundamental */
    if (gdbarch->byte_order == 0)
--- 1163,1169 ----
  verify_gdbarch (struct gdbarch *gdbarch)
  {
    /* Only perform sanity checks on a multi-arch target. */
!   if (!GDB_MULTI_ARCH)
      return;
    /* fundamental */
    if (gdbarch->byte_order == 0)
Index: config/sparc/sp64.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/sparc/sp64.mt,v
retrieving revision 1.1.1.1
diff -p -r1.1.1.1 sp64.mt
*** sp64.mt	1999/04/16 01:34:25	1.1.1.1
--- sp64.mt	2000/07/26 10:19:56
*************** TM_FILE= tm-sp64.h
*** 7,9 ****
--- 7,11 ----
  
  # Need gcc for long long support.
  CC = gcc
+ 
+ GDB_MULTI_ARCH=2
Index: config/sparc/sun4sol2.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/sparc/sun4sol2.mt,v
retrieving revision 1.1.1.1
diff -p -r1.1.1.1 sun4sol2.mt
*** sun4sol2.mt	1999/04/16 01:34:26	1.1.1.1
--- sun4sol2.mt	2000/07/26 10:19:56
***************
*** 1,3 ****
--- 1,6 ----
  # Target: Sun 4 or Sparcstation, running Solaris 2
  TDEPFILES= sparc-tdep.o
  TM_FILE= tm-sun4sol2.h
+ GDB_MULTI_ARCH=2
+ 
+ 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]