Subject: Re: bug#69795: 29.1; cmdproxy.exe exits automatically after executing MSYS2 commands

From: [email-masked]
Date: Sat, 16 Mar 2024 12:52:19 +0900

Eli Zaretskii <[email-masked]> writes:

>> From: [email-masked]
>> Cc: [email-masked]
>> Date: Fri, 15 Mar 2024 21:10:06 +0900
>> 
>> > Doesn't MSYS2 provide a MinGW64 build of GDB, not just an MSYS build?
>> > GDB builds natively with MinGW tools, so there should be no problem
>> > for MSYS2 folks to provide a native 64-bit Windows build of GDB.
>> 
>> I have installed mingw64/mingw-w64-x86_64-gdb.
>> I think it is MinGW64 binary.
>
> Yes.  But then all the discussion around MSYS2 programs is not
> relevant to this issue.
>
>> But gdb.exe sometimes make cmdproxy.exe exit, and sometimes not.
>
> So let's start from the beginning: can you show a recipe, starting
> from "emacs -Q", where you invoke GDB from Emacs, and cmdproxy (or
> some other sub-process) exits?

I found that setting PATH make the difference.
Start emacs -Q, type 'M-x shell RET',
and input following command lines.
  set PATH=c:\msys64\mingw64\bin\;c:\msys64\usr\bin\;%PATH%
  c:\msys64\mingw64\bin\gdb.exe
  q
Then cmdproxy.exe exits automatically.
Here is a log.
  Microsoft Windows [Version 10.0.19045.4170]
  (c) Microsoft Corporation. All rights reserved.
  
  c:\tmp>set PATH=c:\msys64\mingw64\bin\;c:\msys64\usr\bin\;%PATH%
  set PATH=c:\msys64\mingw64\bin\;c:\msys64\usr\bin\;%PATH%
  
  c:\tmp>c:\msys64\mingw64\bin\gdb.exe
  c:\msys64\mingw64\bin\gdb.exe
  GNU gdb (GDB) 13.2
  Copyright (C) 2023 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.
  Type "show copying" and "show warranty" for details.
  This GDB was configured as "x86_64-w64-mingw32".
  Type "show configuration" for configuration details.
  For bug reporting instructions, please see:
  <https://www.gnu.org/software/gdb/bugs/>.
  Find the GDB manual and other documentation resources online at:
      <http://www.gnu.org/software/gdb/documentation/>.
  
  For help, type "help".
  Type "apropos word" to search for commands related to "word".
  (gdb) q
  
  c:\tmp>
  Process shell finished

> Also, did you look at this discussion to which I pointed:
>
>     https://lists.gnu.org/archive/html/emacs-devel/2023-01/msg00242.html
>
> It's possible that the process-send-eof mentioned there is somehow
> involved in what you see.

Redefining #'comint-simple-send to remove #'process-send-eof,
cmdproxy.exe behaves same, exits automatically.
  (defun comint-simple-send (proc string)
    "Default function for sending to PROC input STRING.
  This just sends STRING plus a newline.  To override this,
  set the hook `comint-input-sender'."
    (let ((send-string
           (if comint-input-sender-no-newline
               string
             ;; Sending as two separate strings does not work
             ;; on Windows, so concat the \n before sending.
             (concat string "\n"))))
      (comint-send-string proc send-string)))

>> Here is a list of gdb packages.
>
> That's a large list.  Are you using GDB for debugging native Windows
> programs, or are you using it for debugging other executables (like
> ARM or AVR) via gdbserver?  Which of these packages do you actually
> have installed and are using?

They are available package names.
I have installed only one of them, which is marked as [installed].
I am not sure which is best.