Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Version string added to gdbserver
@ 2006-01-31 10:58 Girish Shilamkar
  2006-02-01 21:37 ` Daniel Jacobowitz
  0 siblings, 1 reply; 2+ messages in thread
From: Girish Shilamkar @ 2006-01-31 10:58 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 450 bytes --]

Hi,
	gdbserver Makefile consists of following line:

# Perhaps should come from parent Makefile
VERSION = gdbserver-4.12.3

	In order to know which gdbserver is being run, the following patch
prints gdbserver version when gdbserver is started. 
	Should the gdb version also be displayed, from which gdbserver was
built (i.e gdb 6.4 etc), since gdbserver built from different gdb
versions may be different even if gdbserver version is same?

-Girish.

[-- Attachment #2: gdbserver_version.patch --]
[-- Type: text/x-patch, Size: 2733 bytes --]

Index: gdb/gdbserver/Makefile.in
===================================================================
--- gdb.orig/gdbserver/Makefile.in	2006-01-31 14:44:32.000000000 +0530
+++ gdb/gdbserver/Makefile.in	2006-01-31 14:57:21.000000000 +0530
@@ -126,7 +126,8 @@
 	$(srcdir)/linux-m68k-low.c $(srcdir)/linux-mips-low.c \
 	$(srcdir)/linux-ppc-low.c $(srcdir)/linux-ppc64-low.c \
 	$(srcdir)/linux-s390-low.c \
-	$(srcdir)/linux-sh-low.c $(srcdir)/linux-x86-64-low.c
+	$(srcdir)/linux-sh-low.c $(srcdir)/linux-x86-64-low.c \
+        $(srcdir)/version.c
 
 DEPFILES = @GDBSERVER_DEPFILES@
 
@@ -136,6 +137,7 @@
 OBS = inferiors.o regcache.o remote-utils.o server.o signals.o target.o \
 	utils.o \
 	mem-break.o \
+	version.o \
 	$(DEPFILES)
 GDBSERVER_LIBS = @GDBSERVER_LIBS@
 
@@ -204,6 +206,7 @@
 	rm -f reg-arm.c reg-i386.c reg-ia64.c reg-m32r.c reg-m68k.c reg-mips.c
 	rm -f reg-ppc.c reg-sh.c reg-x86-64.c reg-i386-linux.c
 	rm -f reg-cris.c reg-crisv32.c
+	rm -f version.c 
 
 maintainer-clean realclean distclean: clean
 	rm -f nm.h tm.h xm.h config.status config.h stamp-h config.log
@@ -224,7 +227,8 @@
 force:
 
 version.c: Makefile
-	echo 'char *version = "$(VERSION)";' >version.c
+	echo '#include "version.h"' >version.c
+	echo 'const char version[] = "$(VERSION)";' >>version.c
 
 # GNU Make has an annoying habit of putting *all* the Makefile variables
 # into the environment, unless you include this target as a circumvention.
@@ -243,7 +247,9 @@
 regcache_h = $(srcdir)/regcache.h
 server_h = $(srcdir)/server.h $(regcache_h) config.h $(srcdir)/target.h \
 		$(srcdir)/mem-break.h
+version_h = $(srcdir)/version.h
 
+version.o: version.c $(server_h)
 inferiors.o: inferiors.c $(server_h)
 mem-break.o: mem-break.c $(server_h)
 proc-service.o: proc-service.c $(server_h) $(gdb_proc_service_h)
Index: gdb/gdbserver/version.h
===================================================================
--- gdb.orig/gdbserver/version.h	2006-01-31 11:29:08.772974888 +0530
+++ gdb/gdbserver/version.h	2006-01-31 15:10:21.293967032 +0530
@@ -0,0 +1,8 @@
+#ifndef VERSION_H
+#define VERSION_H
+
+/* Version number of gdbserver, as a string.  */
+extern const char version[];
+
+#endif /* #ifndef VERSION_H */
+
Index: gdb/gdbserver/server.c
===================================================================
--- gdb.orig/gdbserver/server.c	2006-01-31 14:52:10.000000000 +0530
+++ gdb/gdbserver/server.c	2006-01-31 14:59:11.098852176 +0530
@@ -21,6 +21,7 @@
    Boston, MA 02110-1301, USA.  */
 
 #include "server.h"
+#include "version.h"
 
 #include <unistd.h>
 #include <signal.h>
@@ -358,6 +359,8 @@
 
   initialize_low ();
 
+  fprintf(stderr, "GNU %s\n",version);
+
   own_buf = malloc (PBUFSIZ);
   mem_buf = malloc (PBUFSIZ);
 

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

* Re: Version string added to gdbserver
  2006-01-31 10:58 Version string added to gdbserver Girish Shilamkar
@ 2006-02-01 21:37 ` Daniel Jacobowitz
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2006-02-01 21:37 UTC (permalink / raw)
  To: Girish Shilamkar; +Cc: gdb-patches

On Tue, Jan 31, 2006 at 04:30:00PM +0530, Girish Shilamkar wrote:
> Hi,
> 	gdbserver Makefile consists of following line:
> 
> # Perhaps should come from parent Makefile
> VERSION = gdbserver-4.12.3
> 
> 	In order to know which gdbserver is being run, the following patch
> prints gdbserver version when gdbserver is started. 
> 	Should the gdb version also be displayed, from which gdbserver was
> built (i.e gdb 6.4 etc), since gdbserver built from different gdb
> versions may be different even if gdbserver version is same?

It ought to just use the gdb version number; I've checked in this
alternate patch.  Thanks for the report.

-- 
Daniel Jacobowitz
CodeSourcery

