forked from Imagelibrary/binutils-gdb
gdb/cli: Improve UX when using list with no args
When using "list" with no arguments, GDB will first print the lines around where the inferior is stopped, then print the next N lines until reaching the end of file, at which point it warns the user "Line X out of range, file Y only has X-1 lines.". This is usually desirable, but if the user can no longer see the original line, they may have forgotten the current line or that a list command was used at all, making GDB's error message look cryptic. It was reported in bugzilla as PR cli/30497. This commit improves the user experience by changing the behavior of "list" slightly when a user passes no arguments. It now prints that the end of the file has been reached and recommends that the user use the command "list ." instead. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30497 Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
@@ -1246,10 +1246,19 @@ list_command (const char *arg, int from_tty)
|
||||
list_around_line (arg, cursal);
|
||||
}
|
||||
|
||||
/* "l" or "l +" lists next ten lines. */
|
||||
else if (arg == NULL || arg[0] == '+')
|
||||
print_source_lines (cursal.symtab,
|
||||
source_lines_range (cursal.line), 0);
|
||||
/* "l" and "l +" lists the next few lines, unless we're listing past
|
||||
the end of the file. */
|
||||
else if (arg == nullptr || arg[0] == '+')
|
||||
{
|
||||
if (last_symtab_line (cursal.symtab) >= cursal.line)
|
||||
print_source_lines (cursal.symtab,
|
||||
source_lines_range (cursal.line), 0);
|
||||
else
|
||||
{
|
||||
error (_("End of the file was already reached, use \"list .\" to"
|
||||
" list the current location again"));
|
||||
}
|
||||
}
|
||||
|
||||
/* "l -" lists previous ten lines, the ones before the ten just
|
||||
listed. */
|
||||
|
||||
Reference in New Issue
Block a user