This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

Simulators --with-pkgversion --with-bugurl support


This patch adds --with-pkgversion and --with-bugurl support to the
simulators.  Tested for arm-none-eabi and powerpc-none-eabi.  OK to
commit?

sim/common:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* aclocal.m4: Include ../../config/acx.m4.
	* common.m4: Use ACX_PKGVERSION and ACX_BUGURL.
	* configure, config.in: Regenerate.
	* Make-common.in (LIB_OBJS): Add version.o.
	(version.c, version.o): New rules.
	* run.c: Include version.h. 
	(usage): Add help parameter. Print output either to stdout or
	stderr depending on that parameter.
	(print_version): New.
	(main): Check for --help and --version.
	* run-sim.h (sim_target_display_usage): Add help parameter.
	* version.h: New.

sim/arm:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.
	* wrapper.c (sim_target_display_usage): Add help parameter.

sim/cr16:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/cris:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/d10v:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/erc32:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/frv:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/h8300:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/iq2000:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/m32c:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/m32r:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/m68hc11:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/mcore:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/mips:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/mn10300:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/ppc:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure.ac: Use ACX_PKGVERSION and ACX_BUGURL.
	* configure, config.in: Regenerated.
	* Makefile.in (LIB_OBJ): Add version.o.
	(version.c, version.o): New rules.
	* psim.c (psim_usage): Add help parameter.  Print the bug URL.
	Exit with code 0 for help.
	(psim_options): Update calls to psim_usage.  Handle --help and
	--version.
	* psim.h (psim_usage): Update prototype.
	* main.c (main): Update psim_usage call.

sim/sh:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/sh64:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

sim/v850:
2008-06-06  Vladimir Prus  <vladimir@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* configure: Regenerate.

Index: arm/wrapper.c
===================================================================
RCS file: /cvs/src/src/sim/arm/wrapper.c,v
retrieving revision 1.35
diff -u -p -r1.35 wrapper.c
--- arm/wrapper.c	1 Jan 2008 22:53:23 -0000	1.35
+++ arm/wrapper.c	6 Jun 2008 20:24:34 -0000
@@ -772,9 +772,12 @@ sim_target_parse_arg_array (argv)
 }
 
 void
-sim_target_display_usage ()
+sim_target_display_usage (help)
+     int help;
 {
-  fprintf (stderr, "%s=<list>  Comma seperated list of SWI protocols to supoport.\n\
+  FILE *stream = help ? stdout : stderr;
+
+  fprintf (stream, "%s=<list>  Comma seperated list of SWI protocols to supoport.\n\
                 This list can contain: NONE, DEMON, ANGEL, REDBOOT and/or ALL.\n",
 	   SWI_SWITCH);
 }
Index: common/Make-common.in
===================================================================
RCS file: /cvs/src/src/sim/common/Make-common.in,v
retrieving revision 1.28
diff -u -p -r1.28 Make-common.in
--- common/Make-common.in	1 Jan 2008 22:53:23 -0000	1.28
+++ common/Make-common.in	6 Jun 2008 20:24:34 -0000
@@ -245,7 +245,7 @@ LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LI
 EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL) $(LIBIBERTY_LIB) \
 	$(CONFIG_LIBS) $(SIM_EXTRA_LIBS)
 
-LIB_OBJS = callback.o syscall.o targ-map.o $(SIM_OBJS)
+LIB_OBJS = callback.o syscall.o targ-map.o version.o $(SIM_OBJS)
 
 RUNTESTFLAGS =
 
@@ -291,6 +291,14 @@ stamp-tvals: gentmap
 	$(SHELL) $(srcroot)/move-if-change tmp-tmap.c targ-map.c
 	touch stamp-tvals
 
+version.c: Makefile ../../gdb/version.in
+	rm -f version.c-tmp version.c
+	echo '#include "version.h"' >> version.c-tmp
+	echo 'const char version[] = "'"`sed q ${srcdir}/../../gdb/version.in`"'";' >> version.c-tmp
+	mv version.c-tmp version.c
+version.o: version.c $(version_h)
+
+
 #
 # Rules for building sim-* components.  Triggered by listing the corresponding
 # .o file in the list of simulator targets.