2006-02-01  Daniel Jacobowitz  <dan@codesourcery.com>

	* Makefile.in (OBS): Add version.o.
	(STAGESTUFF): Delete.
	(version.o): Add dependencies.
	(version.c): Replace rule.
	(clean): Remove version.c.
	* server.c (gdbserver_version): New.
	(gdbserver_usage): Use printf.
	(main): Handle --version and --help.
	* server.h (version, host_name): Add declarations.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/Makefile.in,v
retrieving revision 1.32
diff -u -p -r1.32 Makefile.in
--- Makefile.in	23 Dec 2005 18:11:55 -0000	1.32
+++ Makefile.in	1 Feb 2006 21:36:00 -0000
@@ -1,5 +1,6 @@
 # Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-# 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+# 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+# Free Software Foundation, Inc.
 
 # This file is part of GDB.
 
@@ -134,7 +135,7 @@ SOURCES = $(SFILES)
 TAGFILES = $(SOURCES) ${HFILES} ${ALLPARAM} ${POSSLIBS} 
 
 OBS = inferiors.o regcache.o remote-utils.o server.o signals.o target.o \
-	utils.o \
+	utils.o version.o \
 	mem-break.o \
 	$(DEPFILES)
 GDBSERVER_LIBS = @GDBSERVER_LIBS@
@@ -200,6 +201,7 @@ tags: TAGS
 
 clean:
 	rm -f *.o ${ADD_FILES} *~
+	rm -f version.c
 	rm -f gdbserver gdbreplay core make.log
 	rm -f reg-arm.c reg-i386.c reg-ia64.c reg-m32r.c reg-m68k.c reg-mips.c
 	rm -f reg-ppc.c reg-sh.c reg-x86-64.c reg-i386-linux.c
@@ -209,8 +211,6 @@ maintainer-clean realclean distclean: cl
 	rm -f nm.h tm.h xm.h config.status config.h stamp-h config.log
 	rm -f Makefile
 
-STAGESTUFF=${OBS} ${TSOBS} ${NTSOBS} ${ADD_FILES} init.c init.o version.c gdb
-
 config.h: stamp-h ; @true
 stamp-h: config.in config.status
 	CONFIG_FILES="" CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
@@ -223,8 +223,13 @@ config.status: configure configure.srv
 
 force:
 
-version.c: Makefile
-	echo 'char *version = "$(VERSION)";' >version.c
+version.c: Makefile $(srcdir)/../version.in
+	rm -f version.c-tmp version.c
+	echo '#include "server.h"' >> version.c-tmp
+	echo 'const char version[] = "'"`sed q ${srcdir}/../version.in`"'";' >> version.c-tmp
+	echo 'const char host_name[] = "$(host_alias)";' >> version.c-tmp
+	mv version.c-tmp version.c
+version.o: version.c $(server_h)
 
 # GNU Make has an annoying habit of putting *all* the Makefile variables
 # into the environment, unless you include this target as a circumvention.
Index: server.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
retrieving revision 1.30
diff -u -p -r1.30 server.c
--- server.c	23 Dec 2005 18:11:55 -0000	1.30
+++ server.c	1 Feb 2006 21:36:00 -0000
@@ -1,6 +1,6 @@
 /* Main code for remote server for GDB.
    Copyright (C) 1989, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2002, 2003, 2004,
-   2005
+   2005, 2006
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -309,13 +309,23 @@ myresume (int step, int sig)
 static int attached;
 
 static void
+gdbserver_version (void)
+{
+  printf ("GNU gdbserver %s\n"
+	  "Copyright (C) 2006 Free Software Foundation, Inc.\n"
+	  "gdbserver is free software, covered by the GNU General Public License.\n"
+	  "This gdbserver was configured as \"%s\"\n",
+	  version, host_name);
+}
+
+static void
 gdbserver_usage (void)
 {
-  error ("Usage:\tgdbserver COMM PROG [ARGS ...]\n"
-	 "\tgdbserver COMM --attach PID\n"
-	 "\n"
-	 "COMM may either be a tty device (for serial debugging), or \n"
-	 "HOST:PORT to listen for a TCP connection.\n");
+  printf ("Usage:\tgdbserver COMM PROG [ARGS ...]\n"
+	  "\tgdbserver COMM --attach PID\n"
+	  "\n"
+	  "COMM may either be a tty device (for serial debugging), or \n"
+	  "HOST:PORT to listen for a TCP connection.\n");
 }
 
 int
@@ -331,6 +341,18 @@ main (int argc, char *argv[])
   int pid;
   char *arg_end;
 
+  if (argc >= 2 && strcmp (argv[1], "--version") == 0)
+    {
+      gdbserver_version ();
+      exit (0);
+    }
+
+  if (argc >= 2 && strcmp (argv[1], "--help") == 0)
+    {
+      gdbserver_usage ();
+      exit (0);
+    }
+
   if (setjmp (toplevel))
     {
       fprintf (stderr, "Exiting\n");
@@ -354,7 +376,10 @@ main (int argc, char *argv[])
     }
 
   if (argc < 3 || bad_attach)
-    gdbserver_usage();
+    {
+      gdbserver_usage ();
+      exit (1);
+    }
 
   initialize_low ();
 
Index: server.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.h,v
retrieving revision 1.21
diff -u -p -r1.21 server.h
--- server.h	23 Dec 2005 18:11:55 -0000	1.21
+++ server.h	1 Feb 2006 21:36:00 -0000
@@ -181,4 +181,8 @@ void init_registers (void);
 		 ? (registers_length () + 32) \
 		 : 2000)
 
+/* Version information, from version.c.  */
+extern const char version[];
+extern const char host_name[];
+
 #endif /* SERVER_H */


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

end of thread, other threads:[~2006-02-01 21:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-31 10:58 Version string added to gdbserver Girish Shilamkar
2006-02-01 21:37 ` Daniel Jacobowitz

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