From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: Re: [PATCH][gdb] Make INTERP_TUI's default ui_out the INTERP_CONSOLE ui_out
Date: Thu, 05 Sep 2019 12:50:00 -0000 [thread overview]
Message-ID: <2ada25de-fb2f-5866-af4f-892a56007fbc@suse.de> (raw)
In-Reply-To: <20190905095815.GA27717@delia>
[-- Attachment #1: Type: text/plain, Size: 173 bytes --]
Reposting version that applies cleanly on current trunk which includes
the commit 30331a6ca0 "[gdb/testsuite] Restore breakpoint command in
ui-redirect.exp"
Thanks,
- Tom
[-- Attachment #2: 0001-gdb-Make-INTERP_TUI-s-default-ui_out-the-INTERP_CONSOLE-ui_out.patch --]
[-- Type: text/x-patch, Size: 5101 bytes --]
[gdb] Make INTERP_TUI's default ui_out the INTERP_CONSOLE ui_out
When calling the bt command using a user-defined command while logging with
redirect (escaping '#' using '\' for git commit message convenience):
...
$ gdb -q a.out
Reading symbols from a.out...
(gdb) define mybt
Type commands for definition of "mybt".
End with a line saying just "end".
>bt
>end
(gdb) set logging redirect on
(gdb) set logging on
Redirecting output to gdb.txt.
Copying debug output to gdb.txt.
(gdb) start
(gdb) mybt
\#0 main () at hello.c:9
...
we get the bt output (the '#0 main () at hello.c:9' above) in the gdb
output rather than in the log file gdb.txt:
...
$ cat gdb.txt
Temporary breakpoint 1 at 0x40053b: file hello.c, line 9.
Starting program: /data/gdb_versions/devel/a.out
Temporary breakpoint 1, main () at hello.c:9
9 printf ("hello\n");
...
If we do the same using "bt" instead of "mybt", the output does end up in the
log file, and not in the gdb output, as expected.
Also, if we build gdb with --disable-tui, the problem disappears.
The problem is caused by:
- the fact that INTERP_TUI maintains two ui_outs, one for TUI mode disabled
(called the default ui_out) and one for TUI mode enabled, combined with
- the fact that the user-defined commands are interpreted by INTERP_CONSOLE,
which has its own ui_out.
With --disable-tui, the main interpreter is INTERP_CONSOLE, so the logging
redirect is setup for INTERP_CONSOLE's ui_out, and the redirect has effect
when interpreting the mybt command.
With --enable-tui, the main interpreter is INTERP_TUI, so the logging
redirect is setup for INTERP_TUI's default ui_out, and the redirect has no
effect when interpreting the mybt command using INTERP_CONSOLE.
Fix this by making INTERP_TUI's default ui_out the console ui_out.
Tested on x86_64-linux.
gdb/ChangeLog:
2019-09-05 Tom de Vries <tdevries@suse.de>
PR gdb/24956
* tui/tui-io.c (tui_initialize_io): Make default ui_out the console
ui_out.
gdb/testsuite/ChangeLog:
2019-09-05 Tom de Vries <tdevries@suse.de>
PR gdb/24956
* gdb.base/ui-redirect.exp: Test output of user-defined command.
---
gdb/testsuite/gdb.base/ui-redirect.exp | 21 +++++++++++++++++++++
gdb/tui/tui-io.c | 5 ++++-
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/ui-redirect.exp b/gdb/testsuite/gdb.base/ui-redirect.exp
index efcac14b7c..932c74af4b 100644
--- a/gdb/testsuite/gdb.base/ui-redirect.exp
+++ b/gdb/testsuite/gdb.base/ui-redirect.exp
@@ -57,6 +57,24 @@ set cmds "$cmds\n"
set outdir [standard_output_file {}]
set cmds_file "$outdir/cmds.txt"
+with_test_prefix "userdefined" {
+ set test "define userdefined"
+ gdb_test_multiple $test $test {
+ -re "End with a line saying just \"end\"\\.\r\n>$" {
+ pass $test
+ }
+ }
+
+ set test "bt"
+ gdb_test_multiple $test $test {
+ -re "\r\n>$" {
+ pass $test
+ }
+ }
+
+ gdb_test_no_output "end"
+}
+
with_test_prefix "logging" {
gdb_test_no_output "set logging file /dev/null"
gdb_test "set logging on" \
@@ -64,6 +82,7 @@ with_test_prefix "logging" {
gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \
"save breakpoints cmds.txt"
cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
+ gdb_test "userdefined" "#0 main ().*"
gdb_test "set logging off" "Done logging to /dev/null\\."
gdb_test "help" "List of classes of commands:.*"
}
@@ -74,6 +93,7 @@ with_test_prefix "redirect" {
"Redirecting output to /dev/null.*Copying debug output to /dev/null\\."
gdb_test_no_output "save breakpoints $cmds_file" "save breakpoints cmds.txt"
cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
+ gdb_test_no_output "userdefined"
gdb_test "set logging off" "Done logging to /dev/null\\."
gdb_test "help" "List of classes of commands:.*"
}
@@ -87,6 +107,7 @@ with_test_prefix "redirect while already logging" {
gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \
"save breakpoints cmds.txt"
cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
+ gdb_test "userdefined" "#0 main ().*"
gdb_test "set logging off" "Done logging to /dev/null\\."
gdb_test "help" "List of classes of commands:.*"
gdb_test_no_output "set logging redirect off"
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index ee581a2ff6..eab894325a 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -43,6 +43,7 @@
#include "gdbsupport/filestuff.h"
#include "completer.h"
#include "gdb_curses.h"
+#include "interps.h"
#include <map>
/* This redefines CTRL if it is not already defined, so it must come
@@ -870,7 +871,9 @@ tui_initialize_io (void)
tui_out = tui_out_new (tui_stdout);
/* Create the default UI. */
- tui_old_uiout = cli_out_new (gdb_stdout);
+ struct interp *interp = interp_lookup (current_ui, "console");
+ tui_old_uiout = dynamic_cast<cli_ui_out *> (interp->interp_ui_out());
+ gdb_assert (tui_old_uiout != nullptr);
#ifdef TUI_USE_PIPE_FOR_READLINE
/* Temporary solution for readline writing to stdout: redirect
next prev parent reply other threads:[~2019-09-05 12:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-05 9:58 Tom de Vries
2019-09-05 12:50 ` Tom de Vries [this message]
2019-09-24 15:24 ` [PING][PATCH][gdb] " Tom de Vries
2019-09-24 17:31 ` [PATCH][gdb] " Andrew Burgess
2019-09-24 23:20 ` Tom de Vries
2019-09-25 8:36 ` Andrew Burgess
2019-10-01 12:59 ` Tom de Vries
2019-10-03 10:01 ` [PATCH][gdb] Only force INTERP_CONSOLE ui_out for breakpoint commands in MI mode Tom de Vries
2019-10-03 12:11 ` Pedro Alves
2019-10-03 13:51 ` Tom de Vries
2019-10-03 14:02 ` Pedro Alves
2019-11-11 16:27 ` Joel Brobecker
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=2ada25de-fb2f-5866-af4f-892a56007fbc@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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