* Fix double apropos output when both alias name and command name match the pattern @ 2026-05-31 16:37 Philippe Waroquiers 2026-05-31 16:37 ` [PATCH] " Philippe Waroquiers 0 siblings, 1 reply; 5+ messages in thread From: Philippe Waroquiers @ 2026-05-31 16:37 UTC (permalink / raw) To: gdb-patches apropos_cmd first tries to match the command name with the pattern. If that succeeds, it prints the command and all its aliases not having a specific doc string. In this case, it should not try to match the command aliases names as the command has already been printed. Without this patch, the behaviour is: (gdb) alias ter-exec = interpreter-exec (gdb) apropos er-exe interpreter-exec, ter-exec -- Execute a command in an interpreter. interpreter-exec, ter-exec -- Execute a command in an interpreter. (gdb) ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Fix double apropos output when both alias name and command name match the pattern 2026-05-31 16:37 Fix double apropos output when both alias name and command name match the pattern Philippe Waroquiers @ 2026-05-31 16:37 ` Philippe Waroquiers 2026-06-16 18:51 ` Philippe Waroquiers 2026-07-23 14:59 ` Guinevere Larsen 0 siblings, 2 replies; 5+ messages in thread From: Philippe Waroquiers @ 2026-05-31 16:37 UTC (permalink / raw) To: gdb-patches; +Cc: Philippe Waroquiers apropos_cmd first tries to match the command name with the pattern. If that succeeds, it prints the command and all its aliases not having a specific doc string. In this case, it should not try to match the command aliases names as the command has already been printed. Without this patch, the behaviour is: (gdb) alias ter-exec = interpreter-exec (gdb) apropos er-exe interpreter-exec, ter-exec -- Execute a command in an interpreter. interpreter-exec, ter-exec -- Execute a command in an interpreter. (gdb) --- gdb/cli/cli-decode.c | 18 ++++++++++-------- gdb/testsuite/gdb.base/help.exp | 8 ++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index de40faeed59..36f911c2cd6 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -1784,16 +1784,18 @@ apropos_cmd (struct ui_file *stream, returnvalue = regex.search (c->name, name_len, 0, name_len, NULL); if (returnvalue >= 0) print_doc_of_command (*c, verbose, regex, stream); - - /* Try to match against the name of the aliases. */ - for (const cmd_list_element &alias : c->aliases) + else { - name_len = strlen (alias.name); - returnvalue = regex.search (alias.name, name_len, 0, name_len, NULL); - if (returnvalue >= 0) + /* Try to match against the name of the aliases. */ + for (const cmd_list_element &alias : c->aliases) { - print_doc_of_command (*c, verbose, regex, stream); - break; + name_len = strlen (alias.name); + returnvalue = regex.search (alias.name, name_len, 0, name_len, NULL); + if (returnvalue >= 0) + { + print_doc_of_command (*c, verbose, regex, stream); + break; + } } } } diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp index a8c55721ef2..6a88c8d4db2 100644 --- a/gdb/testsuite/gdb.base/help.exp +++ b/gdb/testsuite/gdb.base/help.exp @@ -135,6 +135,14 @@ gdb_test_no_output "alias mybt10 = backtrace 10" "define mybt10 alias" gdb_test "apropos Print backtrace of all stack frames, or innermost COUNT frames\." \ "backtrace, mybt10, mybt, where, bt -- Print backtrace of all stack frames, or innermost COUNT frames\.\[\r\n\]+ alias mybt10 = backtrace 10" +# Test apropos when both the alias name and the aliased command match the pattern. +gdb_test_no_output "alias ter-exec = interpreter-exec" "define ter-exec alias" +gdb_test_multiple "apropos er-exe" "check we have a single output line when alias and command name match" { + -re "^apropos er-exe\r\ninterpreter-exec, ter-exec -- Execute a command in an interpreter\.\r\n$gdb_prompt $" { + pass $gdb_test_name + } +} + # Test help for commands having aliases. gdb_test "help bt" "backtrace, mybt10, mybt, where, bt\[\r\n\]+ alias mybt10 = backtrace 10\[\r\n\]+Print backtrace of all stack frames, or innermost COUNT frames\..*" -- 2.47.3 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix double apropos output when both alias name and command name match the pattern 2026-05-31 16:37 ` [PATCH] " Philippe Waroquiers @ 2026-06-16 18:51 ` Philippe Waroquiers 2026-07-21 14:42 ` Philippe Waroquiers 2026-07-23 14:59 ` Guinevere Larsen 1 sibling, 1 reply; 5+ messages in thread From: Philippe Waroquiers @ 2026-06-16 18:51 UTC (permalink / raw) To: gdb-patches Ping ? Thanks Philippe On Sun, 2026-05-31 at 18:37 +0200, Philippe Waroquiers wrote: > apropos_cmd first tries to match the command name with the pattern. > If that succeeds, it prints the command and all its aliases not having > a specific doc string. > In this case, it should not try to match the command aliases names as > the command has already been printed. > > Without this patch, the behaviour is: > (gdb) alias ter-exec = interpreter-exec > (gdb) apropos er-exe > interpreter-exec, ter-exec -- Execute a command in an interpreter. > interpreter-exec, ter-exec -- Execute a command in an interpreter. > (gdb) > --- > gdb/cli/cli-decode.c | 18 ++++++++++-------- > gdb/testsuite/gdb.base/help.exp | 8 ++++++++ > 2 files changed, 18 insertions(+), 8 deletions(-) > > diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c > index de40faeed59..36f911c2cd6 100644 > --- a/gdb/cli/cli-decode.c > +++ b/gdb/cli/cli-decode.c > @@ -1784,16 +1784,18 @@ apropos_cmd (struct ui_file *stream, > returnvalue = regex.search (c->name, name_len, 0, name_len, NULL); > if (returnvalue >= 0) > print_doc_of_command (*c, verbose, regex, stream); > - > - /* Try to match against the name of the aliases. */ > - for (const cmd_list_element &alias : c->aliases) > + else > { > - name_len = strlen (alias.name); > - returnvalue = regex.search (alias.name, name_len, 0, name_len, NULL); > - if (returnvalue >= 0) > + /* Try to match against the name of the aliases. */ > + for (const cmd_list_element &alias : c->aliases) > { > - print_doc_of_command (*c, verbose, regex, stream); > - break; > + name_len = strlen (alias.name); > + returnvalue = regex.search (alias.name, name_len, 0, name_len, NULL); > + if (returnvalue >= 0) > + { > + print_doc_of_command (*c, verbose, regex, stream); > + break; > + } > } > } > } > diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp > index a8c55721ef2..6a88c8d4db2 100644 > --- a/gdb/testsuite/gdb.base/help.exp > +++ b/gdb/testsuite/gdb.base/help.exp > @@ -135,6 +135,14 @@ gdb_test_no_output "alias mybt10 = backtrace 10" "define mybt10 alias" > gdb_test "apropos Print backtrace of all stack frames, or innermost COUNT frames\." \ > "backtrace, mybt10, mybt, where, bt -- Print backtrace of all stack frames, or innermost COUNT frames\.\[\r\n\]+ alias mybt10 = backtrace 10" > > +# Test apropos when both the alias name and the aliased command match the pattern. > +gdb_test_no_output "alias ter-exec = interpreter-exec" "define ter-exec alias" > +gdb_test_multiple "apropos er-exe" "check we have a single output line when alias and command name match" { > + -re "^apropos er-exe\r\ninterpreter-exec, ter-exec -- Execute a command in an interpreter\.\r\n$gdb_prompt $" { > + pass $gdb_test_name > + } > +} > + > # Test help for commands having aliases. > gdb_test "help bt" "backtrace, mybt10, mybt, where, bt\[\r\n\]+ alias mybt10 = backtrace 10\[\r\n\]+Print backtrace of all stack frames, or innermost COUNT frames\..*" > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix double apropos output when both alias name and command name match the pattern 2026-06-16 18:51 ` Philippe Waroquiers @ 2026-07-21 14:42 ` Philippe Waroquiers 0 siblings, 0 replies; 5+ messages in thread From: Philippe Waroquiers @ 2026-07-21 14:42 UTC (permalink / raw) To: gdb-patches Ping ^ 2 ? Thanks Philippe On Tue, 2026-06-16 at 20:51 +0200, Philippe Waroquiers wrote: > Ping ? > Thanks > Philippe > > On Sun, 2026-05-31 at 18:37 +0200, Philippe Waroquiers wrote: > > apropos_cmd first tries to match the command name with the pattern. > > If that succeeds, it prints the command and all its aliases not having > > a specific doc string. > > In this case, it should not try to match the command aliases names as > > the command has already been printed. > > > > Without this patch, the behaviour is: > > (gdb) alias ter-exec = interpreter-exec > > (gdb) apropos er-exe > > interpreter-exec, ter-exec -- Execute a command in an interpreter. > > interpreter-exec, ter-exec -- Execute a command in an interpreter. > > (gdb) > > --- > > gdb/cli/cli-decode.c | 18 ++++++++++-------- > > gdb/testsuite/gdb.base/help.exp | 8 ++++++++ > > 2 files changed, 18 insertions(+), 8 deletions(-) > > > > diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c > > index de40faeed59..36f911c2cd6 100644 > > --- a/gdb/cli/cli-decode.c > > +++ b/gdb/cli/cli-decode.c > > @@ -1784,16 +1784,18 @@ apropos_cmd (struct ui_file *stream, > > returnvalue = regex.search (c->name, name_len, 0, name_len, NULL); > > if (returnvalue >= 0) > > print_doc_of_command (*c, verbose, regex, stream); > > - > > - /* Try to match against the name of the aliases. */ > > - for (const cmd_list_element &alias : c->aliases) > > + else > > { > > - name_len = strlen (alias.name); > > - returnvalue = regex.search (alias.name, name_len, 0, name_len, NULL); > > - if (returnvalue >= 0) > > + /* Try to match against the name of the aliases. */ > > + for (const cmd_list_element &alias : c->aliases) > > { > > - print_doc_of_command (*c, verbose, regex, stream); > > - break; > > + name_len = strlen (alias.name); > > + returnvalue = regex.search (alias.name, name_len, 0, name_len, NULL); > > + if (returnvalue >= 0) > > + { > > + print_doc_of_command (*c, verbose, regex, stream); > > + break; > > + } > > } > > } > > } > > diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp > > index a8c55721ef2..6a88c8d4db2 100644 > > --- a/gdb/testsuite/gdb.base/help.exp > > +++ b/gdb/testsuite/gdb.base/help.exp > > @@ -135,6 +135,14 @@ gdb_test_no_output "alias mybt10 = backtrace 10" "define mybt10 alias" > > gdb_test "apropos Print backtrace of all stack frames, or innermost COUNT frames\." \ > > "backtrace, mybt10, mybt, where, bt -- Print backtrace of all stack frames, or innermost COUNT frames\.\[\r\n\]+ alias mybt10 = backtrace 10" > > > > +# Test apropos when both the alias name and the aliased command match the pattern. > > +gdb_test_no_output "alias ter-exec = interpreter-exec" "define ter-exec alias" > > +gdb_test_multiple "apropos er-exe" "check we have a single output line when alias and command name match" { > > + -re "^apropos er-exe\r\ninterpreter-exec, ter-exec -- Execute a command in an interpreter\.\r\n$gdb_prompt $" { > > + pass $gdb_test_name > > + } > > +} > > + > > # Test help for commands having aliases. > > gdb_test "help bt" "backtrace, mybt10, mybt, where, bt\[\r\n\]+ alias mybt10 = backtrace 10\[\r\n\]+Print backtrace of all stack frames, or innermost COUNT frames\..*" > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix double apropos output when both alias name and command name match the pattern 2026-05-31 16:37 ` [PATCH] " Philippe Waroquiers 2026-06-16 18:51 ` Philippe Waroquiers @ 2026-07-23 14:59 ` Guinevere Larsen 1 sibling, 0 replies; 5+ messages in thread From: Guinevere Larsen @ 2026-07-23 14:59 UTC (permalink / raw) To: Philippe Waroquiers, gdb-patches On 5/31/26 1:37 PM, Philippe Waroquiers wrote: > apropos_cmd first tries to match the command name with the pattern. > If that succeeds, it prints the command and all its aliases not having > a specific doc string. > In this case, it should not try to match the command aliases names as > the command has already been printed. > > Without this patch, the behaviour is: > (gdb) alias ter-exec = interpreter-exec > (gdb) apropos er-exe > interpreter-exec, ter-exec -- Execute a command in an interpreter. > interpreter-exec, ter-exec -- Execute a command in an interpreter. > (gdb) > --- Hi! Thanks for working on this and sorry for the delay in getting a review. This looks like a pretty good and straight-forward change. Hopefully it gets approved soon. Reviewed-By: Guinevere Larsen <guinevere@redhat.com> -- Cheers, Guinevere Larsen it/its she/her (deprecated) > gdb/cli/cli-decode.c | 18 ++++++++++-------- > gdb/testsuite/gdb.base/help.exp | 8 ++++++++ > 2 files changed, 18 insertions(+), 8 deletions(-) > > diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c > index de40faeed59..36f911c2cd6 100644 > --- a/gdb/cli/cli-decode.c > +++ b/gdb/cli/cli-decode.c > @@ -1784,16 +1784,18 @@ apropos_cmd (struct ui_file *stream, > returnvalue = regex.search (c->name, name_len, 0, name_len, NULL); > if (returnvalue >= 0) > print_doc_of_command (*c, verbose, regex, stream); > - > - /* Try to match against the name of the aliases. */ > - for (const cmd_list_element &alias : c->aliases) > + else > { > - name_len = strlen (alias.name); > - returnvalue = regex.search (alias.name, name_len, 0, name_len, NULL); > - if (returnvalue >= 0) > + /* Try to match against the name of the aliases. */ > + for (const cmd_list_element &alias : c->aliases) > { > - print_doc_of_command (*c, verbose, regex, stream); > - break; > + name_len = strlen (alias.name); > + returnvalue = regex.search (alias.name, name_len, 0, name_len, NULL); > + if (returnvalue >= 0) > + { > + print_doc_of_command (*c, verbose, regex, stream); > + break; > + } > } > } > } > diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp > index a8c55721ef2..6a88c8d4db2 100644 > --- a/gdb/testsuite/gdb.base/help.exp > +++ b/gdb/testsuite/gdb.base/help.exp > @@ -135,6 +135,14 @@ gdb_test_no_output "alias mybt10 = backtrace 10" "define mybt10 alias" > gdb_test "apropos Print backtrace of all stack frames, or innermost COUNT frames\." \ > "backtrace, mybt10, mybt, where, bt -- Print backtrace of all stack frames, or innermost COUNT frames\.\[\r\n\]+ alias mybt10 = backtrace 10" > > +# Test apropos when both the alias name and the aliased command match the pattern. > +gdb_test_no_output "alias ter-exec = interpreter-exec" "define ter-exec alias" > +gdb_test_multiple "apropos er-exe" "check we have a single output line when alias and command name match" { > + -re "^apropos er-exe\r\ninterpreter-exec, ter-exec -- Execute a command in an interpreter\.\r\n$gdb_prompt $" { > + pass $gdb_test_name > + } > +} > + > # Test help for commands having aliases. > gdb_test "help bt" "backtrace, mybt10, mybt, where, bt\[\r\n\]+ alias mybt10 = backtrace 10\[\r\n\]+Print backtrace of all stack frames, or innermost COUNT frames\..*" > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-23 14:59 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-05-31 16:37 Fix double apropos output when both alias name and command name match the pattern Philippe Waroquiers 2026-05-31 16:37 ` [PATCH] " Philippe Waroquiers 2026-06-16 18:51 ` Philippe Waroquiers 2026-07-21 14:42 ` Philippe Waroquiers 2026-07-23 14:59 ` Guinevere Larsen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox