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.bugs Subject: bug#62697: gdb-mi.el: Change target-async to mi-async Date: Fri, 07 Apr 2023 09:26:06 +0300 Message-ID: <83h6tsp5s1.fsf@gnu.org> References: <835ya9qgox.fsf@gnu.org> <79ec3700-02ab-7574-1411-dfef0ec5eb7f@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17435"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62697@debbugs.gnu.org, gustaf.waldemarson@gmail.com To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 07 08:26:54 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1pkfYk-0004LN-34 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Apr 2023 08:26:54 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkfY7-0001o4-SJ; Fri, 07 Apr 2023 02:26:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkfXv-0001m0-CH for bug-gnu-emacs@gnu.org; Fri, 07 Apr 2023 02:26:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkfXu-0005S1-Vg for bug-gnu-emacs@gnu.org; Fri, 07 Apr 2023 02:26:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pkfXu-0006c9-Dk for bug-gnu-emacs@gnu.org; Fri, 07 Apr 2023 02:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 07 Apr 2023 06:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62697 X-GNU-PR-Package: emacs Original-Received: via spool by 62697-submit@debbugs.gnu.org id=B62697.168084874425391 (code B ref 62697); Fri, 07 Apr 2023 06:26:02 +0000 Original-Received: (at 62697) by debbugs.gnu.org; 7 Apr 2023 06:25:44 +0000 Original-Received: from localhost ([127.0.0.1]:55587 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pkfXc-0006bS-Ai for submit@debbugs.gnu.org; Fri, 07 Apr 2023 02:25:44 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:49824) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pkfXY-0006b9-Ns for 62697@debbugs.gnu.org; Fri, 07 Apr 2023 02:25:42 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkfXT-0005Po-AK; Fri, 07 Apr 2023 02:25:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=4JlXqJqqqbXmfW/WNH3VM6bBGEwL4/nVilYH7+08o60=; b=C8AhabO//2qr WD7Eo3NVz/hLlC5ri1/IaCL6d1OgLVtJUqdoPEE4tO26j/F6iWgbFZ+XyM1frSUNLnGFixxtVSmVY vM6/cPj9PFE4BJpYxHKO857DwIcEnS6lyLQL6dF8VCjQpLt+b0XIbXYcoLksocPImzlROyxhigKy4 GBsh4WUCFJLOhzxJH2Ji4yfSl+US6Y31jGC6nPOY6vKJ2lYTGgFNwY5zJru62D5bjxNICMUrkWpPM wKtvvB6naROLGK+GSGWkJjCsWLfEcRj1jw9hznMCJdQ02QRSiOZfwRFiB4A3jNi0xmRfW0GRufGsK C+dCmlM+Jg4thpJBDv32lA==; Original-Received: from [87.69.77.57] (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 1pkfXS-0000Pf-NV; Fri, 07 Apr 2023 02:25:35 -0400 In-Reply-To: <79ec3700-02ab-7574-1411-dfef0ec5eb7f@gmail.com> (message from Jim Porter on Thu, 6 Apr 2023 18:26:48 -0700) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:259363 Archived-At: > Date: Thu, 6 Apr 2023 18:26:48 -0700 > Cc: 62697@debbugs.gnu.org > From: Jim Porter > > On 4/6/2023 6:32 AM, Eli Zaretskii wrote: > > We could either (1) ask GDB about its version, or (2) filter out the > > annoying message so it isn't shown to the users; we'd then have to > > revisit this if/when GDB actually drops the command, if it ever does. > > > > Alternative (1) is AFAIR problematic because the initialization of a > > GDB session under Emacs is entirely asynchronous, so sending a command > > and waiting for its response before sending the rest is not easy. So > > I tend to the second alternative. > > I don't know much about gdb-mi.el's internals, but taking a quick look > at the code, 'gdb-input' takes a callback, so something like the > following pseudocode would probably do the trick? The problem is not with the callback, the problem is with _when_ the callback is called. gdb-mi doesn't wait for each gdb-input call to complete and its callback called before calling the next gdb-input. In practice, we send a dozen gdb-input commands before the response for the first one is received and its callback called. You can clearly see that if you enable gdb-enable-debug and look at the log it collects. So sending a command via gdb-input, then conditioning another command on it is not trivial, since the callback could be called much later. > (gdb-input "-gdb-version" > (lambda () > (if (gdb-should-use-mi-async) ; Check the version output. > (gdb-input "-gdb-set mi-async on" #'ignore) > (gdb-input "-gdb-set target-async on" #'ignore)) > (gdb-input "-list-target-features" #'gdb-check-target-async))) > > The existing 'gdb-check-target-async' already chains GDB-MI commands > like this, so I imagine the above will Just Work. It "will work", but what if the other commands sent via the other gdb-input calls during initialization depend, or change the GDB behavior depending, on whether mi-async was or wasn't already sent? Or are you saying that mi-async can be sent anywhere during the initialization sequence, including after it finishes? The GDB manual says: The frontend may specify a preference for asynchronous execution using the '-gdb-set mi-async 1' command, which should be emitted before either running the executable or attaching to the target. If GDB is invoked with, e.g., "gdb -p PID", then we need to send this command up front, before GDB attaches. And there could be other issues with that proposal. Which is why I said that alternative was "problematic". Filtering out the annoying message is much safer, IMO.