From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juan =?utf-8?Q?Jos=C3=A9_Garc=C3=ADa-Ripoll?= Newsgroups: gmane.emacs.devel Subject: Re: gdb fails to flush output (msys2) Date: Mon, 14 Mar 2022 18:55:55 +0100 Organization: Institute of Fundamental Physics, CSIC Message-ID: <867d8wa05w.fsf@csic.es> References: <86y21caikh.fsf@csic.es> <83o828k6a7.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27468"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (windows-nt) To: emacs-devel@gnu.org Cancel-Lock: sha1:AQkYRAHdWL0KLBU0mz5v1j7fsmw= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Mar 14 19:01:37 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nTp0i-0006xm-G7 for ged-emacs-devel@m.gmane-mx.org; Mon, 14 Mar 2022 19:01:36 +0100 Original-Received: from localhost ([::1]:49364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nTp0h-0002k2-DS for ged-emacs-devel@m.gmane-mx.org; Mon, 14 Mar 2022 14:01:35 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:43794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTovO-0000oy-Uv for emacs-devel@gnu.org; Mon, 14 Mar 2022 13:56:07 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]:38164) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTovN-0002Xv-5I for emacs-devel@gnu.org; Mon, 14 Mar 2022 13:56:06 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1nTovJ-000AOe-SB for emacs-devel@gnu.org; Mon, 14 Mar 2022 18:56:01 +0100 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:287160 Archived-At: Eli Zaretskii writes: >> I am trying to debug some programs on Windows using MSYS2. > > What do you mean by "using MSYS2" here? MSYS2 is the open source software distribution that replaces cygwin in providing a unix-like experience in Windows. I am using MSYS2 and the Mingw64, UCRT64 and Clang-based toolchains to develop, compile and now debug software. >> In doing so, I noticed that the gdb mode is not working well with >> the output from the debugger. > > By "gdb mode", do you mean the result of "M-x gdb", followed by > specifying the GDB command line to debug a program? If so, what was > the GDB command line you used? Yes, as stated in my script, I invoke Emacs's "gdb" function programatically supplying it with a command line that is essentially "c:/msys64/ucrt64/bin/gdb.exe -i=mi /path/to/my.exe" I have also tried invoking it interactively with similar success. The script I provided is a bit more clear in the choice of system and paths. > What program are you debugging? Is it a native MS-Windows > (a.k.a. "MinGW") program, or is it an MSYS2 program that depends on > the MSYS DLL? Also, is it a console program or something else, like a > program using curses or some other unusual methods of writing to the > screen? I am debugging applications built using cmake + g++ natively (MinGW with either ucrt64 or older runtimes). They are all console applications. Launching the debugger from a terminal works for the same application, but, of course, I lose integration with Emacs. > What happens if you manually add "C:/msys64/ucrt64/bin" to PATH > outside of Emacs, and then invoke GDB from the Windows Command Prompt > window to debug that same program -- does that work as expected? I prefer not to add MSYS2 + Mingw/Ucrt64 to the path because it collides with various tools and because I want to be able to use different toolchains, which does not work if I set the path to point to those environments (this is what project-cmake automates) This said, another way to reproduce this issue is to open a Mingw64/Ucrt64 native console, launch emacs from that console and invoke M-x gdb. The debugger still stops after launching the initial threads, hiding the remaining console output, as shown below. I verified that the problem exists with both ucrt64 and mingw64 runtimes. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from c:/home/juanjo/src/tensor/build-msys2-ucrt64/tests/test_rand.exe... (gdb) run Starting program: c:\home\juanjo\src\tensor\build-msys2-ucrt64\tests\test_rand.exe [New Thread 9944.0x1a28] [New Thread 9944.0x28c0] [New Thread 9944.0x3a00] <--- Here it stops. If I press it shows the console output. -- Juan José García Ripoll http://juanjose.garciaripoll.com http://quinfog.hbar.es