public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/debuginfod: Prevent prompt for continue during downloading.
@ 2023-01-28  4:06 Aaron Merey
  2023-01-28 15:01 ` Tom Tromey
  0 siblings, 1 reply; 9+ messages in thread
From: Aaron Merey @ 2023-01-28  4:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Aaron Merey

In some cases the prompt "--Type <RET> for more, q to quit, c to
continue without paging--" can appear during a large series of
debuginfod downloads when lines_printed exceeds lines_allowed.

This is inconvenient plus ctrl-c during this prompt could leave some
of gdb's internal structures in a broken state.

Fix this by adding a bool count_lines_printed to control whether
lines_printed is incremented when a newline is printed.  Set this
value to false when performing a download.
---
 gdb/debuginfod-support.c |  6 ++++++
 gdb/utils.c              | 10 ++++++++--
 gdb/utils.h              |  2 ++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 04d254a1601..d5fb6153ee4 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -293,6 +293,8 @@ debuginfod_source_query (const unsigned char *build_id,
   user_data data ("source file", srcpath);
 
   debuginfod_set_user_data (c, &data);
+  scoped_restore save_count_lines_printed
+    = make_scoped_restore (&count_lines_printed, false);
   gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
   if (target_supports_terminal_ours ())
     {
@@ -334,6 +336,8 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
   user_data data ("separate debug info for", filename);
 
   debuginfod_set_user_data (c, &data);
+  scoped_restore save_count_lines_printed
+    = make_scoped_restore (&count_lines_printed, false);
   gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
   if (target_supports_terminal_ours ())
     {
@@ -372,6 +376,8 @@ debuginfod_exec_query (const unsigned char *build_id,
   user_data data ("executable for", filename);
 
   debuginfod_set_user_data (c, &data);
+  scoped_restore save_count_lines_printed
+    = make_scoped_restore (&count_lines_printed, false);
   gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
   if (target_supports_terminal_ours ())
     {
diff --git a/gdb/utils.c b/gdb/utils.c
index 95adbe58e4a..cb6f7276ab3 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1166,6 +1166,10 @@ show_chars_per_line (struct ui_file *file, int from_tty,
 /* Current count of lines printed on this page, chars on this line.  */
 static unsigned int lines_printed, chars_printed;
 
+/* Controls whether to increment lines_printed.  */
+
+bool count_lines_printed = true;
+
 /* True if pagination is disabled for just one command.  */
 
 static bool pagination_disabled_for_command;
@@ -1675,7 +1679,8 @@ pager_file::puts (const char *linebuffer)
 	      bool did_paginate = false;
 
 	      chars_printed = 0;
-	      lines_printed++;
+	      if (count_lines_printed)
+		lines_printed++;
 	      if (m_wrap_column)
 		{
 		  /* We are about to insert a newline at an historic
@@ -1736,7 +1741,8 @@ pager_file::puts (const char *linebuffer)
 	{
 	  chars_printed = 0;
 	  wrap_here (0); /* Spit out chars, cancel further wraps.  */
-	  lines_printed++;
+	  if (count_lines_printed)
+	    lines_printed++;
 	  m_stream->puts ("\n");
 	  lineptr++;
 	}
diff --git a/gdb/utils.h b/gdb/utils.h
index 7865812998e..fdac3e03211 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -167,6 +167,8 @@ extern int get_chars_per_line ();
 
 extern bool pagination_enabled;
 
+extern bool count_lines_printed;
+
 /* A flag indicating whether to timestamp debugging messages.  */
 extern bool debug_timestamp;
 
-- 
2.39.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-02-13 20:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-28  4:06 [PATCH] gdb/debuginfod: Prevent prompt for continue during downloading Aaron Merey
2023-01-28 15:01 ` Tom Tromey
2023-01-31  2:09   ` Aaron Merey
2023-01-31 14:22     ` Tom Tromey
2023-01-31 20:41       ` Aaron Merey
2023-02-08 14:44         ` Tom Tromey
2023-02-11  2:02           ` Aaron Merey
2023-02-13 14:17             ` Tom Tromey
2023-02-13 20:23               ` Aaron Merey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).