aboutsummaryrefslogtreecommitdiff
path: root/gdb/source.h
diff options
context:
space:
mode:
authorBruno Larsen <blarsen@redhat.com>2023-06-15 11:17:07 +0200
committerBruno Larsen <blarsen@redhat.com>2023-07-14 10:58:17 +0200
commitf52625f1f29a87e94aa9d40e1b76be2d0ecedc10 (patch)
tree53b8c986a4913bfe8404134a687e235d5db65ba8 /gdb/source.h
parent3e3a1874fcec34bcf51b4baf4be09aebab561bff (diff)
downloadfsf-binutils-gdb-f52625f1f29a87e94aa9d40e1b76be2d0ecedc10.zip
fsf-binutils-gdb-f52625f1f29a87e94aa9d40e1b76be2d0ecedc10.tar.gz
fsf-binutils-gdb-f52625f1f29a87e94aa9d40e1b76be2d0ecedc10.tar.bz2
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>
Diffstat (limited to 'gdb/source.h')
-rw-r--r--gdb/source.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/source.h b/gdb/source.h
index 8fbc365..be80e00 100644
--- a/gdb/source.h
+++ b/gdb/source.h
@@ -192,6 +192,13 @@ private:
int m_stopline;
};
+/* Get the number of the last line in the given symtab. */
+extern int last_symtab_line (struct symtab *s);
+
+/* Check if the line LINE can be found in the symtab S, so that it can be
+ printed. */
+extern bool can_print_line (struct symtab *s, int line);
+
/* Variation of previous print_source_lines that takes a range instead of a
start and end line number. */
extern void print_source_lines (struct symtab *s, source_lines_range r,