Add text to gdbreplay --help output

Message ID 20241209192312.1051206-1-tromey@adacore.com
State New
Headers
Series Add text to gdbreplay --help output |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom Tromey Dec. 9, 2024, 7:23 p.m. UTC
  I noticed that gdbreplay --help is rather sparse -- it doesn't even
mention the names of the options it accepts.

This patch updates the help output to be more complete.
---
 gdbserver/gdbreplay.cc | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)
  

Comments

Andrew Burgess Dec. 12, 2024, 10:32 a.m. UTC | #1
Tom Tromey <tromey@adacore.com> writes:

> I noticed that gdbreplay --help is rather sparse -- it doesn't even
> mention the names of the options it accepts.
>
> This patch updates the help output to be more complete.

Thanks for doing this.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew


> ---
>  gdbserver/gdbreplay.cc | 32 +++++++++++++++++++++++++++++---
>  1 file changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/gdbserver/gdbreplay.cc b/gdbserver/gdbreplay.cc
> index a9a55924ca9..31bda7b08d2 100644
> --- a/gdbserver/gdbreplay.cc
> +++ b/gdbserver/gdbreplay.cc
> @@ -483,8 +483,29 @@ static void
>  gdbreplay_usage (FILE *stream)
>  {
>    fprintf (stream, "Usage:\tgdbreplay LOGFILE HOST:PORT\n");
> -  if (REPORT_BUGS_TO[0] && stream == stdout)
> -    fprintf (stream, "Report bugs to \"%s\".\n", REPORT_BUGS_TO);
> +}
> +
> +static void
> +gdbreplay_help ()
> +{
> +  gdbreplay_usage (stdout);
> +
> +  printf ("\n");
> +  printf ("LOGFILE is a file generated by 'set remotelogfile' in gdb.\n");
> +  printf ("COMM may either be a tty device (for serial debugging),\n");
> +  printf ("HOST:PORT to listen for a TCP connection, or '-' or 'stdio' to use\n");
> +  printf ("stdin/stdout of gdbserver.\n");
> +  printf ("\n");
> +
> +  printf ("Options:\n\n");
> +  printf ("  --debug-logging       Show packets as they are processed.\n");
> +  printf ("  --help                Print this message and then exit.\n");
> +  printf ("  --version             Display version information and then exit.\n");
> +  if (REPORT_BUGS_TO[0])
> +    {
> +      printf ("\n");
> +      printf ("Report bugs to \"%s\".\n", REPORT_BUGS_TO);
> +    }
>  }
>  
>  /* Main function.  This is called by the real "main" function,
> @@ -512,11 +533,16 @@ captured_main (int argc, char *argv[])
>  	  gdbreplay_version ();
>  	  exit (0);
>  	case OPT_HELP:
> -	  gdbreplay_usage (stdout);
> +	  gdbreplay_help ();
>  	  exit (0);
>  	case OPT_LOGGING:
>  	  debug_logging = true;
>  	  break;
> +
> +	case '?':
> +	  fprintf (stderr,
> +		   "Use 'gdbreplay --help' for a complete list of options.\n");
> +	  exit (1);
>  	}
>      }
>  
> -- 
> 2.47.0
  

Patch

diff --git a/gdbserver/gdbreplay.cc b/gdbserver/gdbreplay.cc
index a9a55924ca9..31bda7b08d2 100644
--- a/gdbserver/gdbreplay.cc
+++ b/gdbserver/gdbreplay.cc
@@ -483,8 +483,29 @@  static void
 gdbreplay_usage (FILE *stream)
 {
   fprintf (stream, "Usage:\tgdbreplay LOGFILE HOST:PORT\n");
-  if (REPORT_BUGS_TO[0] && stream == stdout)
-    fprintf (stream, "Report bugs to \"%s\".\n", REPORT_BUGS_TO);
+}
+
+static void
+gdbreplay_help ()
+{
+  gdbreplay_usage (stdout);
+
+  printf ("\n");
+  printf ("LOGFILE is a file generated by 'set remotelogfile' in gdb.\n");
+  printf ("COMM may either be a tty device (for serial debugging),\n");
+  printf ("HOST:PORT to listen for a TCP connection, or '-' or 'stdio' to use\n");
+  printf ("stdin/stdout of gdbserver.\n");
+  printf ("\n");
+
+  printf ("Options:\n\n");
+  printf ("  --debug-logging       Show packets as they are processed.\n");
+  printf ("  --help                Print this message and then exit.\n");
+  printf ("  --version             Display version information and then exit.\n");
+  if (REPORT_BUGS_TO[0])
+    {
+      printf ("\n");
+      printf ("Report bugs to \"%s\".\n", REPORT_BUGS_TO);
+    }
 }
 
 /* Main function.  This is called by the real "main" function,
@@ -512,11 +533,16 @@  captured_main (int argc, char *argv[])
 	  gdbreplay_version ();
 	  exit (0);
 	case OPT_HELP:
-	  gdbreplay_usage (stdout);
+	  gdbreplay_help ();
 	  exit (0);
 	case OPT_LOGGING:
 	  debug_logging = true;
 	  break;
+
+	case '?':
+	  fprintf (stderr,
+		   "Use 'gdbreplay --help' for a complete list of options.\n");
+	  exit (1);
 	}
     }