public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Aaron Merey <amerey@redhat.com>
To: gdb-patches@sourceware.org
Cc: Aaron Merey <amerey@redhat.com>
Subject: [PATCH] gdb/debuginfod: Prevent prompt for continue during downloading.
Date: Fri, 27 Jan 2023 23:06:01 -0500	[thread overview]
Message-ID: <20230128040601.2927632-1-amerey@redhat.com> (raw)

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


             reply	other threads:[~2023-01-28  4:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-28  4:06 Aaron Merey [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230128040601.2927632-1-amerey@redhat.com \
    --to=amerey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).