* Makefile.in (OBS): Add version.o.
[deliverable/binutils-gdb.git] / gdb / gdbserver / server.c
index fc90e7496be017c6bc996d0b0ae988fabd84d06d..9ea2b72055cc64545ae0158d308bc553fb49ba2e 100644 (file)
@@ -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.
@@ -308,14 +308,24 @@ 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 ();
 
This page took 0.026547 seconds and 4 git commands to generate.