This is the mail archive of the gdb@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: --enable-targets=<list>


Hello,

I'm getting ready to commit a patch (raw draft attached) that makes it 
possible to build a GDB that contains several orthogonal target 
architectures.  Not sure what happens when you use it yet :-)

Anyway, I'm trying to take a softly softly approach.  The attatched 
configury tweek tries to do the right thing (multi-arch when possible) 
and warn the user when something isn't possible.  The alternative would 
be to simply fail.  Thoughts?

Until someone comes up with something better, GDB will link in just the 
primary target's simulator.

As a preliminary change, I intend updating all the pure- multi-arch 
targets so that they set gdb_tdepfiles in configure.tgt instead of 
TDEPFILES=... in *.mt.  The patch currently interprets that to mean a 
multi-arch target, perhaphs I shouldn't do that?

	Andrew
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.97
diff -p -r1.97 Makefile.in
*** Makefile.in	2001/07/14 09:50:25	1.97
--- Makefile.in	2001/07/15 20:47:46
*************** CONFIG_CLEAN= @CONFIG_CLEAN@
*** 294,299 ****
--- 294,301 ----
  CONFIG_CLEAN= @CONFIG_CLEAN@
  CONFIG_INSTALL = @CONFIG_INSTALL@
  CONFIG_UNINSTALL = @CONFIG_UNINSTALL@
+ CONFIG_TDEPFILES= @CONFIG_TDEPFILES@
+ CONFIG_TARGETS= @CONFIG_TARGETS@
  
  # -I. for config files.
  # -I$(srcdir) for gdb internal headers and possibly for gnu-regex.h also.
*************** POSSLIBS = gnu-regex.c gnu-regex.h
*** 663,669 ****
  # Makefile.in
  
  DEPFILES = $(TDEPFILES) $(XDEPFILES) $(SER_HARDWIRE) $(NATDEPFILES) \
! 	   $(REMOTE_OBS) $(SIM_OBS) $(CONFIG_LIB_OBS)
  
  SOURCES = $(SFILES) $(ALLDEPFILES) $(YYFILES) $(CONFIG_SRCS)
  # Don't include YYFILES (*.tab.c) because we already include *.y in SFILES,
--- 665,671 ----
  # Makefile.in
  
  DEPFILES = $(TDEPFILES) $(XDEPFILES) $(SER_HARDWIRE) $(NATDEPFILES) \
! 	   $(REMOTE_OBS) $(SIM_OBS) $(CONFIG_LIB_OBS) $(CONFIG_TDEPFILES)
  
  SOURCES = $(SFILES) $(ALLDEPFILES) $(YYFILES) $(CONFIG_SRCS)
  # Don't include YYFILES (*.tab.c) because we already include *.y in SFILES,
*************** version.c: Makefile version.in
*** 1018,1024 ****
  	echo '#include "version.h"' >> version.c-tmp
  	echo 'const char version[] = "'"`head -1 ${srcdir}/version.in`"'";' >> version.c-tmp
  	echo 'const char host_name[] = "$(host_alias)";' >> version.c-tmp
! 	echo 'const char target_name[] = "$(target_alias)";' >> version.c-tmp
  	mv version.c-tmp version.c
  version.o: version.c $(version_h)
  
--- 1020,1032 ----
  	echo '#include "version.h"' >> version.c-tmp
  	echo 'const char version[] = "'"`head -1 ${srcdir}/version.in`"'";' >> version.c-tmp
  	echo 'const char host_name[] = "$(host_alias)";' >> version.c-tmp
! 	echo 'const char *target_names[] =' >> version.c-tmp
! 	echo '{' >> version.c-tmp
! 	for targ in $(CONFIG_TARGETS); do \
! 		echo '  "'"$$targ"'",' >> version.c-tmp ; \
! 	done
! 	echo '  0' >> version.c-tmp
! 	echo '};' >> version.c-tmp
  	mv version.c-tmp version.c
  version.o: version.c $(version_h)
  
Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.33
diff -p -r1.33 arch-utils.c
*** arch-utils.c	2001/06/16 20:00:24	1.33
--- arch-utils.c	2001/07/15 20:47:49
*************** initialize_current_architecture (void)
*** 708,716 ****
      {
        /* look for ``*el-*'' in the target name. */
        const char *chp;
!       chp = strchr (target_name, '-');
        if (chp != NULL
! 	  && chp - 2 >= target_name
  	  && strncmp (chp - 2, "el", 2) == 0)
  	info.byte_order = LITTLE_ENDIAN;
      }
--- 708,716 ----
      {
        /* look for ``*el-*'' in the target name. */
        const char *chp;
!       chp = strchr (target_names[0], '-');
        if (chp != NULL
! 	  && chp - 2 >= target_names[0]
  	  && strncmp (chp - 2, "el", 2) == 0)
  	info.byte_order = LITTLE_ENDIAN;
      }
Index: configure.in
===================================================================
RCS file: /cvs/src/src/gdb/configure.in,v
retrieving revision 1.66
diff -p -r1.66 configure.in
*** configure.in	2001/07/12 13:48:45	1.66
--- configure.in	2001/07/15 20:48:09
*************** changequote(,)dnl
*** 73,80 ****
  
  . ${srcdir}/configure.tgt
  
