[PR,<gdb/29784>] Fix: Trailing whitespace omitted when using "with" command
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Testing passed
|
Commit Message
Consider the following usage of the "complete" command (<SP>
represents a whitespace):
(gdb) complete set architecture<SP>
set architecture auto
set architecture i386
set architecture i386:intel
set architecture i386:x64-32
set architecture i386:x64-32:intel
set architecture i386:x86-64
set architecture i386:x86-64:intel
set architecture i8086
The trailing whitespace is not dropped.
However, using the "with" command alongside "complete" drops the
trailing whitespace.
(gdb) with max-completions unlimited -- complete set architecture<SP>
set architecture
The execute_command() function in "gdb/top.c" is responsible for this.
It checks if the command is "complete" or "set". If it isn't, then the
trailing whitespace is cleared.
The syntax of the "with" command is:
with SETTING [VALUE] [-- COMMAND]
Given that the "with" command is used to temporarily change the value of
a setting before running a specific command, execute_command() should
not clear trailing spaces until it evaluates the COMMAND to be run
following the "--" delimiter.
Changes:
* gdb/top.c (execute_command):
Fix trailing whitespace omission for "with" command.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29784
Signed-off-by: Sahil Siddiq <icegambit91@gmail.com>
---
gdb/top.c | 1 +
1 file changed, 1 insertion(+)
Comments
>>>>> "Sahil" == Sahil Siddiq via Gdb-patches <gdb-patches@sourceware.org> writes:
Sahil> Consider the following usage of the "complete" command (<SP>
Sahil> represents a whitespace):
[...]
Thank you for the patch.
Sahil> Given that the "with" command is used to temporarily change the value of
Sahil> a setting before running a specific command, execute_command() should
Sahil> not clear trailing spaces until it evaluates the COMMAND to be run
Sahil> following the "--" delimiter.
I agree there's a bug here.
I am not completely sure about the fix. It seems like it could do the
wrong thing when completing "with" where the "sub-command" is not
"complete".
I think a test case is required as well. It can probably be added to
some existing test.
Sahil> + && strcmp(c->name, "with")
gdb style is a space before the paren and an explicit "!= 0".
Or you can use "!streq".
thanks,
Tom
@@ -525,6 +525,7 @@ execute_command (const char *p, int from_tty)
std::string without_whitespace;
if (arg
&& c->type != set_cmd
+ && strcmp(c->name, "with")
&& !is_complete_command (c))
{
const char *old_end = arg + strlen (arg) - 1;