From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 9D21E3857C42; Mon, 4 Apr 2022 21:58:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D21E3857C42 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: make timestamped_file implement can_emit_style_escape X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: cb25fdbb76e41d9c02fe86009fc8a3ecf8737c9a X-Git-Newrev: 962937b15dd570e44109f3c8196a392b788837ba Message-Id: <20220404215853.9D21E3857C42@sourceware.org> Date: Mon, 4 Apr 2022 21:58:53 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Apr 2022 21:58:53 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D962937b15dd5= 70e44109f3c8196a392b788837ba commit 962937b15dd570e44109f3c8196a392b788837ba Author: Simon Marchi Date: Thu Mar 31 13:32:20 2022 -0400 gdb: make timestamped_file implement can_emit_style_escape =20 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. =20 Change-Id: I78a2fd1e078f80f2263251cf6bc53b3a9de9c17a Diff: --- 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 057104d97b0..b6056f5d60a 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -733,8 +733,8 @@ auto_load_objfile_script_1 (struct objfile *objfile, co= nst char *realname, gdb_file_up input =3D gdb_fopen_cloexec (filename.c_str (), "r"); debugfile =3D filename.c_str (); =20 - 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 !=3D nullptr ? "exists" : "does not exist"); =20 std::string debugfile_holder; @@ -763,8 +763,9 @@ auto_load_objfile_script_1 (struct objfile *objfile, co= nst char *realname, =20 input =3D gdb_fopen_cloexec (debugfile, "r"); =20 - 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 !=3D nullptr ? "exists" : "does not exist")); diff --git a/gdb/ui-file.h b/gdb/ui-file.h index f8e1fe8be3c..e420555b8a6 100644 --- a/gdb/ui-file.h +++ b/gdb/ui-file.h @@ -402,6 +402,9 @@ public: { } =20 + bool can_emit_style_escape () override + { return m_stream->can_emit_style_escape (); } + DISABLE_COPY_AND_ASSIGN (timestamped_file); =20 void write (const char *buf, long len) override;