Index: common/aclocal.m4
===================================================================
RCS file: /cvs/src/src/sim/common/aclocal.m4,v
retrieving revision 1.14
diff -u -p -r1.14 aclocal.m4
--- common/aclocal.m4	13 Jun 2006 08:06:48 -0000	1.14
+++ common/aclocal.m4	6 Jun 2008 20:24:34 -0000
@@ -893,6 +893,7 @@ AC_OUTPUT
 ])
 
 sinclude(../../config/gettext-sister.m4)
+sinclude(../../config/acx.m4)
 
 dnl --enable-cgen-maint support
 AC_DEFUN(SIM_AC_OPTION_CGEN_MAINT,
Index: common/common.m4
===================================================================
RCS file: /cvs/src/src/sim/common/common.m4,v
retrieving revision 1.4
diff -u -p -r1.4 common.m4
--- common/common.m4	13 Jun 2006 08:06:48 -0000	1.4
+++ common/common.m4	6 Jun 2008 20:24:34 -0000
@@ -195,6 +195,10 @@ if test x"$silent" != x"yes" && test x"$
 fi],[sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1"])dnl
 AC_SUBST(sim_profile)
 
+ACX_PKGVERSION([GDB])
+ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
+AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
+AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
 
 dnl Types used by common code
 AC_TYPE_SIGNAL
Index: common/run-sim.h
===================================================================
RCS file: /cvs/src/src/sim/common/run-sim.h,v
retrieving revision 1.5
diff -u -p -r1.5 run-sim.h
--- common/run-sim.h	1 Jan 2008 22:53:23 -0000	1.5
+++ common/run-sim.h	6 Jun 2008 20:24:35 -0000
@@ -30,7 +30,7 @@ int sim_target_parse_command_line PARAMS
 
   /* Display a list of target specific switches supported by this
      target.  */
-void sim_target_display_usage PARAMS ((void));
+void sim_target_display_usage PARAMS ((int help));
 
 #endif
 
Index: common/run.c
===================================================================
RCS file: /cvs/src/src/sim/common/run.c,v
retrieving revision 1.19
diff -u -p -r1.19 run.c
--- common/run.c	1 Jan 2008 22:53:23 -0000	1.19
+++ common/run.c	6 Jun 2008 20:24:35 -0000
@@ -49,8 +49,10 @@ along with this program.  If not, see <h
 #include "gdb/remote-sim.h"
 #include "ansidecl.h"
 #include "run-sim.h"
+#include "version.h"
 
-static void usage PARAMS ((void));
+static void usage PARAMS ((int help));
+static void print_version PARAMS ((void));
 extern int optind;
 extern char *optarg;
 
@@ -118,6 +120,19 @@ main (ac, av)
   ac = sim_target_parse_command_line (ac, av);
 #endif
 
+  for (i = 1; av[i]; ++i)
+    {
+      if (strcmp (av[i], "--help") == 0)
+        {
+          usage (1);
+        }
+      else if (strcmp (av[i], "--version") == 0)
+        {
+          print_version ();
+          return 0;
+        }
+    }
+
   /* FIXME: This is currently being rewritten to have each simulator
      do all argv processing.  */
 
@@ -175,13 +190,13 @@ main (ac, av)
 	break;
 	/* FIXME: Quick hack, to be replaced by more general facility.  */
       default:
-	usage ();
+	usage (0);
       }
 
   ac -= optind;
   av += optind;
   if (ac <= 0)
-    usage ();
+    usage (0);
 
   name = *av;
   prog_args = av;
@@ -301,31 +316,43 @@ main (ac, av)
 }
 
 static void
