From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 42A923858039; Thu, 3 Mar 2022 18:19:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42A923858039 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Takashi Yano To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: pty: Stop to use PID_NEW_PG flag as a marker for GDB. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: efd153853c44876cceb430a0cc1a1a94e2067c96 X-Git-Newrev: 261acf73188bafafe8b59d8db7e8edeb940dac23 Message-Id: <20220303181950.42A923858039@sourceware.org> Date: Thu, 3 Mar 2022 18:19:50 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Mar 2022 18:19:50 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D261acf73188= bafafe8b59d8db7e8edeb940dac23 commit 261acf73188bafafe8b59d8db7e8edeb940dac23 Author: Takashi Yano Date: Thu Mar 3 11:43:07 2022 +0900 Cygwin: pty: Stop to use PID_NEW_PG flag as a marker for GDB. =20 - Previously, the PID_NEW_PG flag was also used as a marker for GDB with non-cygwin inferior, unlike its original meaning. With this patch, the condition exec_dwProcessId =3D=3D dwProcessId is used as a marker for that instead. Diff: --- winsup/cygwin/fhandler_termios.cc | 14 +++++++------- winsup/cygwin/fhandler_tty.cc | 11 ++++++----- winsup/cygwin/tty.cc | 4 +++- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_ter= mios.cc index 3740ba011..5cd44d7bf 100644 --- a/winsup/cygwin/fhandler_termios.cc +++ b/winsup/cygwin/fhandler_termios.cc @@ -341,15 +341,16 @@ fhandler_termios::process_sigs (char c, tty* ttyp, fh= andler_termios *fh) { _pinfo *p =3D pids[i]; /* PID_NOTCYGWIN: check this for non-cygwin process. - PID_NEW_PG: check this ofr GDB with non-cygwin inferior in pty + exec_dwProcessId =3D=3D dwProcessId: + check this for GDB with non-cygwin inferior in pty without pcon enabled. In this case, the inferior is not - cygwin process list. PID_NEW_PG is set as a marker for - GDB with non-cygwin inferior in pty code. + cygwin process list. This condition is set true as + a marker for GDB with non-cygwin inferior in pty code. !PID_CYGPARENT: check this for GDB with cygwin inferior or cygwin apps started from non-cygwin shell. */ if (c =3D=3D '\003' && p && p->ctty =3D=3D ttyp->ntty && p->pgid =3D= =3D pgid && ((p->process_state & PID_NOTCYGWIN) - || (p->process_state & PID_NEW_PG) + || (p->exec_dwProcessId =3D=3D p->dwProcessId) || !(p->process_state & PID_CYGPARENT))) { /* Ctrl-C event will be sent only to the processes attaching @@ -369,8 +370,7 @@ fhandler_termios::process_sigs (char c, tty* ttyp, fhan= dler_termios *fh) /* CTRL_C_EVENT does not work for the process started with CREATE_NEW_PROCESS_GROUP flag, so send CTRL_BREAK_EVENT instead. */ - if ((p->process_state & PID_NEW_PG) - && (p->process_state & PID_NOTCYGWIN)) + if (p->process_state & PID_NEW_PG) GenerateConsoleCtrlEvent (CTRL_BREAK_EVENT, p->dwProcessId); else if ((!fh || fh->need_send_ctrl_c_event () || cyg_leader) && !ctrl_c_event_sent) /* cyg_leader is needed by GDB @@ -405,7 +405,7 @@ fhandler_termios::process_sigs (char c, tty* ttyp, fhan= dler_termios *fh) && (p->process_state & PID_DEBUGGED)) with_debugger =3D true; /* inferior is cygwin app */ if (!(p->process_state & PID_NOTCYGWIN) - && (p->process_state & PID_NEW_PG) /* Check marker */ + && (p->exec_dwProcessId =3D=3D p->dwProcessId) /* Check marker */ && p->pid =3D=3D pgid) with_debugger_nat =3D true; /* inferior is non-cygwin app */ } diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index c7588a073..3332fefd6 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -116,8 +116,9 @@ fhandler_pty_common::get_console_process_id (DWORD pid,= bool match, return res_pri ?: res; } =20 -static bool isHybrid; /* Set true if the active pipe is set to nat pipe ev= en - though the current process is a cygwin process. */ +static bool isHybrid; /* Set true if the active pipe is set to nat pipe + owned by myself even though the current process + is a cygwin process. */ static HANDLE h_gdb_inferior; /* Handle of GDB inferior process. */ =20 static void @@ -1079,8 +1080,9 @@ fhandler_pty_slave::set_switch_to_nat_pipe (void) { isHybrid =3D true; setup_locale (); - myself->exec_dwProcessId =3D myself->dwProcessId; - myself->process_state |=3D PID_NEW_PG; /* Marker for nat_fg */ + myself->exec_dwProcessId =3D myself->dwProcessId; /* Set this as a m= arker + for tty::nat_fg() + and process_sigs() */ bool stdin_is_ptys =3D GetStdHandle (STD_INPUT_HANDLE) =3D=3D get_ha= ndle (); setup_for_non_cygwin_app (false, NULL, stdin_is_ptys); } @@ -1199,7 +1201,6 @@ fhandler_pty_slave::reset_switch_to_nat_pipe (void) } } myself->exec_dwProcessId =3D 0; - myself->process_state &=3D ~PID_NEW_PG; isHybrid =3D false; } } diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc index b2218fef7..60f4a602a 100644 --- a/winsup/cygwin/tty.cc +++ b/winsup/cygwin/tty.cc @@ -342,7 +342,9 @@ tty::nat_fg (pid_t pgid) { _pinfo *p =3D pids[i]; if (p->ctty =3D=3D ntty && p->pgid =3D=3D pgid - && (p->process_state & (PID_NOTCYGWIN | PID_NEW_PG))) + && ((p->process_state & PID_NOTCYGWIN) + /* Below is true for GDB with non-cygwin inferior */ + || p->exec_dwProcessId =3D=3D p->dwProcessId)) return true; } if (pgid > MAX_PID)