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: Tue, 15 Mar 2022 14:24:15 +0100 Message-ID: <86y21btklc.fsf@csic.es> References: <86y21caikh.fsf@csic.es> <83o828k6a7.fsf@gnu.org> <867d8wa05w.fsf@csic.es> <837d8wjsur.fsf@gnu.org> <834k40js23.fsf@gnu.org> <86h77zwn9b.fsf@csic.es> <77bec550-18e8-bcb9-0d32-b023f01eb3a4@secure.kjonigsen.net> 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="15219"; 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:LcLyyOYTrR7g91tQpOA1VmmIoVE= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 15 14:27:05 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 1nU7Ca-0003ow-Qh for ged-emacs-devel@m.gmane-mx.org; Tue, 15 Mar 2022 14:27:04 +0100 Original-Received: from localhost ([::1]:38934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nU7CZ-0001V5-LY for ged-emacs-devel@m.gmane-mx.org; Tue, 15 Mar 2022 09:27:03 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:38732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nU7A2-0005i1-QI for emacs-devel@gnu.org; Tue, 15 Mar 2022 09:24:28 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]:35210) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nU7A0-0004rP-ML for emacs-devel@gnu.org; Tue, 15 Mar 2022 09:24:26 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1nU79x-000AdE-5S for emacs-devel@gnu.org; Tue, 15 Mar 2022 14:24:21 +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:287181 Archived-At: I am not sure this has to do with using spawn() which IMHO would also benefit Windows as compared to faking fork(). To confirm this, I have run emacs and gdb inside Process Explorer. Just before I enter "run" in the "gdb" window, Process Explorer shows a total of 30kb written by gdb, while after my process is finished it shows 32kb. Those extra 2kb are not shown by Emacs. Below I show a complete interaction consisting on four steps: (1) launch gdb with M-x gdb, supplying "c:/msys64/ucrt64/bin/gdb -i=mi c:/home/juanjo/src/tensor/build-msys2-ucrt64/tests/test_rand.exe", (2) enter "run" + enter in gdb, (3) press again , (4) press , (5) type "quit" follwed by . Note how Emacs fails to show me the output of the debugger and interprets a single as pressing "run" again. Between steps (1) and (2), Process Explorer shows 2k of written data, after (3) it shows another 2k. Current directory is c:/home/juanjo/src/tensor/build-msys2-ucrt64/tests/ GNU gdb (GDB) 11.1 Copyright (C) 2021 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later 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: . Find the GDB manual and other documentation resources online at: . 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 <<<< Step (2) Starting program: c:\home\juanjo\src\tensor\build-msys2-ucrt64\tests\test_rand.exe [New Thread 17312.0x144c] [New Thread 17312.0x1f28] [New Thread 17312.0x4d0] <<< Step (3), press [[----------] Global test environment set-up. [----------] 10 tests from RandTest [ RUN ] RandTest.IntSize [ OK ] RandTest.IntSize (0 ms) [ RUN ] RandTest.LongSize [ OK ] RandTest.LongSize (0 ms) [ RUN ] RandTest.Reseed [ OK ] RandTest.Reseed (1 ms) [ RUN ] RandTest.DoubleBalanced [ OK ] RandTest.DoubleBalanced (0 ms) [ RUN ] RandTest.DoubleSigma [ OK ] RandTest.DoubleSigma (1 ms) [ RUN ] RandTest.ComplexBalanced [ OK ] RandTest.ComplexBalanced (1 ms) [ RUN ] RandTest.ComplexUncorrelated [ OK ] RandTest.ComplexUncorrelated (0 ms) [ RUN ] RandTest.IntEmpty [ OK ] RandTest.IntEmpty (0 ms) [ RUN ] RandTest.LongEmpty [ OK ] RandTest.LongEmpty (0 ms) [ RUN ] RandTest.ULongEmpty [ OK ] RandTest.ULongEmpty (0 ms) [----------] 10 tests from RandTest (3 ms total) [----------] Global test environment tear-down [[ PASSED ] 10 tests. [Thread 17312.0x1f28 exited with code 0] [Thread 17312.0x4d0 exited with code 0] [Thread 17312.0x144c exited with code 0] [Inferior 1 (process 17312) exited normally] (gdb) Starting program: c:\home\juanjo\src\tensor\build-msys2-ucrt64\tests\test_rand.exe [New Thread 18700.0xdf8] [New Thread 18700.0x18f4] [New Thread 18700.0xf08] [<<< Step (4), press [----------] Global test environment set-up. [----------] 10 tests from RandTest [ RUN ] RandTest.IntSize [ OK ] RandTest.IntSize (0 ms) [ RUN ] RandTest.LongSize [ OK ] RandTest.LongSize (0 ms) [ RUN ] RandTest.Reseed [ OK ] RandTest.Reseed (1 ms) [ RUN ] RandTest.DoubleBalanced [ OK ] RandTest.DoubleBalanced (0 ms) [ RUN ] RandTest.DoubleSigma [ OK ] RandTest.DoubleSigma (2 ms) [ RUN ] RandTest.ComplexBalanced [ OK ] RandTest.ComplexBalanced (0 ms) [ RUN ] RandTest.ComplexUncorrelated [ OK ] RandTest.ComplexUncorrelated (1 ms) [ RUN ] RandTest.IntEmpty [ OK ] RandTest.IntEmpty (0 ms) [ RUN ] RandTest.LongEmpty [ OK ] RandTest.LongEmpty (0 ms) [ RUN ] RandTest.ULongEmpty [ OK ] RandTest.ULongEmpty (0 ms) [----------] 10 tests from RandTest (4 ms total) [----------] Global test environment tear-down [[ PASSED ] 10 tests. [Thread 18700.0xf08 exited with code 0] [Thread 18700.0xdf8 exited with code 0] [Thread 18700.0x18f4 exited with code 0] [Inferior 1 (process 18700) exited normally] (gdb) Starting program: c:\home\juanjo\src\tensor\build-msys2-ucrt64\tests\test_rand.exe [New Thread 12752.0x21b4] [New Thread 12752.0x3710] [New Thread 12752.0x4934] [quit<<< Step (4) Debugger finished Jostein Kjønigsen writes: > On 15.03.2022 10:58, Juan José García-Ripoll wrote: > > Eli Zaretskii writes: > > Can you show how that program behaves when invoked from the system > shell, not under the debugger? Also, if you invoke "M-x shell" inside > Emacs, and then run that program from the inferior shell, does it > behave correctly, or does it also hangs until you type Enter? > > > Let me summarize all the questions in this single post. What is related > to MSYS2 is the use of MSYS2's toolchains for building and debugging the > software. There is nothing specific to MSYS2 other than specifying to > Emacs that the debugger is c:/msys64/ucrt64/bin/gdb.exe or some other > program from the toolchain I choose. > > Your paragraph abore is quite on spot. As I stated before, if I use M-x > shell and invoke the debugger from the shell (still within Emacs) > everything works just fine, so it is not a buffering issue. Also, to be > more precise, within the debugger the program runs to completion, which > means the output is completely unbuffered. It therefore should have been > shown by Emacs' gdb already when I copied the text. > > Another indication that there is some problem with Emacs' GDB/GUD > packages is that the output _is_ there. If I type a command right after > the last shown output, gdb executes that command, and any following one, > but re-displays the original output of the program again and again. It > is somehow as if it had reinterpreted the program's output as a prompt. > > Is there a way I can debug how GUD is behaving or interfacing with gdb's > output? I know some other major modes keep debugging information or > intermediate buffers if requested. But I still have not found it for > GUD. > > Best, > > Could this error in any way be related to the previous issue with had with "use posix_spawn"? [1] > > For those who need a reminder, as far as I understood it, the key issue there was that a required bugfix for > Mac (but also generally an optimization) was made into a default optimization for platforms, and the idea was > that unless it was proven troublesome one could decide to keep it. > > Well, on Linux it did cause some issues with triggering external processes. Specifically .NET-based tooling, > made especially painful with .NET-based Language Server implementations no longer working (C# and F#). > > If this is another instance of such a bug (and I'm deliberately qualifing that with an "if"), would it make sense > to reverse this optimization on all platforms not Mac? There seems to be several unintended side-effects, and > could possibly be more? > > [1] https://lists.gnu.org/archive/html/emacs-devel/2022-01/msg01561.html -- Juan José García Ripoll http://juanjose.garciaripoll.com http://quinfog.hbar.es