-usage ()
+usage (int help)
 {
-  fprintf (stderr, "Usage: %s [options] program [program args]\n", myname);
-  fprintf (stderr, "Options:\n");
-  fprintf (stderr, "-a args         Pass `args' to simulator.\n");
+  FILE *stream = help ? stdout : stderr;
+
+  fprintf (stream, "Usage: %s [options] program [program args]\n", myname);
+  fprintf (stream, "Options:\n");
+  fprintf (stream, "-a args         Pass `args' to simulator.\n");
 #ifdef SIM_HAVE_SIMCACHE
-  fprintf (stderr, "-c size         Set simulator cache size to `size'.\n");
+  fprintf (stream, "-c size         Set simulator cache size to `size'.\n");
 #endif
-  fprintf (stderr, "-m size         Set memory size of simulator, in bytes.\n");
+  fprintf (stream, "-m size         Set memory size of simulator, in bytes.\n");
 #ifdef SIM_HAVE_ENVIRONMENT
-  fprintf (stderr, "-o              Select operating (kernel) environment.\n");
+  fprintf (stream, "-o              Select operating (kernel) environment.\n");
 #endif
 #ifdef SIM_HAVE_PROFILE
-  fprintf (stderr, "-p freq         Set profiling frequency.\n");
-  fprintf (stderr, "-s size         Set profiling size.\n");
+  fprintf (stream, "-p freq         Set profiling frequency.\n");
+  fprintf (stream, "-s size         Set profiling size.\n");
 #endif
-  fprintf (stderr, "-t              Perform instruction tracing.\n");
-  fprintf (stderr, "                Note: Very few simulators support tracing.\n");
-  fprintf (stderr, "-v              Verbose output.\n");
-  fprintf (stderr, "\n");
-  fprintf (stderr, "program args    Arguments to pass to simulated program.\n");
-  fprintf (stderr, "                Note: Very few simulators support this.\n");
+  fprintf (stream, "-t              Perform instruction tracing.\n");
+  fprintf (stream, "                Note: Very few simulators support tracing.\n");
+  fprintf (stream, "-v              Verbose output.\n");
+  fprintf (stream, "\n");
+  fprintf (stream, "program args    Arguments to pass to simulated program.\n");
+  fprintf (stream, "                Note: Very few simulators support this.\n");
 #ifdef SIM_TARGET_SWITCHES
-  fprintf (stderr, "\nTarget specific options:\n");
-  sim_target_display_usage ();
+  fprintf (stream, "\nTarget specific options:\n");
+  sim_target_display_usage (help);
 #endif
-  exit (1);
+
+  if (help && REPORT_BUGS_TO[0])
+    printf ("Report bugs to %s\n", REPORT_BUGS_TO);
+
+  exit (help ? 0 : 1);
+}
+
+static void 
+print_version ()
+{
+  printf ("GNU simulator %s%s\n", PKGVERSION, version);
 }
Index: common/version.h
===================================================================
RCS file: common/version.h
diff -N common/version.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ common/version.h	6 Jun 2008 20:24:35 -0000
@@ -0,0 +1,25 @@
+/* Version information for GDB.
+   Copyright (C) 1999, 2007, 2008 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 3 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, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef VERSION_H
+#define VERSION_H
+
+/* Version number of GDB, as a string.  */
+extern const char version[];
+
+#endif /* #ifndef VERSION_H */
Index: ppc/Makefile.in
===================================================================
RCS file: /cvs/src/src/sim/ppc/Makefile.in,v
retrieving revision 1.22
diff -u -p -r1.22 Makefile.in
--- ppc/Makefile.in	31 May 2006 15:14:45 -0000	1.22
+++ ppc/Makefile.in	6 Jun 2008 20:24:46 -0000
@@ -534,6 +534,7 @@ LIB_OBJ = \
 	support.o \
 	@sim_fpu@ \
 	psim.o \
+	version.o \
 	$(PACKAGE_OBJ) \
 	$(HW_OBJ) \
 	options.o
@@ -560,6 +561,13 @@ $(TARGETLIB): tmp-igen tmp-dgen tmp-hw t
 	$(AR) $(AR_FLAGS) $(TARGETLIB) $(LIB_OBJ) $(GDB_OBJ)
 	$(RANLIB) $(TARGETLIB)
 
+version.c: Makefile ../../gdb/version.in
+	rm -f version.c-tmp version.c
+	echo '#include "version.h"' >> version.c-tmp
+	echo 'const char version[] = "'"`sed q ${srcdir}/../../gdb/version.in`"'";' >> version.c-tmp
+	mv version.c-tmp version.c
+version.o: version.c $(version_h)
+
 psim.o: psim.c $(CPU_H) $(IDECODE_H) $(OPTIONS_H) $(TREE_H) $(BFD_H)
 
 bits.o: bits.c $(BASICS_H)
