Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Roy Qu via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: the redirected stdin/out/err for new console is wrong when the gdb's stdin/out/err is already redirected
Date: Mon, 28 Sep 2020 20:21:38 +0800	[thread overview]
Message-ID: <CAKjWZNXYLeQc0mamedvjKMZVmsh_0MMsradzQiVt+sSi6CwnSg@mail.gmail.com> (raw)

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;
     }

             reply	other threads:[~2020-09-28 12:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 12:21 Roy Qu via Gdb-patches [this message]
2020-09-28 12:40 ` Eli Zaretskii via Gdb-patches
     [not found]   ` <CAKjWZNWC3ZsR-D8ZPMS5qdhBg5WeWv0p=D9ncdAQua9aKYbSMg@mail.gmail.com>
2020-10-02 12:17     ` Eli Zaretskii via Gdb-patches
     [not found]       ` <CAKjWZNXxSfSKEcXMfK4P4NJtWtaP0t84k5W1VUEDqX5ofXLa6A@mail.gmail.com>
2020-10-02 14:49         ` Eli Zaretskii via Gdb-patches
     [not found]           ` <CAKjWZNXKFTKV7SsN066+bY-ocB32EC1gSSwbKO_Nqu9Dj8qzbQ@mail.gmail.com>
2020-10-02 19:50             ` Eli Zaretskii via Gdb-patches
2020-10-06 13:13               ` Roy Qu via Gdb-patches

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=CAKjWZNXYLeQc0mamedvjKMZVmsh_0MMsradzQiVt+sSi6CwnSg@mail.gmail.com \
    --to=gdb-patches@sourceware.org \
    --cc=royqh1979@gmail.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