From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 07 11:17:30 2025 Received: (at submit) by debbugs.gnu.org; 7 Sep 2025 15:17:30 +0000 Received: from localhost ([127.0.0.1]:45041 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uvH8z-0003LB-9L for submit@debbugs.gnu.org; Sun, 07 Sep 2025 11:17:29 -0400 Received: from lists.gnu.org ([2001:470:142::17]:46258) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uvH8k-0003KV-Kt for submit@debbugs.gnu.org; Sun, 07 Sep 2025 11:17:15 -0400 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 1uvH8c-0004C7-Fr for bug-gnu-emacs@gnu.org; Sun, 07 Sep 2025 11:17:06 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uvH8U-0003HO-0b for bug-gnu-emacs@gnu.org; Sun, 07 Sep 2025 11:17:05 -0400 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-61cc281171cso6433982a12.0 for ; Sun, 07 Sep 2025 08:16:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757258212; x=1757863012; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=GvH96wC4ZoksmmkvfHFPQnxgFw2ylmORx/WJzD9Qsu0=; b=bVQPW2Jigex2IWo1atLIKS7OyTcjhJ4kkCChrZOVYwo/4kuLuPlZEjd8Es/A5HnWp3 KT8Vmk1ZkFRuxfk0ek6NSuR1nR5tkFjjxL77XWqf5olS6IQVmZZcoOnzkmQeCvHhiV9l 96UtRInbgw4zYjEoUw4qvx+74hm/ukixp8OBseZS85gHuQKc7sXhKgUILyh5BzsaIZf1 SvXeM5/tMQhgA2FvNxO3xJkDZ9ZyzXGzqSQgEdME5B3cETbTzqtlMQhW3NsIMaszaEgf 7lAdbMG9Ew5NeZyI+MR+scCeCUlbmq4I0u3+ajZOmIPWos9TBLqsCh6e+xN31FRER0YS 1E+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757258212; x=1757863012; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=GvH96wC4ZoksmmkvfHFPQnxgFw2ylmORx/WJzD9Qsu0=; b=dyCbXHsyzJoUcBRQG9+biOALmti5X/fSxRxgm41vJQCsF2tjoDHTPpSe5P4ZemFi6L OkxBwX5XfUQqoEM74mRFIlEcU7tB3LgEbi6B2S8RFUOCxZY4hCt0q0AyuCQS44G6q0bv vEKVSQPqWVthv0KKqoO8JBU7kTbCYqwGonEeT5hI27Vij5716rqhubL0zFYJOS0uzNAs bRwLRKc6aa2ECxRMT2NeFPNSvCNwY9zm5nMgvh1cHnXliaS0VcePHP4qvx8PL784ouyL tJaADA54WV6IFRp3iBezxJ1OnXFKSUr3LNqgkCavZPZLWfAsYEHdKk+qI+7GwdRrL5V+ Fg0A== X-Gm-Message-State: AOJu0YyVnJeXZLnr1xG77f1LiOI1sLyzg5Peq5VCZw6vL5MTlssC6c0h 6//8aOPnq/BJzFnKRZvu5VbmRS7xJ+0DeALZ7UgBf3TcGNh7FCHzMNTZVvv+G8RR3q9DXey1EgQ pWO0K5MXSIRAeSi2L37eaiMu9aw0wOZEcAxFG X-Gm-Gg: ASbGnctbvbdRz/OKO5YWKRmGvZppQKpqPNXUgZ+W0piMNuKYRFwBR/AUts8OalZEhYc /3dSTqRC4ynGdP+F1Iq/rXQGWfsmMSy6Dh4lpWuU9eFe6VaijD3oP7EQNK8lNBcSu4sdqDnZRoK Q4DC47zHiMhG81QzUrg673z3AldSIYWSbhoP4gLu4g4QrFP72dOlE1MdWHE2X08bGGhxav0vRDw l1U+g== X-Google-Smtp-Source: AGHT+IGiHLXP8vRd0ZAmU4Rt2oLgcU308yyrfnS1QoKhPTDyiwQMOQqm4+jlXzT0wXteeyYGl4rUw6BMkVXjAzJ7xSA= X-Received: by 2002:a05:6402:2748:b0:618:2733:1a52 with SMTP id 4fb4d7f45d1cf-6237b0ac917mr4163297a12.8.1757258211799; Sun, 07 Sep 2025 08:16:51 -0700 (PDT) MIME-Version: 1.0 From: =?UTF-8?Q?Gustav_H=C3=A5llberg?= Date: Sun, 7 Sep 2025 17:16:41 +0200 X-Gm-Features: AS18NWDc-5RvrVjGS15gVU1kRCY0_awIvkE7Bt1qWTTxuSv61uBY0oPBZi6aSPk Message-ID: Subject: 30.1; M-x gdb startup problem with (eq gdb-debuginfod-enable-setting 'ask) To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary="0000000000007e37ab063e378fa6" Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=gustav@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --0000000000007e37ab063e378fa6 Content-Type: text/plain; charset="UTF-8" If gdb-debuginfod-enable-setting is set to 'ask, gdb-init-1 may be called recursively, causing gdb-token-number (and other variables) to be reset in the middle of startup. This causes an "gdb-handle-reply: Wrong type argument: gdb-handler, nil" error message and other "strange" behavior. It triggers every time for me when attaching gdb to a running process: "emacs -nw -q" and M-x gdb, "gdb -i=mi -p ". I only tested it with emacs 30.1 but the code seems to be the same at origin/master. If you insert (when (> gdb-token-number 0) (edebug)) in the begining of (gdb-init-1) you'll see what happens. Partial call trace: gdb-init-1() : gdb-update() : gdb-stopped(...) : gud-filter(...) read-from-minibuffer(...) y-or-n-p("Enable querying debuginfod servers for this session?") : gdb-init-1() : gdb-update() gdb("gdb -i=mi -p ...") I don't know what the right fix is, but it doesn't seem right to wait for user input in the middle of gdb-init-1. --0000000000007e37ab063e378fa6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
If=C2=A0gdb-debuginfod-enable-setting is set to 'ask, = gdb-init-1 may be called recursively, causing=C2=A0gdb-token-number (and ot= her variables) to be reset in the middle of startup.

This causes an "gdb-handle-reply: Wrong type argument: gdb-handler, n= il" error message and other "strange" behavior.
It triggers every time for me when attaching gdb to a running = process: "emacs -nw -q" and M-x gdb, "gdb -i=3Dmi -p <som= e-pid>". I only tested it with emacs 30.1 but the code seems to be = the same at origin/master.

If you insert (when (&g= t; gdb-token-number 0) (edebug)) in the begining of (gdb-init-1) you'll= see what happens. Partial call trace:

=C2=A0 gdb-init-1()
=C2=A0 =C2=A0:
=C2=A0 gdb-update()
=C2= =A0 =C2=A0:
=C2=A0 gdb-stopped(...)
=C2=A0 =C2=A0:
=C2=A0 gud-filt= er(...)
=C2=A0 read-from-minibuffer(...)
=C2=A0 y-or-n-p("Enable= querying debuginfod servers for this session?")
=C2=A0 =C2=A0:
= =C2=A0 gdb-init-1()
=C2=A0 =C2=A0:
=C2=A0 gdb-update()
=C2=A0 gdb(= "gdb -i=3Dmi -p ...")

I don't know what the rig= ht fix is, but it doesn't seem right to wait for user input in the midd= le of gdb-init-1.
--0000000000007e37ab063e378fa6-- From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 13 05:37:42 2025 Received: (at 79403) by debbugs.gnu.org; 13 Sep 2025 09:37:42 +0000 Received: from localhost ([127.0.0.1]:53554 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uxMhR-0004LH-Ij for submit@debbugs.gnu.org; Sat, 13 Sep 2025 05:37:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34994) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uxMhP-0004KW-3x for 79403@debbugs.gnu.org; Sat, 13 Sep 2025 05:37:39 -0400 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 1uxMhH-00076D-RS; Sat, 13 Sep 2025 05:37:33 -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=ZbVb2QxgZ5ZKYjOzAvSPE5/asufTteokcg7HpQt5qII=; b=nMs1r1U9/GXDLgiyCZKt 9+wZ7sCwK6WGhnjq6MC6bJ7MHQFFFFpdHY4md8yxITN1f0021DCxSH9WWviPWxKWpd/XvB7fPU0jL HnTFcbXUCZ3Vu+J2jS3CaMI8W6EahfDsw06y5OAU75XqMgNu26b01omSb4eTDl8UZ/9JBWNRCs8St 3qAD1ECgiO5P3boRSjh7BbMVGCwj/B1dpZyEwZGUP0nWvKpi+X2V5paYPTOaE2chAcBlvcfKo165e HPg7ZbvKppLOspbZ+gsNsT0TdZvgQLICqzfcxPVlmF0nux4+P1dgqlILSWc+ceVLmF5vdlRFA6PGB uDA0KfXbrCQd9Q==; Date: Sat, 13 Sep 2025 12:37:29 +0300 Message-Id: <86qzwar8va.fsf@gnu.org> From: Eli Zaretskii To: Gustav =?utf-8?Q?H=C3=A5llberg?= In-Reply-To: (message from Gustav =?utf-8?Q?H=C3=A5llberg?= on Sun, 7 Sep 2025 17:16:41 +0200) Subject: Re: bug#79403: 30.1; M-x gdb startup problem with (eq gdb-debuginfod-enable-setting 'ask) References: MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79403 Cc: 79403@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Gustav HÃ¥llberg > Date: Sun, 7 Sep 2025 17:16:41 +0200 > > If gdb-debuginfod-enable-setting is set to 'ask, gdb-init-1 may be called recursively, causing > gdb-token-number (and other variables) to be reset in the middle of startup. > > This causes an "gdb-handle-reply: Wrong type argument: gdb-handler, nil" error message and other > "strange" behavior. > > It triggers every time for me when attaching gdb to a running process: "emacs -nw -q" and M-x gdb, "gdb - > i=mi -p ". I only tested it with emacs 30.1 but the code seems to be the same at origin/master. > > If you insert (when (> gdb-token-number 0) (edebug)) in the begining of (gdb-init-1) you'll see what > happens. Partial call trace: > > gdb-init-1() > : > gdb-update() > : > gdb-stopped(...) > : > gud-filter(...) > read-from-minibuffer(...) > y-or-n-p("Enable querying debuginfod servers for this session?") > : > gdb-init-1() > : > gdb-update() > gdb("gdb -i=mi -p ...") > > I don't know what the right fix is, but it doesn't seem right to wait for user input in the middle of gdb-init-1. Thanks. Does the patch below give good results? diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 74dff32..ebaff4a2 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -1108,7 +1108,9 @@ gdb-init-1 ;; trigger questions about debuginfod queries. (if (eq gdb-debuginfod-enable 'ask) (setq gdb-debuginfod-enable - (y-or-n-p "Enable querying debuginfod servers for this session?"))) + (let ((gud-filter-defer-flag t)) + (y-or-n-p + "Enable querying debuginfod servers for this session?")))) (gdb-input (format "-gdb-set debuginfod enabled %s" (if gdb-debuginfod-enable "on" "off")) 'gdb-debuginfod-message) From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 13 06:26:13 2025 Received: (at 79403) by debbugs.gnu.org; 13 Sep 2025 10:26:13 +0000 Received: from localhost ([127.0.0.1]:53773 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uxNSP-00081n-6C for submit@debbugs.gnu.org; Sat, 13 Sep 2025 06:26:13 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:57680) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uxNSM-00081F-Gu for 79403@debbugs.gnu.org; Sat, 13 Sep 2025 06:26:11 -0400 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-61cd6089262so4095829a12.3 for <79403@debbugs.gnu.org>; Sat, 13 Sep 2025 03:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757759164; x=1758363964; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=6gn5lRUd3bA25EkOC2VqXzaVv3KlqsJt3yyNBlr9+bI=; b=UrhxCP5FXT38TGH83jLYy1qj/adgsQMVEgw3vH8poS+m6CZGb3cLz6BPeIIlp1p5OQ zgCf4uY7jdeuYx6q0TsyGsVvHGyJPx+I0iBJ9he5k8STU5IYFsTnlH3eRHUiW3r/J2Eu QeILHmOR6grlwWktC4HTdWfxteNVphqcq9/DAwEajjDiqixHZppdS7dlkJHotNVv7new +AGOTLftfgJ61g8lTX9d5QBQW8AzbIaUB5p0VPZFNOkXHg5JvqUei4Nb/Ns/gs5kC7z5 Jjg+DOmCKvOYV3dxt4hPgbVcqzI5ctBV2TuhWZeEUWEewgprQ37l+Ksr/zVHeDHaTduG YG4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757759164; x=1758363964; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6gn5lRUd3bA25EkOC2VqXzaVv3KlqsJt3yyNBlr9+bI=; b=jYDxmZdCIZzpqT+Uc754ciRhclMAPqFlXNt7XMfi1N1BnxDOPjthOtQFbytMleoJIt v13SsQKI7dFlZGD/3L17NvMcMTdt7C0Czu+jX9vH6Pyw+ZKXwlzz0QB7/NOhVjDuTGW/ 1L3yokivMS2rvnD1h/byxVm9mK4txxgdGisjLfw99NLFyj/xVWRefL6FvcEnicOGjMVE YQbdNxmErKrFv2iWxLhKy2vYfym2b7ztJbclEzrGqlCaC0euWj+ESixjXUdHrNp3Wx/V SI0kCqIP+tvrrhZ6zkuD3Xu9HOMIqULHdrHT+1HoQQQ9oSAFrS600WCfF1Zgn306hNAt AGBQ== X-Gm-Message-State: AOJu0YxHSYD3MrzIgOP0V8HtFJb7K9mFyIwXMKkcCsq9SZxTfb/LBXYG z1qq4pzKKVi7Nqr96UP3LRzsrgmkoq9wJL3KGu1ZIFYvzkPNzPGSlJQCYK2AsMXPQ091rZGkjr4 dModZ5aVoJ4SYJ9fmScZmMwjp25vQn/Bj3X9E X-Gm-Gg: ASbGncvcbO9PgoynPyVn+DeRjx80hvBDLvgxN3Zg2ljN/tkzmoxuMNJZ7UZsxN7WwXA pMAEBfXmp7xTqxfkR7Q7ooZ409gIuA1g7s0F34seugBrXpEdXp1Qo67U3bl95I3kbyDSxntI1MB r+BgJ2Tf25GUCaw+owbPjOgkAd3TAsfP73VFwYO9BnRwxpoVheWVmES0LOf+wUxFsHhWJPPkets JXLbw== X-Google-Smtp-Source: AGHT+IFsLfFhniH7gpjAiC8xbAlae0qB6HEPDIWDLmUnEaLNr+vF7dg52k8PzfKnDIqlTMngHp1WeRqzyI0UVr0v7JM= X-Received: by 2002:a05:6402:4412:b0:621:99dc:8cea with SMTP id 4fb4d7f45d1cf-62ed82ce470mr5328553a12.37.1757759163696; Sat, 13 Sep 2025 03:26:03 -0700 (PDT) MIME-Version: 1.0 References: <86qzwar8va.fsf@gnu.org> In-Reply-To: <86qzwar8va.fsf@gnu.org> From: =?UTF-8?Q?Gustav_H=C3=A5llberg?= Date: Sat, 13 Sep 2025 12:25:52 +0200 X-Gm-Features: AS18NWADXzb3LfudJBBDmhmYDsp3sVOx2uCm-daRCSQyt-3u3P6vd79KyFhW3ko Message-ID: Subject: Re: bug#79403: 30.1; M-x gdb startup problem with (eq gdb-debuginfod-enable-setting 'ask) To: Eli Zaretskii Content-Type: multipart/alternative; boundary="0000000000008d8bb7063eac3260" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79403 Cc: 79403@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --0000000000008d8bb7063eac3260 Content-Type: text/plain; charset="UTF-8" > > Thanks. Does the patch below give good results? > Yes but gud-filter-defer-flag seems to be a global so if you have several gdb sessions going they all get confused while waiting for the y-or-no-p. To test I did: 1. M-x gdb, start debugging process A, stop at breakpoint 2. M-x gdb, attach to process B, waiting at y-or-n-p 3. Type "step" in A's gdb window 4. Answer "y" to the y-or-n-p for B This sent output from A's gdb to B's gdb buffer! It seems gud-filter-defer-flag and gud-filter-pending-text should be buffer-local (or process properties?) to avoid this. But I don't know this code at all so... That said, your patch is definitely a big improvement and the above error case is a bit contrived :) > diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el > index 74dff32..ebaff4a2 100644 > --- a/lisp/progmodes/gdb-mi.el > +++ b/lisp/progmodes/gdb-mi.el > @@ -1108,7 +1108,9 @@ gdb-init-1 > ;; trigger questions about debuginfod queries. > (if (eq gdb-debuginfod-enable 'ask) > (setq gdb-debuginfod-enable > - (y-or-n-p "Enable querying debuginfod servers for this > session?"))) > + (let ((gud-filter-defer-flag t)) > + (y-or-n-p > + "Enable querying debuginfod servers for this session?")))) > (gdb-input (format "-gdb-set debuginfod enabled %s" > (if gdb-debuginfod-enable "on" "off")) > 'gdb-debuginfod-message) > --0000000000008d8bb7063eac3260 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks.=C2=A0 Does the patch below= give good results?

Yes but gud-filter-= defer-flag seems to be a global so if you have several gdb sessions going t= hey all get confused while waiting for the y-or-no-p.

To = test I did:
1. M-x gdb, start debugging process A, stop at breakp= oint
2. M-x gdb, attach to process B, waiting at y-or-n-p
3. Type "step" in A's gdb window
4. Answer "= ;y" to the y-or-n-p for B

This sent output fr= om A's gdb to B's gdb buffer!

It seems gud= -filter-defer-flag and=C2=A0gud-filter-pending-text should be buffer-local = (or process properties?) to avoid this.
But I don't know this= code at all so...

That said, your patch is defini= tely a big improvement and the above error case is a bit contrived :)
=
=C2=A0
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 74dff32..ebaff4a2 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1108,7 +1108,9 @@ gdb-init-1
=C2=A0 =C2=A0;; trigger questions about debuginfod queries.
=C2=A0 =C2=A0(if (eq gdb-debuginfod-enable 'ask)
=C2=A0 =C2=A0 =C2=A0 =C2=A0(setq gdb-debuginfod-enable
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (y-or-n-p "Enable querying = debuginfod servers for this session?")))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((gud-filter-defer-flag t))=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (y-or-n-p
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"Enable queryi= ng debuginfod servers for this session?"))))
=C2=A0 =C2=A0(gdb-input (format "-gdb-set debuginfod enabled %s"<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (if gdb-debuginfod-enable "on" "off"))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 'gdb-debuginfod-messag= e)
--0000000000008d8bb7063eac3260-- From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 13 10:07:42 2025 Received: (at 79403) by debbugs.gnu.org; 13 Sep 2025 14:07:42 +0000 Received: from localhost ([127.0.0.1]:55709 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uxQuj-0003y5-1k for submit@debbugs.gnu.org; Sat, 13 Sep 2025 10:07:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48874) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uxQug-0003xL-CV for 79403@debbugs.gnu.org; Sat, 13 Sep 2025 10:07:39 -0400 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 1uxQub-0004uy-1Y; Sat, 13 Sep 2025 10:07:33 -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=FfxyMj5Ld4jm/AiKzrLqNePezsP/i4MLZnbYZndZCX8=; b=rna36lSm7zo70GJ9/1SM S8Ll5nmQx/rt0vdWSkyp4AKrftFpn/3dIZamtcFGJ+/e4cAG+3Subu1MCsqWtOaBEu0pUKGyywdIK UeBrb8Cq6vEgoc3Q0HuYxlABDcLWc5rlsS10K1JhcKbq//ApR0D/VFmvAk7Z2zBCRIGgr1gNS+kiU WnMZaNQRNAhSMLBYovGs0h3bi7eyY9jZt96NJLtjqn2jBXOcAzIn/9U9X92tAZJ6iRNLnZ9pv5/9n EbJ0XNip41kRCI8pGSQMwRQQgjnxiVm1SmZfEUN6DDarMgO0wWX0jfr5mm7v0abgYEqwUQJEgIu71 NotPLpX4OnuaDA==; Date: Sat, 13 Sep 2025 17:07:28 +0300 Message-Id: <86v7lmphsv.fsf@gnu.org> From: Eli Zaretskii To: Gustav =?utf-8?Q?H=C3=A5llberg?= In-Reply-To: (message from Gustav =?utf-8?Q?H=C3=A5llberg?= on Sat, 13 Sep 2025 12:25:52 +0200) Subject: Re: bug#79403: 30.1; M-x gdb startup problem with (eq gdb-debuginfod-enable-setting 'ask) References: <86qzwar8va.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79403 Cc: 79403@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Gustav HÃ¥llberg > Date: Sat, 13 Sep 2025 12:25:52 +0200 > Cc: 79403@debbugs.gnu.org > > Thanks. Does the patch below give good results? > > Yes but gud-filter-defer-flag seems to be a global so if you have several gdb sessions going they all get > confused while waiting for the y-or-no-p. > > To test I did: > 1. M-x gdb, start debugging process A, stop at breakpoint > 2. M-x gdb, attach to process B, waiting at y-or-n-p > 3. Type "step" in A's gdb window > 4. Answer "y" to the y-or-n-p for B > > This sent output from A's gdb to B's gdb buffer! > > It seems gud-filter-defer-flag and gud-filter-pending-text should be buffer-local (or process properties?) to > avoid this. > But I don't know this code at all so... > > That said, your patch is definitely a big improvement and the above error case is a bit contrived :) Thanks, how about the patch below? diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 74dff32..ebaff4a2 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -1108,7 +1108,9 @@ gdb-init-1 ;; trigger questions about debuginfod queries. (if (eq gdb-debuginfod-enable 'ask) (setq gdb-debuginfod-enable - (y-or-n-p "Enable querying debuginfod servers for this session?"))) + (let ((gud-filter-defer-flag t)) + (y-or-n-p + "Enable querying debuginfod servers for this session?")))) (gdb-input (format "-gdb-set debuginfod enabled %s" (if gdb-debuginfod-enable "on" "off")) 'gdb-debuginfod-message) diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 5980bc2..1d43028 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -793,6 +793,10 @@ gdb-first-prompt (defvar gud-filter-pending-text nil "Non-nil means this is text that has been saved for later in `gud-filter'.") +(defvar gud-filter-defer-flag nil + "Non-nil means don't process anything from the debugger right now. +It is saved for when this flag is not set.") + ;; One of the nice features of GDB is its impressive support for ;; context-sensitive command completion. We preserve that feature ;; in the GUD buffer by using a GDB command designed just for Emacs. @@ -2829,6 +2833,11 @@ gud-common-init (if find-file (setq-local gud-find-file find-file)) (setq gud-last-last-frame nil) + ;; We need these to be local to the process's buffer so that we could + ;; defer processing output for each debugging session separately. + (make-local-variable 'gud-filter-defer-flag) + (make-local-variable 'gud-filter-pending-text) + (set-process-filter (get-buffer-process (current-buffer)) #'gud-filter) (set-process-sentinel (get-buffer-process (current-buffer)) #'gud-sentinel) (gud-set-buffer)) @@ -2837,34 +2846,32 @@ gud-set-buffer (when (derived-mode-p 'gud-mode) (setq gud-comint-buffer (current-buffer)))) -(defvar gud-filter-defer-flag nil - "Non-nil means don't process anything from the debugger right now. -It is saved for when this flag is not set.") - ;; These functions are responsible for inserting output from your debugger ;; into the buffer. The hard work is done by the method that is ;; the value of gud-marker-filter. (defun gud-filter (proc string) ;; Here's where the actual buffer insertion is done - (let (output process-window) - (if (buffer-name (process-buffer proc)) - (if gud-filter-defer-flag - ;; If we can't process any text now, - ;; save it for later. - (setq gud-filter-pending-text - (concat (or gud-filter-pending-text "") string)) - - ;; If we have to ask a question during the processing, - ;; defer any additional text that comes from the debugger - ;; during that time. - (let ((gud-filter-defer-flag t)) - ;; Process now any text we previously saved up. - (if gud-filter-pending-text - (setq string (concat gud-filter-pending-text string) - gud-filter-pending-text nil)) + (let ((proc-buf (process-buffer proc)) + (cbuf (current-buffer)) + output process-window) + (if (buffer-name proc-buf) + (with-current-buffer proc-buf + (if gud-filter-defer-flag + ;; If we can't process any text now, + ;; save it for later. + (setq gud-filter-pending-text + (concat (or gud-filter-pending-text "") string)) + + ;; If we have to ask a question during the processing, + ;; defer any additional text that comes from the debugger + ;; during that time. + (let ((gud-filter-defer-flag t)) + ;; Process now any text we previously saved up. + (if gud-filter-pending-text + (setq string (concat gud-filter-pending-text string) + gud-filter-pending-text nil)) - (with-current-buffer (process-buffer proc) ;; If we have been so requested, delete the debugger prompt. (save-restriction (widen) @@ -2887,23 +2894,22 @@ gud-filter ;; Let the comint filter do the actual insertion. ;; That lets us inherit various comint features. - (comint-output-filter proc output)) - - ;; Put the arrow on the source line. - ;; This must be outside of the save-excursion - ;; in case the source file is our current buffer. - (if process-window - (with-selected-window process-window - (gud-display-frame)) - ;; We have to be in the proper buffer, (process-buffer proc), - ;; but not in a save-excursion, because that would restore point. - (with-current-buffer (process-buffer proc) - (gud-display-frame)))) - - ;; If we deferred text that arrived during this processing, - ;; handle it now. - (if gud-filter-pending-text - (gud-filter proc "")))))) + (comint-output-filter proc output) + + ;; Put the arrow on the source line. + ;; This must be outside of the save-excursion + ;; in case the source file is our current buffer. + (if process-window + (with-selected-window process-window + (gud-display-frame)) + ;; We are in the proper buffer, (process-buffer proc), + ;; but not in a save-excursion, because that would restore point. + (gud-display-frame))) + + ;; If we deferred text that arrived during this processing, + ;; handle it now. + (if gud-filter-pending-text + (gud-filter proc ""))))))) (defvar gud-minor-mode-type nil) (defvar gud-overlay-arrow-position nil)