- targ=${target} ; . ${srcdir}/../bfd/config.bfd
- 
  dnl
  changequote([,])dnl
  
--- 73,78 ----
*************** if test x"${targ_defvec}" != x ; then
*** 93,98 ****
--- 91,166 ----
      AC_DEFINE_UNQUOTED(DEFAULT_BFD_VEC, ${targ_defvec})
  fi
  
+ 
+ # See what extra targets the user wants.  Unlike BFD, ignore ``all''.
+ AC_ARG_ENABLE(targets,
+ [  --enable-targets        alternative target configurations],
+ [case "${enableval}" in
+   all | yes | "")
+ 	    AC_MSG_WARN(enable-targets option must specify target names, ignored)
+ 	    enable_targets=
+             ;;
+   no)       enable_targets= ;;
+   *)        enable_targets=$enableval ;;
+ esac])dnl
+ 
+ # When the primary target is multi-arch, go through all the secondary
+ # targets and weed out both duplicates and pure- multi-arch targets.
+ # Accumulate TDEP files as we go.
+ 
+ CONFIG_TARGETS="$target_alias"
+ CONFIG_TDEPFILES="$gdb_tdepfiles"
+ canon_targets="$target"
+ AC_MSG_CHECKING(for multi-arch)
+ if test -n "$gdb_tdepfiles" ; then
+     gdb_multi_arch=yes
+     for targ in x `echo $enable_targets | sed 's/,/ /g'`
+     do
+ 	test "$targ" = x && continue
+ 	# strip out unknown targets
+ 	canon=`$ac_config_sub $targ 2>/dev/null`
+ 	if test ! -n "$canon" ; then
+ 	    AC_MSG_WARN(ignoring unknown target $targ)
+ 	    continue
+ 	fi
+ 	# Strip out duplicate targets.
+ 	case " $canon_targets " in
+ 	    *" $canon "*)
+ 		AC_MSG_WARN(ignoring duplicate target $targ)
+ 		continue ;;
+ 	esac
+ 	# Strip out non- multi-arch targets.
+ 	tdepfiles=`target=$canon ; . ${srcdir}/configure.tgt ; echo $gdb_tdepfiles`
+ 	if test ! -n "$tdepfiles" ; then
+ 	    AC_MSG_WARN(ignoring non- multi-arch target $targ)
+ 	    continue
+ 	fi
+ 	canon_targets="$canon_targets $canon"
+ 	CONFIG_TARGETS="$CONFIG_TARGETS $targ"
+ 	CONFIG_TDEPFILES="$CONFIG_TDEPFILES $tdepfiles"
+     done
+     # Strip out duplicate TDEP files.
+     f=""
+     for i in $CONFIG_TDEPFILES
+     do
+ 	case " $f " in
+ 	    *" $i "*) ;;
+ 	    "  ") f="$i" ;;
+ 	    *) f="$f $i" ;;
+ 	esac
+     done
+     CONFIG_TDEPFILES="$f"
+     AC_MSG_RESULT(${CONFIG_TARGETS} - ${CONFIG_TDEPFILES})
+ elif test -n "$canon_targets" ; then
+     AC_MSG_WARN(ignoring --enable-targets)
+     AC_MSG_RESULT(no)
+ else
+     AC_MSG_RESULT(no)
+ fi
+ AC_SUBST(CONFIG_TARGETS)
+ AC_SUBST(CONFIG_TDEPFILES)
+ 
+ 
  AC_PROG_AWK
  AC_PROG_INSTALL
  AC_CHECK_TOOL(AR, ar)
