public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: make timestamped_file implement can_emit_style_escape
@ 2022-03-31 17:32 Simon Marchi
  2022-04-04 16:52 ` Tom Tromey
  0 siblings, 1 reply; 9+ messages in thread
From: Simon Marchi @ 2022-03-31 17:32 UTC (permalink / raw)
  To: gdb-patches

In our AMDGPU downstream port, we use styling in some logging output.
We noticed it stopped working after the gdb_printf changes.  Making
timestamped_file implement can_emit_style_escape (returning the value of
the stream it wraps) fixes it.  To show that it works, modify some
logging statements in auto-load.c to output style filenames.  You can
see it in action by setting "set debug auto-load 1" and running a
program.  We can incrementally add styling to other debug statements
throughout GDB, as needed.

Change-Id: I78a2fd1e078f80f2263251cf6bc53b3a9de9c17a
---
 gdb/auto-load.c | 9 +++++----
 gdb/ui-file.h   | 3 +++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 057104d97b08..b6056f5d60a9 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -733,8 +733,8 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname,
   gdb_file_up input = gdb_fopen_cloexec (filename.c_str (), "r");
   debugfile = filename.c_str ();
 
-  auto_load_debug_printf ("Attempted file \"%s\" %s.",
-			  debugfile,
+  auto_load_debug_printf ("Attempted file \"%ps\" %s.",
+			  styled_string (file_name_style.style (), debugfile),
 			  input != nullptr ? "exists" : "does not exist");
 
   std::string debugfile_holder;
@@ -763,8 +763,9 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname,
 
 	  input = gdb_fopen_cloexec (debugfile, "r");
 
-	  auto_load_debug_printf ("Attempted file \"%s\" %s.",
-				  debugfile,
+	  auto_load_debug_printf ("Attempted file \"%ps\" %s.",
+				  styled_string (file_name_style.style (),
+						 debugfile),
 				  (input != nullptr
 				   ? "exists"
 				   : "does not exist"));
diff --git a/gdb/ui-file.h b/gdb/ui-file.h
index f8e1fe8be3c2..e420555b8a6d 100644
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -402,6 +402,9 @@ class timestamped_file : public ui_file
   {
   }
 
+  bool can_emit_style_escape () override
+  { return m_stream->can_emit_style_escape (); }
+
   DISABLE_COPY_AND_ASSIGN (timestamped_file);
 
   void write (const char *buf, long len) override;

base-commit: 0653f01479ecbcbf3c4dfa6083187a5b2c2258c2
-- 
2.35.1


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

end of thread, other threads:[~2022-04-05 20:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 17:32 [PATCH] gdb: make timestamped_file implement can_emit_style_escape Simon Marchi
2022-04-04 16:52 ` Tom Tromey
2022-04-04 21:58   ` Simon Marchi
2022-04-04 22:02     ` Simon Marchi
2022-04-05 14:25       ` Tom Tromey
2022-04-05 14:36         ` Simon Marchi
2022-04-05 20:54           ` Tom Tromey
2022-04-05 18:28         ` Pedro Alves
2022-04-05 20:54           ` Tom Tromey

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).