Index: ppc/configure.ac
===================================================================
RCS file: /cvs/src/src/sim/ppc/configure.ac,v
retrieving revision 1.7
diff -u -p -r1.7 configure.ac
--- ppc/configure.ac	14 Mar 2008 20:26:49 -0000	1.7
+++ ppc/configure.ac	6 Jun 2008 20:24:47 -0000
@@ -563,6 +563,11 @@ if test x"$silent" != x"yes" && test x"$
 fi],[sim_xor_endian=""])dnl
 
 
+ACX_PKGVERSION([GDB])
+ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
+AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
+AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
+
 AC_CANONICAL_SYSTEM
 AC_ARG_PROGRAM
 
Index: ppc/main.c
===================================================================
RCS file: /cvs/src/src/sim/ppc/main.c,v
retrieving revision 1.4
diff -u -p -r1.4 main.c
--- ppc/main.c	9 Jun 2002 15:45:51 -0000	1.4
+++ ppc/main.c	6 Jun 2008 20:24:47 -0000
@@ -283,7 +283,7 @@ main(int argc, char **argv)
       print_options ();
       return 0;
     } else {
-      psim_usage(0);
+      psim_usage(0, 0);
     }
   }
   name_of_file = argv[0];
Index: ppc/psim.c
===================================================================
RCS file: /cvs/src/src/sim/ppc/psim.c,v
retrieving revision 1.7
diff -u -p -r1.7 psim.c
--- ppc/psim.c	28 Nov 2005 21:30:07 -0000	1.7
+++ ppc/psim.c	6 Jun 2008 20:24:47 -0000
@@ -119,7 +119,7 @@ find_arg(char *err_msg,
 
 INLINE_PSIM\
 (void)
-psim_usage(int verbose)
+psim_usage(int verbose, int help)
 {
   printf_filtered("Usage:\n");
   printf_filtered("\n");
@@ -217,7 +217,10 @@ psim_usage(int verbose)
     printf_filtered("\n");
     print_options();
   }
-  error("");
+
+  if (REPORT_BUGS_TO[0])
+    printf ("Report bugs to %s\n", REPORT_BUGS_TO);
+  exit (help ? 0 : 1);
 }
 
 /* Test "string" for containing a string of digits that form a number
@@ -258,7 +261,7 @@ psim_options(device *root,
     while (*p != '\0') {
       switch (*p) {
       default:
-	psim_usage(0);
+	psim_usage(0, 0);
 	error ("");
 	break;
       case 'c':
@@ -279,7 +282,7 @@ psim_options(device *root,
 	else
 	  {
 	    printf_filtered ("Invalid <endian> option for -E (target-endian)\n");
-	    psim_usage (0);
+	    psim_usage (0, 0);
 	  }
 	break;
       case 'f':
@@ -288,10 +291,10 @@ psim_options(device *root,
 	break;
       case 'h':
       case '?':
-	psim_usage(1);
+	psim_usage(1, 1);
 	break;
       case 'H':
-	psim_usage(2);
+	psim_usage(2, 1);
 	break;
       case 'i':
 	if (isdigit(p[1])) {
@@ -352,6 +355,14 @@ psim_options(device *root,
 	  p = argv[argp] + strlen(argv[argp]) - 1;
 	  printf_filtered("Warning - architecture parameter ignored\n");
         }
+	else if (strcmp (argv[argp], "--help") == 0)
+	  psim_usage (0, 1);
+	else if (strcmp (argv[argp], "--version") == 0)
+	  {
+	    extern const char version[];
+	    printf ("GNU simulator %s%s\n", PKGVERSION, version);
+	    exit (0);
+	  }
 	else
 	  error("Unrecognized option");
 	break;
Index: ppc/psim.h
===================================================================
RCS file: /cvs/src/src/sim/ppc/psim.h,v
retrieving revision 1.2
diff -u -p -r1.2 psim.h
--- ppc/psim.h	20 Jun 2003 13:32:34 -0000	1.2
+++ ppc/psim.h	6 Jun 2008 20:24:47 -0000
@@ -61,7 +61,7 @@ extern void psim_merge_device_file
  const char *file_name);
 
 extern void psim_usage
-(int verbose);
+(int verbose, int help);
 
 
 /* create a new simulator from the device tree */

-- 
Joseph S. Myers
joseph@codesourcery.com


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