*************** targetfile=`sed -n '
*** 1176,1185 ****
  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
--- 1244,1249 ----
*************** fi
*** 1194,1216 ****
  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 practice
  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
--- 1258,1274 ----
  changequote([,])
  
  # New targets should just set gdb_multi_arch=yes in configure.tgt.
! case "${gdb_multi_arch}" in
! yes ) GDB_MULTI_ARCH=GDB_MULTI_ARCH_PURE ;;
! no ) GDB_MULTI_ARCH=0 ;;
! esac
  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 practice
  case "${GDB_MULTI_ARCH}" in
      "" ) ;;
!     GDB_MULTI_ARCH_PARTIAL | GDB_MULTI_ARCH_TM )
  	AC_MSG_WARN("GDB: Target is not pure multi-arch") ;;
      GDB_MULTI_ARCH_PURE )
  	if test x"${targetfile}" != x ; then
Index: configure.tgt
===================================================================
RCS file: /cvs/src/src/gdb/configure.tgt,v
retrieving revision 1.32
diff -p -r1.32 configure.tgt
*** configure.tgt	2001/07/11 17:58:14	1.32
--- configure.tgt	2001/07/15 20:48:10
***************
*** 2,9 ****
  # invoked from the autoconf generated configure script.
  
  # This file sets the following shell variables:
! #  gdb_target_cpu	generic name of CPU
! #  gdb_target		name of GDB target definition to use
  
  # This file may also modify configdirs.
  
--- 2,10 ----
  # invoked from the autoconf generated configure script.
  
  # This file sets the following shell variables:
! gdb_target_cpu=""	# Generic name of CPU.
! gdb_target=""		# Name of GDB target (.mt) definition to use.
! gdb_tdepfiles=""	# List of TDEP .o files to include with this target.
  
  # This file may also modify configdirs.
  
*************** xscale-*-*)		gdb_target=embed
*** 63,69 ****
                          configdirs="$configdirs rdi-share"
                          ;;
  
! d10v-*-*)		gdb_target=d10v ;;
  d30v-*-*)		gdb_target=d30v ;;
  
  h8300-*-*)		gdb_target=h8300 ;;
--- 64,72 ----
                          configdirs="$configdirs rdi-share"
                          ;;
  
! d10v-*-*)		gdb_target=d10v
! 			gdb_tdepfiles="d10v-tdep.o" ;;
! 
  d30v-*-*)		gdb_target=d30v ;;
  
  h8300-*-*)		gdb_target=h8300 ;;
*************** ia64-*-linux*)		gdb_target=linux ;;
*** 138,144 ****
  
  m32r-*-elf*)		gdb_target=m32r ;;
  
! m68hc11*-*-*|m6811*-*-*)	gdb_target=m68hc11 ;;
  
  m68000-*-sunos3*)	gdb_target=sun2os3 ;;
  m68000-*-sunos4*)	gdb_target=sun2os4 ;;
--- 141,149 ----
  
  m32r-*-elf*)		gdb_target=m32r ;;
  
! m68hc11*-*-*|m6811*-*-*)
! 			gdb_target=m68hc11
! 			gdb_tdepfiles="m68hc11-tdep.o" ;;
  
  m68000-*-sunos3*)	gdb_target=sun2os3 ;;
  m68000-*-sunos4*)	gdb_target=sun2os4 ;;
*************** v850*-*-*)		gdb_target=v850
*** 312,323 ****
  
  z8k-*-coff*)		gdb_target=z8k ;;
  
- esac
- 
- 
- # map GDB target onto multi-arch support
- 
- case "${gdb_target}" in
- d10v)		gdb_multi_arch=yes ;;
- m68hc11)	gdb_multi_arch=yes ;;
  esac
--- 317,320 ----
Index: top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.35
diff -p -r1.35 top.c
*** top.c	2001/05/17 15:05:32	1.35
--- top.c	2001/07/15 20:48:40
*************** There is absolutely no warranty for GDB.
*** 1398,1406 ****
    /* After the required info we print the configuration information. */
  
    fprintf_filtered (stream, "This GDB was configured as \"");
!   if (!STREQ (host_name, target_name))
      {
!       fprintf_filtered (stream, "--host=%s --target=%s", host_name, target_name);
      }
    else
      {
--- 1398,1411 ----
    /* After the required info we print the configuration information. */
  
    fprintf_filtered (stream, "This GDB was configured as \"");
!   if (strcmp (host_name, target_names[0]) != 0)
      {
!       int i;
!       fprintf_filtered (stream, "--host=%s --target=%s", host_name, target_names[0]);
!       for (i = 1; target_names[i] != NULL; i++)
! 	{
! 	  fprintf_filtered (stream, ",%s", target_names[i]);
! 	}
      }
    else
      {
Index: version.h
===================================================================
RCS file: /cvs/src/src/gdb/version.h,v
retrieving revision 1.2
diff -p -r1.2 version.h
*** version.h	2001/03/06 08:21:18	1.2
--- version.h	2001/07/15 20:48:42
*************** extern const char version[];
*** 27,33 ****
  /* Canonical host name as a string. */
  extern const char host_name[];
  
! /* Canonical target name as a string. */
! extern const char target_name[];
  
  #endif /* #ifndef VERSION_H */
--- 27,33 ----
  /* Canonical host name as a string. */
  extern const char host_name[];
  
! /* Canonical target names as strings. */
! extern const char *target_names[];
  
  #endif /* #ifndef VERSION_H */
Index: config/d10v/d10v.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/d10v/d10v.mt,v
retrieving revision 1.2
diff -p -r1.2 d10v.mt
*** d10v.mt	2001/07/11 17:58:15	1.2
--- d10v.mt	2001/07/15 20:48:42
***************
*** 1,4 ****
  # Target: Mitsubishi D10V processor
- TDEPFILES= d10v-tdep.o
  SIM_OBS= remote-sim.o
  SIM= ../sim/d10v/libsim.a
--- 1,3 ----
Index: config/m68hc11/m68hc11.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/m68hc11/m68hc11.mt,v
retrieving revision 1.1
diff -p -r1.1 m68hc11.mt
*** m68hc11.mt	2000/07/27 07:18:32	1.1
--- m68hc11.mt	2001/07/15 20:48:44
***************
*** 1,6 ****
  # Target: Motorola 68HC11 processor
- TDEPFILES= m68hc11-tdep.o
- TM_FILE= tm-m68hc11.h
  SIM_OBS= remote-sim.o
  SIM= ../sim/m68hc11/libsim.a -lm
- 
--- 1,3 ----

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