* [PATCH] Fix "set debug timestamp"
@ 2022-12-27 23:36 Tom Tromey
2022-12-28 6:59 ` tdevries
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2022-12-27 23:36 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
PR cli/29945 points out that "set debug timestamp 1" stopped working
-- this is a regression due to commit b8043d27 ("Remove a ui-related
memory leak").
This patch fixes the bug and adds a regression test.
I think this should probably be backported to the gdb 13 branch.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29945
---
gdb/testsuite/gdb.base/timestamp.exp | 24 ++++++++++++++++++++++++
gdb/top.c | 2 +-
2 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 gdb/testsuite/gdb.base/timestamp.exp
diff --git a/gdb/testsuite/gdb.base/timestamp.exp b/gdb/testsuite/gdb.base/timestamp.exp
new file mode 100644
index 00000000000..3d124b450e5
--- /dev/null
+++ b/gdb/testsuite/gdb.base/timestamp.exp
@@ -0,0 +1,24 @@
+# Copyright 2022 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test that timestamps are printed when logging.
+
+clean_restart
+
+# This is a simple way to get logging output.
+gdb_test_no_output "set debug expression 1"
+gdb_test_no_output "set debug timestamp 1"
+
+gdb_test "print 23" "\[0-9\]+\\.\[0-9\]+ Operation: OP_LONG.* = 23"
diff --git a/gdb/top.c b/gdb/top.c
index 565b455a020..91b4e6a3cfe 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -305,7 +305,7 @@ ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_)
m_gdb_stdout (new pager_file (new stdio_file (outstream))),
m_gdb_stdin (new stdio_file (instream)),
m_gdb_stderr (new stderr_file (errstream)),
- m_gdb_stdlog (m_gdb_stderr)
+ m_gdb_stdlog (new timestamped_file (m_gdb_stderr))
{
unbuffer_stream (instream_);
--
2.38.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix "set debug timestamp"
2022-12-27 23:36 [PATCH] Fix "set debug timestamp" Tom Tromey
@ 2022-12-28 6:59 ` tdevries
2022-12-28 17:04 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: tdevries @ 2022-12-28 6:59 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 2022-12-27 23:36, Tom Tromey wrote:
> PR cli/29945 points out that "set debug timestamp 1" stopped working
> -- this is a regression due to commit b8043d27 ("Remove a ui-related
> memory leak").
>
> This patch fixes the bug and adds a regression test.
>
I've applied the patch, ran the regression test without rebuilding and
verified that it failed, then rebuild and verified that it passed.
The code LGTM.
FWIW, I think the regexp could be make more readable using $decimal:
...
-gdb_test "print 23" "\[0-9\]+\\.\[0-9\]+ Operation: OP_LONG.* = 23"
+gdb_test "print 23" "$decimal\\.$decimal Operation: OP_LONG.* = 23"
...
> I think this should probably be backported to the gdb 13 branch.
>
Agreed.
Thanks,
- Tom
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29945
> ---
> gdb/testsuite/gdb.base/timestamp.exp | 24 ++++++++++++++++++++++++
> gdb/top.c | 2 +-
> 2 files changed, 25 insertions(+), 1 deletion(-)
> create mode 100644 gdb/testsuite/gdb.base/timestamp.exp
>
> diff --git a/gdb/testsuite/gdb.base/timestamp.exp
> b/gdb/testsuite/gdb.base/timestamp.exp
> new file mode 100644
> index 00000000000..3d124b450e5
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/timestamp.exp
> @@ -0,0 +1,24 @@
> +# Copyright 2022 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see
> <http://www.gnu.org/licenses/>.
> +
> +# Test that timestamps are printed when logging.
> +
> +clean_restart
> +
> +# This is a simple way to get logging output.
> +gdb_test_no_output "set debug expression 1"
> +gdb_test_no_output "set debug timestamp 1"
> +
> +gdb_test "print 23" "\[0-9\]+\\.\[0-9\]+ Operation: OP_LONG.* = 23"
> diff --git a/gdb/top.c b/gdb/top.c
> index 565b455a020..91b4e6a3cfe 100644
> --- a/gdb/top.c
> +++ b/gdb/top.c
> @@ -305,7 +305,7 @@ ui::ui (FILE *instream_, FILE *outstream_, FILE
> *errstream_)
> m_gdb_stdout (new pager_file (new stdio_file (outstream))),
> m_gdb_stdin (new stdio_file (instream)),
> m_gdb_stderr (new stderr_file (errstream)),
> - m_gdb_stdlog (m_gdb_stderr)
> + m_gdb_stdlog (new timestamped_file (m_gdb_stderr))
> {
> unbuffer_stream (instream_);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix "set debug timestamp"
2022-12-28 6:59 ` tdevries
@ 2022-12-28 17:04 ` Tom Tromey
0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2022-12-28 17:04 UTC (permalink / raw)
To: tdevries; +Cc: Tom Tromey, gdb-patches
> FWIW, I think the regexp could be make more readable using $decimal:
> ...
> -gdb_test "print 23" "\[0-9\]+\\.\[0-9\]+ Operation: OP_LONG.* = 23"
> +gdb_test "print 23" "$decimal\\.$decimal Operation: OP_LONG.* = 23"
I meant to do this and then forgot you'd mentioned it and pushed the
patch. I'm going to fix it on git master now, but I probably won't
bother backporting this to gdb 13. Sorry about that.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-28 17:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-27 23:36 [PATCH] Fix "set debug timestamp" Tom Tromey
2022-12-28 6:59 ` tdevries
2022-12-28 17:04 ` 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).