mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-20 01:50:24 +08:00
gdb: 'list' command, tweak handling of +/- arguments.
There is an inconsistency with the handling of the special +/- arguments to the list command. For the very first time that list is used (after the inferior has changed locations) then only the first character of the argument string is checked, so 'list +BLAH' will operate as 'list +' and 'list -----FOO' will operate as 'list -'. This compares to each subsequent use of list, where the whole argument string is checked, so 'list +BLAH' will try to list lines of code around the function '+BLAH'. This commit unifies the behaviour so that the whole argument string is checked, in order to list the next 10, or previous 10 lines from a file only 'list +' and 'list -' are now valid. gdb/ChangeLog: * cli/cli-cmds.c (list_command): Check that the argument string is a single character, either '+' or '-'. gdb/testsuite/ChangeLog: * gdb.base/list.exp (test_list_invalid_args): New function, defined, and called.
This commit is contained in:
@ -907,7 +907,7 @@ list_command (char *arg, int from_tty)
|
||||
cleanup = make_cleanup (null_cleanup, NULL);
|
||||
|
||||
/* Pull in the current default source line if necessary. */
|
||||
if (arg == NULL || arg[0] == '+' || arg[0] == '-')
|
||||
if (arg == NULL || ((arg[0] == '+' || arg[0] == '-') && arg[1] == '\0'))
|
||||
{
|
||||
set_default_source_symtab_and_line ();
|
||||
cursal = get_current_source_symtab_and_line ();
|
||||
@ -933,13 +933,13 @@ list_command (char *arg, int from_tty)
|
||||
}
|
||||
|
||||
/* "l" or "l +" lists next ten lines. */
|
||||
else if (arg == NULL || strcmp (arg, "+") == 0)
|
||||
else if (arg == NULL || arg[0] == '+')
|
||||
print_source_lines (cursal.symtab, cursal.line,
|
||||
cursal.line + get_lines_to_list (), 0);
|
||||
|
||||
/* "l -" lists previous ten lines, the ones before the ten just
|
||||
listed. */
|
||||
else if (strcmp (arg, "-") == 0)
|
||||
else if (arg[0] == '-')
|
||||
print_source_lines (cursal.symtab,
|
||||
max (get_first_line_listed ()
|
||||
- get_lines_to_list (), 1),
|
||||
|
Reference in New Issue
Block a user