* [PATCH 0/2] Send trace-commands output to gdb_stdlog
@ 2026-06-02 17:51 Tom Tromey
2026-06-02 17:51 ` [PATCH 1/2] Boolify suppress_next_print_command_trace Tom Tromey
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tom Tromey @ 2026-06-02 17:51 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This short series is a cleanup plus a patch to send the trace-commands
output to gdb_stdlog. See the second patch for the rationale.
Regression tested on x86-64 Fedora 43.
Signed-off-by: Tom Tromey <tromey@adacore.com>
---
Tom Tromey (2):
Boolify suppress_next_print_command_trace
Print command trace to gdb_stdlog
gdb/cli/cli-script.c | 18 ++++++++----------
gdb/testsuite/gdb.base/ui-redirect.exp | 6 ++++++
2 files changed, 14 insertions(+), 10 deletions(-)
---
base-commit: ad6e2895e419d17ffa0803e69a89db12b5b75298
change-id: 20260602-cmd-trace-logging-7316aee8b2a4
Best regards,
--
Tom Tromey <tromey@adacore.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] Boolify suppress_next_print_command_trace
2026-06-02 17:51 [PATCH 0/2] Send trace-commands output to gdb_stdlog Tom Tromey
@ 2026-06-02 17:51 ` Tom Tromey
2026-06-02 17:51 ` [PATCH 2/2] Print command trace to gdb_stdlog Tom Tromey
2026-06-18 16:48 ` [PATCH 0/2] Send trace-commands output " Tom Tromey
2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2026-06-02 17:51 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This changes suppress_next_print_command_trace to use bool.
---
gdb/cli/cli-script.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index e081f0454b3..b8312f431cb 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -62,7 +62,7 @@ static int control_level;
static int command_nest_depth = 1;
/* This is to prevent certain commands being printed twice. */
-static int suppress_next_print_command_trace = 0;
+static bool suppress_next_print_command_trace = false;
/* Command element for the 'while' command. */
static cmd_list_element *while_cmd_element = nullptr;
@@ -471,7 +471,7 @@ reset_command_nest_depth (void)
command_nest_depth = 1;
/* Just in case. */
- suppress_next_print_command_trace = 0;
+ suppress_next_print_command_trace = false;
}
/* Print the command, prefixed with '+' to represent the call depth.
@@ -490,7 +490,7 @@ print_command_trace (const char *fmt, ...)
if (suppress_next_print_command_trace)
{
- suppress_next_print_command_trace = 0;
+ suppress_next_print_command_trace = false;
return;
}
@@ -720,7 +720,7 @@ execute_control_command (struct command_line *cmd, int from_tty)
enum command_control_type
execute_control_command_untraced (struct command_line *cmd)
{
- suppress_next_print_command_trace = 1;
+ suppress_next_print_command_trace = true;
return execute_control_command (cmd);
}
--
2.54.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] Print command trace to gdb_stdlog
2026-06-02 17:51 [PATCH 0/2] Send trace-commands output to gdb_stdlog Tom Tromey
2026-06-02 17:51 ` [PATCH 1/2] Boolify suppress_next_print_command_trace Tom Tromey
@ 2026-06-02 17:51 ` Tom Tromey
2026-06-18 16:48 ` [PATCH 0/2] Send trace-commands output " Tom Tromey
2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2026-06-02 17:51 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
I recently wanted to enable some gdb logging when running the internal
AdaCore test suite. To do this nicely, I enable debug-redirect early
in the test, so that the logging output does not affect the test
results.
I also wanted to the log the commands, to correlate what I see in the
debug log with what I see in the ordinary test suite log file (which
is basically like our own gdb.log).
However, I found that "set trace-commands on" will log to stdout, not
stdlog. This patch changes this to log to the log file instead.
---
gdb/cli/cli-script.c | 10 ++++------
gdb/testsuite/gdb.base/ui-redirect.exp | 6 ++++++
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index b8312f431cb..0a1208845b4 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -486,8 +486,6 @@ ATTRIBUTE_PRINTF (1, 2)
void
print_command_trace (const char *fmt, ...)
{
- int i;
-
if (suppress_next_print_command_trace)
{
suppress_next_print_command_trace = false;
@@ -497,15 +495,15 @@ print_command_trace (const char *fmt, ...)
if (!source_verbose && !trace_commands)
return;
- for (i=0; i < command_nest_depth; i++)
- gdb_printf ("+");
+ for (int i = 0; i < command_nest_depth; ++i)
+ gdb_printf (gdb_stdlog, "+");
va_list args;
va_start (args, fmt);
- gdb_vprintf (fmt, args);
+ gdb_vprintf (gdb_stdlog, fmt, args);
va_end (args);
- gdb_puts ("\n");
+ gdb_puts ("\n", gdb_stdlog);
}
/* Helper for execute_control_command. */
diff --git a/gdb/testsuite/gdb.base/ui-redirect.exp b/gdb/testsuite/gdb.base/ui-redirect.exp
index c1cb461496b..64007276b17 100644
--- a/gdb/testsuite/gdb.base/ui-redirect.exp
+++ b/gdb/testsuite/gdb.base/ui-redirect.exp
@@ -135,6 +135,12 @@ with_test_prefix "redirect debugging" {
"Copying output to /dev/null.*Redirecting debug output to /dev/null\\."
gdb_test "continue" "Continuing.*((?!infrun).).*Breakpoint ${::decimal}, bar.*"
gdb_test "set debug infrun 0"
+
+ # The trace should be sent to the log, not stdout.
+ gdb_test_no_output "set trace-commands on"
+ gdb_test_no_output {printf ""}
+ gdb_test_no_output "set trace-commands off"
+
gdb_test "set logging enabled off" "Done logging to /dev/null\\."
gdb_test "help" "List of classes of commands:.*"
}
--
2.54.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Send trace-commands output to gdb_stdlog
2026-06-02 17:51 [PATCH 0/2] Send trace-commands output to gdb_stdlog Tom Tromey
2026-06-02 17:51 ` [PATCH 1/2] Boolify suppress_next_print_command_trace Tom Tromey
2026-06-02 17:51 ` [PATCH 2/2] Print command trace to gdb_stdlog Tom Tromey
@ 2026-06-18 16:48 ` Tom Tromey
2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2026-06-18 16:48 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:
Tom> This short series is a cleanup plus a patch to send the trace-commands
Tom> output to gdb_stdlog. See the second patch for the rationale.
I'm checking these in.
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-18 16:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-02 17:51 [PATCH 0/2] Send trace-commands output to gdb_stdlog Tom Tromey
2026-06-02 17:51 ` [PATCH 1/2] Boolify suppress_next_print_command_trace Tom Tromey
2026-06-02 17:51 ` [PATCH 2/2] Print command trace to gdb_stdlog Tom Tromey
2026-06-18 16:48 ` [PATCH 0/2] Send trace-commands output " Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox