Skip to content

Commit 32d8e07

Browse files
committed
gdb: Only paginate for filtered output in fputs_maybe_filtered
A have had situation where a unfiltered output (done using fputs_unfiltered) ended up triggering pagination. The backtrace for this was: ... #24 0x000055839377ee4e in check_async_event_handlers () at ../../gdb/async-event.c:335 #25 0x0000558394b67b57 in gdb_do_one_event () at ../../gdbsupport/event-loop.cc:216 #26 0x0000558394587454 in gdb_readline_wrapper (prompt=0x7ffd907712d0 "--Type <RET> for more, q to quit, c to continue without paging--") at ../../gdb/top.c:1148 #27 0x0000558394707270 in prompt_for_continue () at ../../gdb/utils.c:1438 #28 0x00005583947088b3 in fputs_maybe_filtered (linebuffer=0x60c0000f4000 " [...quite big message...]", stream=0x60300028e9d0, filter=0) at ../../gdb/utils.c:1752 #29 0x0000558394708e57 in fputs_unfiltered (linebuffer=0x60c0000f4000 " [...quite big message...]", stream=0x60300028e9d0) at ../../gdb/utils.c:1811 ... This comes from what appears to be a oversight in fputs_maybe_filtered. This function has a FILTER parameter which if true makes the function pause after every screenful (i.e. triggers pagination). The filter parameter is correctly used to guard the first place where prompt_for_continue. There is a second place in the function which can call prompt_for_continue, but is currently unguarded. I believe that this is an oversight, this patch fixes that. Tested on Linux-x86_64, no regression observed. Change-Id: Iad8ffd50a87cf20077500878e2564b5a7dc81ece
1 parent d65aab9 commit 32d8e07

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

gdb/utils.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1744,7 +1744,8 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
17441744
/* Possible new page. Note that
17451745
PAGINATION_DISABLED_FOR_COMMAND might be set during
17461746
this loop, so we must continue to check it here. */
1747-
if (lines_printed >= lines_per_page - 1
1747+
if (filter
1748+
&& lines_printed >= lines_per_page - 1
17481749
&& !pagination_disabled_for_command)
17491750
{
17501751
prompt_for_continue ();

0 commit comments

Comments
 (0)