Sasha is working on a real solution for redirecting all of the stdin/out/err file descriptors: https://git.sr.ht/~sasshka/binutils-gdb/log/split_fd But that needs a new gdb that understand the new proposed FdSwitch packet. As a temporary workaround we can at least redirect stdout to stderr (and close stdin) for the inferior (unless --port is used). Something like: /* close stdin */ close (0); /* open /dev/null as new stdin */ open ("/dev/null", O_RDONLY); /* redirect stdout as stderr */ dup2 (2, 1);
Created attachment 161024 [details] gdb --multi mode stdout redirecting to stderr Implementing this is almost trivial, see attached.
commit b35a8ed5a9575dbadb7e2a84bd4b6c4ab9eda21a Author: Mark Wielaard <mark@klomp.org> Date: Thu Aug 17 15:40:30 2023 +0200 gdb --multi mode stdout redirecting to stderr When in stdio mode (talking to gdb through stdin/stdout, not through a socket), redirect stdout to stderr and close stdin for the inferior. That way at least some output can be seen, but there will be no input. This is workaround till we have real terminal handling. * coregrind/vgdb.c (main): Pass in_port to do_multi_mode. (do_multi_mode): Pass in_port to fork_and_exec_valgrind. (fork_and_exec_valgrind): Close stdin, redirect stdout to stderr if in_port <= 0. https://bugs.kde.org/show_bug.cgi?id=471311