forked from Imagelibrary/binutils-gdb
gdb: Add an error when 'list -' reaches the start of a file.
When a a user uses 'list +' to list forward through a source file they eventually reach the end of the source file. Subsequent uses of 'list +' result in an error message like this, that let the user know they are at the end of the source file: Line number XXX out of range; FILENAME has YYY lines. Compare this to the current behaviour of 'list -' which lists backwards through a source file. When the user reaches the beginning of the source file, subsequent uses of 'list -' result in the command silently returning. This can be confusing if the previous uses of 'list -' have scrolled off the users display, the user receives no reminder that the have already seen the start of the file. After this commit a use of 'list -' when the user has already seen the start of a file will receive the following error: Already at the start of FILENAME. gdb/ChangeLog: * cli/cli-cmds.c (list_command): Add an error when trying to use '-' to scan read off the start of the source file. gdb/testsuite/ChangeLog: * gdb.base/list.exp (test_list_forward): Add end of file error test. (test_repeat_list_command): Add end of file error test. (test_list_backwards): Add beginning of file error test.
This commit is contained in:
@@ -940,10 +940,15 @@ list_command (char *arg, int from_tty)
|
||||
/* "l -" lists previous ten lines, the ones before the ten just
|
||||
listed. */
|
||||
else if (arg[0] == '-')
|
||||
print_source_lines (cursal.symtab,
|
||||
max (get_first_line_listed ()
|
||||
- get_lines_to_list (), 1),
|
||||
get_first_line_listed (), 0);
|
||||
{
|
||||
if (get_first_line_listed () == 1)
|
||||
error (_("Already at the start of %s."),
|
||||
symtab_to_filename_for_display (cursal.symtab));
|
||||
print_source_lines (cursal.symtab,
|
||||
max (get_first_line_listed ()
|
||||
- get_lines_to_list (), 1),
|
||||
get_first_line_listed (), 0);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user