aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAaron Merey <amerey@redhat.com>2023-05-23 11:03:32 -0400
committerAaron Merey <amerey@redhat.com>2023-05-23 11:12:31 -0400
commit6aebb6e100fb3c5e2acf19f8b0432b3b4fd750e0 (patch)
tree1914ccf832d97cb05a5b5774be9b528916c0ed52 /gdb
parent13a3cad698b3a757b1fcc938cc33e09a364ea47a (diff)
downloadgdb-6aebb6e100fb3c5e2acf19f8b0432b3b4fd750e0.zip
gdb-6aebb6e100fb3c5e2acf19f8b0432b3b4fd750e0.tar.gz
gdb-6aebb6e100fb3c5e2acf19f8b0432b3b4fd750e0.tar.bz2
gdb/cli-out.c: clear_current_line shouldn't trigger pagination prompt
clear_current_line overwrites the current line with chars_per_line blank spaces. Printing the final space triggers a condition in pager_file::puts that causes lines_printed to be incremented. If lines_printed becomes greater than or equal to lines_allowed, the pagination prompt will appear if enabled. In this case the prompt is unnecessary since after printing the final space clear_current_line immediately moves the cursor to the beginning of the line with '\r'. A new line isn't actually started, so the prompt ends up being spurious. Additionally it's possible for gdb to crash during this pagination prompt. Answering the prompt with 'q' throws an exception intended to bring gdb back to the main event loop. But since commit 0fea10f32746, clear_current_line may be called under the progress_update destructor. The exception will try to propagate through the destructor, causing an abort. To fix this, pagination is disabled for the duration for clear_current_line. clear_current_line is also renamed to clear_progress_notify to help indicate that it is a special purpose function intended for use with do_progress_notify. Acked-by: Eli Zaretskii <eliz@gnu.org>
Diffstat (limited to 'gdb')
-rw-r--r--gdb/cli-out.c11
-rw-r--r--gdb/cli-out.h2
2 files changed, 8 insertions, 5 deletions
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 4c59888..20d3d93 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -378,15 +378,18 @@ cli_ui_out::do_progress_notify (const std::string &msg,
return;
}
-/* Clear the current line of the most recent progress update. Overwrites
- the current line with whitespace. */
+/* Clear do_progress_notify output from the current line. Overwrites the
+ notification with whitespace. */
void
-cli_ui_out::clear_current_line ()
+cli_ui_out::clear_progress_notify ()
{
struct ui_file *stream = m_streams.back ();
int chars_per_line = get_chars_per_line ();
+ scoped_restore save_pagination
+ = make_scoped_restore (&pagination_enabled, false);
+
if (!stream->isatty ()
|| !current_ui->input_interactive_p ()
|| chars_per_line < MIN_CHARS_PER_LINE)
@@ -413,7 +416,7 @@ cli_ui_out::do_progress_end ()
m_progress_info.pop_back ();
if (stream->isatty ())
- clear_current_line ();
+ clear_progress_notify ();
}
/* local functions */
diff --git a/gdb/cli-out.h b/gdb/cli-out.h
index 0729834..3401618 100644
--- a/gdb/cli-out.h
+++ b/gdb/cli-out.h
@@ -104,7 +104,7 @@ private:
/* Stack of progress info. */
std::vector<cli_progress_info> m_progress_info;
- void clear_current_line ();
+ void clear_progress_notify ();
};
extern void cli_display_match_list (char **matches, int len, int max);