gdb: missing space in %OPTIONS% help output

Message ID 22e475c16675b2296845fe70d9ad4915b1bcd50f.1737040247.git.aburgess@redhat.com
State New
Headers
Series gdb: missing space in %OPTIONS% help output |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Andrew Burgess Jan. 16, 2025, 3:11 p.m. UTC
  I noticed that for gdb::option::string_option_def and
gdb::option::filename_option_def options, the help text, generated by
calling gdb::option::build_help is missing a space.  See:

  (gdb) help maintenance test-options require-delimiter
  Command used for testing options processing.
  Usage: maint test-options require-delimiter [[OPTION]... --] [OPERAND]...

  Options:
    ... snip ...

    -stringSTRING
      A string option.

    -filenameFILENAME
      A filename option.

Notice the missing space in '-stringSTRING' and '-filenameFILENAME'.
This does show up for one "real" command right now:

  (gdb) help add-inferior
  Add a new inferior.
  Usage: add-inferior [-copies NUMBER] [-exec FILENAME] [-no-connection]

  Options:
    -copies NUMBER
      The number of inferiors to add.  The default is 1.

    -execFILENAME
      FILENAME is the file name of the executable to use as the
      main program.

    -no-connection
      If specified, the new inferiors begin with no target connection.
      Without this flag the new inferiors inherit the current inferior's
      connection.

Fixed by this commit.
---
 gdb/cli/cli-option.c               |  4 +--
 gdb/testsuite/gdb.base/options.exp | 40 ++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 2 deletions(-)


base-commit: ac8f3fc9330da0302ebb491bf2bac8da5e035e35
  

Comments

Andrew Burgess Jan. 16, 2025, 5:44 p.m. UTC | #1
I just spotted that Tom already posted this fix:

  https://inbox.sourceware.org/gdb-patches/20250113143349.198028-1-tromey@adacore.com

Please ignore this patch.

Thanks,
Andrew


Andrew Burgess <aburgess@redhat.com> writes:

