From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: gdb fails to flush output (msys2) Date: Mon, 14 Mar 2022 20:23:40 +0200 Message-ID: <837d8wjsur.fsf@gnu.org> References: <86y21caikh.fsf@csic.es> <83o828k6a7.fsf@gnu.org> <867d8wa05w.fsf@csic.es> 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="32802"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Juan =?utf-8?Q?Jos=C3=A9_Garc=C3=ADa-Ripoll?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Mar 14 19:25:08 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 1nTpNU-0008Oi-1E for ged-emacs-devel@m.gmane-mx.org; Mon, 14 Mar 2022 19:25:08 +0100 Original-Received: from localhost ([::1]:58686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nTpNS-0003gc-GC for ged-emacs-devel@m.gmane-mx.org; Mon, 14 Mar 2022 14:25:06 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:50368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTpMG-0002zQ-Jy for emacs-devel@gnu.org; Mon, 14 Mar 2022 14:23:52 -0400 Original-Received: from [2001:470:142:3::e] (port=48176 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTpMG-00072I-Bf; Mon, 14 Mar 2022 14:23:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=jehim41iJvRlz74uLE8X7eAJ9PEUM9HylKGdBDcPHgI=; b=obbnDvFB0Xjy4amWg1zt yvLwR86h9T5DylwtsZyZNM+W7Ql20jAZNs9ef377dOZS10B2cOdA009d6jF8XOINV7aE01pamBs1v Pwsc6mNEMLJhY7ehawlz23wGk7Ga9UAo4lGVg2VnuslPxInPRkqFsaupVY79TIqu//Qe8V68S+vd8 U2vzGmFdxBME0Vw5mqCVNO9O84kcu/OIY4ur0u3etXZ7cuLA9HVtOvvPPAR5QTSkBLf2iso3vAbx1 5tHwfyaPMWdq0lKyOopWiCNDo+w0qTsfFArjVZC1/8rJ/dY3SrLw+04aWEHgdU1pJjUs18FQ8eACp +BoJcAXLJhqwrw==; Original-Received: from [87.69.77.57] (port=4847 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTpMF-0007Dv-Rv; Mon, 14 Mar 2022 14:23:52 -0400 In-Reply-To: <867d8wa05w.fsf@csic.es> (juanjose.garciaripoll@gmail.com) 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:287162 Archived-At: > From: Juan José García-Ripoll > > Date: Mon, 14 Mar 2022 18:55:55 +0100 > > 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. Yes, I know what MSYS2 is. I asked a more specific question: what does it mean to debug a program using MSYS2, and how is it different from debugging a program "normally", e.g. from the MS-Windows Command Prompt window? IOW, what MSYS2-specific aspects are involved in this debugging? Also, where did you get the GDB binary distribution you are using? > > >> 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 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) You can do that in a separate Command Prompt window you open, setting PATH from the shell prompt. Then the rest of the system will not be affected by that. > 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. How do you start the "Mingw64/Ucrt64 native console"? I'm asking because I'm trying to figure out whether this console is or isn't part of the problem. > 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. This seems to indicate that there's some incompatibility between the way GDB outputs stuff to its stdout and the device/program which displays that stuff. I don't yet understand well enough what you are doing differently from the "usual" use of GDB on MS-Windows (which works just fine), so I cannot tell anything more intelligent. UCRT may or may not be a part of the problem, but I don't have any experience with using Windows programs linked against UCRT instead of MSVCRT.