public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Make ui_out::do_progress_end 'private'
Date: Thu, 16 Mar 2023 13:37:41 -0600	[thread overview]
Message-ID: <20230316193741.3804125-1-tromey@adacore.com> (raw)

I noticed that ui_out::do_progress_end is public, just to support one
use in debuginfod-support.c.  This patch makes it private, updates
progress_info to call it from its destructor, and finally changes
debuginfod-support.c to follow.
---
 gdb/debuginfod-support.c | 101 ++++++++++++++++++++++-----------------
 gdb/ui-out.h             |   8 ++--
 2 files changed, 61 insertions(+), 48 deletions(-)

diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 04d254a1601..5853f420a18 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -261,16 +261,13 @@ debuginfod_is_enabled ()
 /* Print the result of the most recent attempted download.  */
 
 static void
-print_outcome (user_data &data, int fd)
+print_outcome (int fd, const char *desc, const char *fname)
 {
-  /* Clears the current line of progress output.  */
-  current_uiout->do_progress_end ();
-
   if (fd < 0 && fd != -ENOENT)
     gdb_printf (_("Download failed: %s.  Continuing without %s %ps.\n"),
 		safe_strerror (-fd),
-		data.desc,
-		styled_string (file_name_style.style (), data.fname));
+		desc,
+		styled_string (file_name_style.style (), fname));
 }
 
 /* See debuginfod-support.h  */
@@ -290,23 +287,28 @@ debuginfod_source_query (const unsigned char *build_id,
     return scoped_fd (-ENOMEM);
 
   char *dname = nullptr;
-  user_data data ("source file", srcpath);
-
-  debuginfod_set_user_data (c, &data);
+  scoped_fd fd;
   gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
-  if (target_supports_terminal_ours ())
-    {
-      term_state.emplace ();
-      target_terminal::ours ();
-    }
 
-  scoped_fd fd (debuginfod_find_source (c,
-					build_id,
-					build_id_len,
-					srcpath,
-					&dname));
-  debuginfod_set_user_data (c, nullptr);
-  print_outcome (data, fd.get ());
+  {
+    user_data data ("source file", srcpath);
+
+    debuginfod_set_user_data (c, &data);
+    if (target_supports_terminal_ours ())
+      {
+	term_state.emplace ();
+	target_terminal::ours ();
+      }
+
+    fd = scoped_fd (debuginfod_find_source (c,
+					    build_id,
+					    build_id_len,
+					    srcpath,
+					    &dname));
+    debuginfod_set_user_data (c, nullptr);
+  }
+
+  print_outcome (fd.get (), "source file", srcpath);
 
   if (fd.get () >= 0)
     destname->reset (dname);
@@ -331,20 +333,25 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
     return scoped_fd (-ENOMEM);
 
   char *dname = nullptr;
-  user_data data ("separate debug info for", filename);
-
-  debuginfod_set_user_data (c, &data);
+  scoped_fd fd;
   gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
-  if (target_supports_terminal_ours ())
-    {
-      term_state.emplace ();
-      target_terminal::ours ();
-    }
 
-  scoped_fd fd (debuginfod_find_debuginfo (c, build_id, build_id_len,
-					   &dname));
-  debuginfod_set_user_data (c, nullptr);
-  print_outcome (data, fd.get ());
+  {
+    user_data data ("separate debug info for", filename);
+
+    debuginfod_set_user_data (c, &data);
+    if (target_supports_terminal_ours ())
+      {
+	term_state.emplace ();
+	target_terminal::ours ();
+      }
+
+    fd = scoped_fd (debuginfod_find_debuginfo (c, build_id, build_id_len,
+					       &dname));
+    debuginfod_set_user_data (c, nullptr);
+  }
+
+  print_outcome (fd.get (), "separate debug info for", filename);
 
   if (fd.get () >= 0)
     destname->reset (dname);
@@ -369,19 +376,25 @@ debuginfod_exec_query (const unsigned char *build_id,
     return scoped_fd (-ENOMEM);
 
   char *dname = nullptr;
-  user_data data ("executable for", filename);
-
-  debuginfod_set_user_data (c, &data);
+  scoped_fd fd;
   gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
-  if (target_supports_terminal_ours ())
-    {
-      term_state.emplace ();
-      target_terminal::ours ();
-    }
 
-  scoped_fd fd (debuginfod_find_executable (c, build_id, build_id_len, &dname));
-  debuginfod_set_user_data (c, nullptr);
-  print_outcome (data, fd.get ());
+  {
+    user_data data ("executable for", filename);
+
+    debuginfod_set_user_data (c, &data);
+    if (target_supports_terminal_ours ())
+      {
+	term_state.emplace ();
+	target_terminal::ours ();
+      }
+
+    fd = scoped_fd (debuginfod_find_executable (c, build_id, build_id_len,
+						&dname));
+    debuginfod_set_user_data (c, nullptr);
+  }
+
+  print_outcome (fd.get (), "executable for", filename);
 
   if (fd.get () >= 0)
     destname->reset (dname);
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index c7ae6698bbf..ba5b1de68ab 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -302,7 +302,7 @@ class ui_out
 
     ~progress_update ()
     {
-
+      m_uiout->do_progress_end ();
     }
 
     progress_update (const progress_update &) = delete;
@@ -321,14 +321,13 @@ class ui_out
     {
       m_uiout->do_progress_notify (msg, "", -1, -1);
     }
+
   private:
 
     struct ui_out *m_uiout;
   };
 
-  virtual void do_progress_end () = 0;
-
- protected:
+protected:
 
   virtual void do_table_begin (int nbrofcols, int nr_rows, const char *tblid)
     = 0;
@@ -365,6 +364,7 @@ class ui_out
   virtual void do_progress_start () = 0;
   virtual void do_progress_notify (const std::string &, const char *,
 				   double, double) = 0;
+  virtual void do_progress_end () = 0;
 
   /* Set as not MI-like by default.  It is overridden in subclasses if
      necessary.  */
-- 
2.39.1


             reply	other threads:[~2023-03-16 19:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16 19:37 Tom Tromey [this message]
2023-03-17 22:20 ` Kevin Buettner

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=20230316193741.3804125-1-tromey@adacore.com \
    --to=tromey@adacore.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).