> I noticed that for gdb::option::string_option_def and
> gdb::option::filename_option_def options, the help text, generated by
> calling gdb::option::build_help is missing a space.  See:
>
>   (gdb) help maintenance test-options require-delimiter
>   Command used for testing options processing.
>   Usage: maint test-options require-delimiter [[OPTION]... --] [OPERAND]...
>
>   Options:
>     ... snip ...
>
>     -stringSTRING
>       A string option.
>
>     -filenameFILENAME
>       A filename option.
>
> Notice the missing space in '-stringSTRING' and '-filenameFILENAME'.
> This does show up for one "real" command right now:
>
>   (gdb) help add-inferior
>   Add a new inferior.
>   Usage: add-inferior [-copies NUMBER] [-exec FILENAME] [-no-connection]
>
>   Options:
>     -copies NUMBER
>       The number of inferiors to add.  The default is 1.
>
>     -execFILENAME
>       FILENAME is the file name of the executable to use as the
>       main program.
>
>     -no-connection
>       If specified, the new inferiors begin with no target connection.
>       Without this flag the new inferiors inherit the current inferior's
>       connection.
>
> Fixed by this commit.
> ---
>  gdb/cli/cli-option.c               |  4 +--
>  gdb/testsuite/gdb.base/options.exp | 40 ++++++++++++++++++++++++++++++
>  2 files changed, 42 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c
> index 10a59449f7c..34ac1642b84 100644
> --- a/gdb/cli/cli-option.c
> +++ b/gdb/cli/cli-option.c
> @@ -832,10 +832,10 @@ append_val_type_str (std::string &help, const option_def &opt,
>        help += "NUMBER|#RRGGBB";
>        break;
>      case var_string:
> -      help += "STRING";
> +      help += " STRING";
>        break;
>      case var_filename:
> -      help += "FILENAME";
> +      help += " FILENAME";
>        break;
>      default:
>        break;
> diff --git a/gdb/testsuite/gdb.base/options.exp b/gdb/testsuite/gdb.base/options.exp
> index e1ad61e6470..56ce2a4e4be 100644
> --- a/gdb/testsuite/gdb.base/options.exp
> +++ b/gdb/testsuite/gdb.base/options.exp
> @@ -1111,6 +1111,45 @@ proc_with_prefix test-filename {variant} {
>      }
>  }
>  
> +# Run 'help maint test-options VARIANT' to check the formatting of the
> +# generated help text.
> +proc_with_prefix test-help {variant} {
> +    gdb_test "help maintenance test-options $variant" \
> +	[multi_line \
> +    "Command used for testing options processing\\." \
> +    "Usage: maint test-options $variant \[^\r\n\]+" \
> +    "" \
> +    "Options:" \
> +    "  -flag" \
> +    "    A flag option\\." \
> +    "" \
> +    "  -xx1" \
> +    "    A flag option\\." \
> +    "" \
> +    "  -xx2" \
> +    "    A flag option\\." \
> +    "" \
> +    "  -bool \\\[on\\|off\\\]" \
> +    "    A boolean option\\." \
> +    "" \
> +    "  -enum xxx\\|yyy\\|zzz" \
> +    "    An enum option\\." \
> +    "" \
> +    "  -uinteger-unlimited NUMBER\\|unlimited" \
> +    "    A uinteger option\\." \
> +    "    A help doc that spawns" \
> +    "    multiple lines\\." \
> +    "" \
> +    "  -pinteger-unlimited NUMBER\\|unlimited" \
> +    "    A pinteger-unlimited option\\." \
> +    "" \
> +    "  -string STRING" \
> +    "    A string option\\." \
> +    "" \
> +    "  -filename FILENAME" \
> +    "    A filename option\\..*"]
> +}
> +
>  # Run the options framework tests first.
>  foreach_with_prefix cmd {
>      "require-delimiter"
> @@ -1126,6 +1165,7 @@ foreach_with_prefix cmd {
>      test-enum $cmd
>      test-string $cmd
>      test-filename $cmd
> +    test-help $cmd
>  }
>  
>  # Run the print integration tests, both as "standalone", and under
>
> base-commit: ac8f3fc9330da0302ebb491bf2bac8da5e035e35
> -- 
> 2.47.1
  

Patch

diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c
index 10a59449f7c..34ac1642b84 100644
--- a/gdb/cli/cli-option.c
+++ b/gdb/cli/cli-option.c
@@ -832,10 +832,10 @@  append_val_type_str (std::string &help, const option_def &opt,
       help += "NUMBER|#RRGGBB";
       break;
     case var_string:
-      help += "STRING";
+      help += " STRING";
       break;
     case var_filename:
-      help += "FILENAME";
+      help += " FILENAME";
       break;
     default:
       break;
diff --git a/gdb/testsuite/gdb.base/options.exp b/gdb/testsuite/gdb.base/options.exp
index e1ad61e6470..56ce2a4e4be 100644
--- a/gdb/testsuite/gdb.base/options.exp
+++ b/gdb/testsuite/gdb.base/options.exp
@@ -1111,6 +1111,45 @@  proc_with_prefix test-filename {variant} {
     }
 }
 
+# Run 'help maint test-options VARIANT' to check the formatting of the
+# generated help text.
+proc_with_prefix test-help {variant} {
+    gdb_test "help maintenance test-options $variant" \
+	[multi_line \
+    "Command used for testing options processing\\." \
+    "Usage: maint test-options $variant \[^\r\n\]+" \
+    "" \
+    "Options:" \
+    "  -flag" \
+    "    A flag option\\." \
+    "" \
+    "  -xx1" \
+    "    A flag option\\." \
+    "" \
+    "  -xx2" \
+    "    A flag option\\." \
+    "" \
+    "  -bool \\\[on\\|off\\\]" \
+    "    A boolean option\\." \
+    "" \
+    "  -enum xxx\\|yyy\\|zzz" \
+    "    An enum option\\." \
+    "" \
+    "  -uinteger-unlimited NUMBER\\|unlimited" \
+    "    A uinteger option\\." \
+    "    A help doc that spawns" \
+    "    multiple lines\\." \
+    "" \
+    "  -pinteger-unlimited NUMBER\\|unlimited" \
+    "    A pinteger-unlimited option\\." \
+    "" \
+    "  -string STRING" \
+    "    A string option\\." \
+    "" \
+    "  -filename FILENAME" \
+    "    A filename option\\..*"]
+}
+
 # Run the options framework tests first.
 foreach_with_prefix cmd {
     "require-delimiter"
@@ -1126,6 +1165,7 @@  foreach_with_prefix cmd {
     test-enum $cmd
     test-string $cmd
     test-filename $cmd
+    test-help $cmd
 }
 
 # Run the print integration tests, both as "standalone", and under