public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* the redirected stdin/out/err for new console is wrong when the gdb's stdin/out/err is already redirected
@ 2020-09-28 12:21 Roy Qu
  2020-09-28 12:40 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Roy Qu @ 2020-09-28 12:21 UTC (permalink / raw)
  To: gdb-patches

I'm using gdb 9.2 of  mingw.org. (not mingw-w64)
With "set new-console on", gdb will create a new console and run the
debugged program in it.
Commands like "run  < somefile" will redirect STDIN to the input of
'somefile', and the STDOUT should leave to the created console.

but when the gdb is running embedded in some IDE such as Dev-CPP and its
STDIN/STDOUT/STDERR is already redirected into the host IDE,
Console created by commands like "run < somefile" will inherit gdb's
STDOUT/STDERR value and redirect all the output to host IDE too.
(The running result should show in the debugged console, not in the IDE's
debug log window)

So I create a patch to fix it.

--- gdb-9.2-new/gdb/windows-nat.c 2020-07-11 20:13:30.000000000 +0800
+++ gdb-9.2/gdb/windows-nat.c 2020-09-28 20:21:06.515524700 +0800
@@ -2736,20 +2736,20 @@
  si.hStdInput = (HANDLE) _get_osfhandle (fd_inp);
       else if (tty != INVALID_HANDLE_VALUE)
  si.hStdInput = tty;
-      else
- si.hStdInput = GetStdHandle (STD_INPUT_HANDLE);
+      else
+ si.hStdInput = (HANDLE)0;
       if (fd_out >= 0)
  si.hStdOutput = (HANDLE) _get_osfhandle (fd_out);
       else if (tty != INVALID_HANDLE_VALUE)
  si.hStdOutput = tty;
       else
- si.hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE);
+ si.hStdOutput = NULL;
       if (fd_err >= 0)
  si.hStdError = (HANDLE) _get_osfhandle (fd_err);
       else if (tty != INVALID_HANDLE_VALUE)
  si.hStdError = tty;
       else
- si.hStdError = GetStdHandle (STD_ERROR_HANDLE);
+ si.hStdError = NULL;
       si.dwFlags |= STARTF_USESTDHANDLES;
     }

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-10-06 13:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-28 12:21 the redirected stdin/out/err for new console is wrong when the gdb's stdin/out/err is already redirected Roy Qu
2020-09-28 12:40 ` Eli Zaretskii
     [not found]   ` <CAKjWZNWC3ZsR-D8ZPMS5qdhBg5WeWv0p=D9ncdAQua9aKYbSMg@mail.gmail.com>
2020-10-02 12:17     ` Eli Zaretskii
     [not found]       ` <CAKjWZNXxSfSKEcXMfK4P4NJtWtaP0t84k5W1VUEDqX5ofXLa6A@mail.gmail.com>
2020-10-02 14:49         ` Eli Zaretskii
     [not found]           ` <CAKjWZNXKFTKV7SsN066+bY-ocB32EC1gSSwbKO_Nqu9Dj8qzbQ@mail.gmail.com>
2020-10-02 19:50             ` Eli Zaretskii
2020-10-06 13:13               ` Roy Qu

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).