From unknown Sat Aug 16 16:14:05 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65612: gdb-mi non-stop mode can not set breakpoints when `gud-running' is t Resent-From: Diancheng Wang Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Aug 2023 07:19:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 65612 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 65612@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.169337992726909 (code B ref -1); Wed, 30 Aug 2023 07:19:04 +0000 Received: (at submit) by debbugs.gnu.org; 30 Aug 2023 07:18:47 +0000 Received: from localhost ([127.0.0.1]:52023 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbFTP-0006zk-1M for submit@debbugs.gnu.org; Wed, 30 Aug 2023 03:18:47 -0400 Received: from lists.gnu.org ([2001:470:142::17]:57464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbAfW-0007Uq-A0 for submit@debbugs.gnu.org; Tue, 29 Aug 2023 22:10:56 -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 1qbAfJ-0003EW-GY for bug-gnu-emacs@gnu.org; Tue, 29 Aug 2023 22:10:41 -0400 Received: from m12.mail.163.com ([220.181.12.199]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbAfD-0007m3-Tc for bug-gnu-emacs@gnu.org; Tue, 29 Aug 2023 22:10:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version: Content-Type; bh=guBDfCD9WfzUpFMS80sXL98OQ9UOAFvSmVE3Umg150E=; b=TjijuRDyL+xIXyy+u0pjWd8sT8vAI5CL5ywzT9+6YZ8H1RfLl0ijW5WVIhBWDd frA4axCmC7sTT1xeCXkKLuvkSmzLeXPfXu2FvnMu+dRSKtENZpASRfOB+QOJ0fIA clqLxlea1SFHoBxigPqejn9WSrh5NIJJ/E1gP4r0oEmIY= Received: from hadleywang-LC0 (unknown [42.81.199.10]) by zwqz-smtp-mta-g1-0 (Coremail) with SMTP id _____wAnNAUKpe5kqpWrAg--.62215S3; Wed, 30 Aug 2023 10:10:19 +0800 (CST) From: Diancheng Wang Date: Wed, 30 Aug 2023 10:15:01 +0800 Message-ID: <871qflwa1m.fsf@163.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-CM-TRANSID: _____wAnNAUKpe5kqpWrAg--.62215S3 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjxU70tCUUUUU X-Originating-IP: [42.81.199.10] X-CM-SenderInfo: xgld0u5khqwspzdqwqqrwthudrp/1tbiVwfbqVetsJLX3AABsw Received-SPF: pass client-ip=220.181.12.199; envelope-from=diancheng_wang@163.com; helo=m12.mail.163.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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_BL=0.001, RCVD_IN_MSPIKE_L4=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Mailman-Approved-At: Wed, 30 Aug 2023 03:18:37 -0400 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.1 (/) --=-=-= Content-Type: text/plain Hi, When gdb-mi is running in non-stop mode (both `gud-running' and `gdb-non-stop' are t), it can not set breakpoints using `gud-break' function. But at the same situation, we can set breakpoints using gdb CLI commands in gdb interactive buffer. Attached patch fixed this bug. The patch introduces a gud new variable: `gud-async-running'. The marco `gud-def' still sends command to gdb if `gud-async-running' is t even `gud-running' is t. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-gdb-mi.el-Enable-to-set-breakpoints-even-all-threads.patch >From 717ab9c933308a1222844c0b4cca5c4c93f7ff4a Mon Sep 17 00:00:00 2001 From: Diancheng Wang Date: Wed, 9 Aug 2023 10:35:12 +0800 Subject: [PATCH] gdb-mi.el: Enable to set breakpoints even all threads of debugee are running. --- lisp/progmodes/gdb-mi.el | 17 ++++++++++------- lisp/progmodes/gud.el | 22 ++++++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index a1091de43e9..58629773974 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -928,7 +928,7 @@ gdb (setq-local comint-input-ring-file-name hfile)) (comint-read-input-ring t))) (gud-def gud-tbreak "tbreak %f:%l" "\C-t" - "Set temporary breakpoint at current line.") + "Set temporary breakpoint at current line." t) (gud-def gud-jump (progn (gud-call "tbreak %f:%l" arg) (gud-call "jump %f:%l")) "\C-j" "Set execution address to current line.") @@ -959,7 +959,7 @@ gdb "Finish executing current function.") (gud-def gud-run "-exec-run" nil - "Run the program.") + "Run the program." t) (gud-def gud-break (if (not (string-match "Disassembly" mode-name)) (gud-call "break %f:%l" arg) @@ -967,7 +967,7 @@ gdb (beginning-of-line) (forward-char 2) (gud-call "break *%a" arg))) - "\C-b" "Set breakpoint at current line or address.") + "\C-b" "Set breakpoint at current line or address." t) (gud-def gud-remove (if (not (string-match "Disassembly" mode-name)) (gud-call "clear %f:%l" arg) @@ -975,7 +975,7 @@ gdb (beginning-of-line) (forward-char 2) (gud-call "clear *%a" arg))) - "\C-d" "Remove breakpoint at current line or address.") + "\C-d" "Remove breakpoint at current line or address." t) ;; -exec-until doesn't support --all yet (gud-def gud-until (if (not (string-match "Disassembly" mode-name)) @@ -1044,6 +1044,7 @@ gdb (setq gdb-first-prompt t) (setq gud-running nil) + (setq gud-async-running nil) (gdb-update) @@ -2671,9 +2672,11 @@ gdb-starting ;; Set `gdb-non-stop' when `gdb-last-command' is a CLI background ;; running command e.g. "run &", attach &" or a MI command ;; e.g. "-exec-run" or "-exec-attach". - (when (or (string-match "&\s*$" gdb-last-command) - (string-match "^-" gdb-last-command)) - (gdb-try-check-target-async-support)) + (if (or (string-match "&\s*$" gdb-last-command) + (string-match "^-" gdb-last-command)) + (progn (gdb-try-check-target-async-support) + (setq gud-async-running t)) + (setq gud-async-running nil)) (gdb-force-mode-line-update (propertize gdb-inferior-status 'face font-lock-type-face)) diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 09860a4cbde..3cc63aab84f 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -128,6 +128,10 @@ gud-running "Non-nil if debugged program is running. Used to gray out relevant toolbar icons.") +(defvar gud-async-running nil + "Non-nil if debugged program is running in async mode. +Check it when `gud-running' is t") + (defvar gud-target-name "--unknown--" "The apparent name of the program being debugged in a gud buffer.") @@ -261,13 +265,13 @@ gud-menu-map :visible (memq gud-minor-mode '(gdbmi gdb guiler dbx xdb jdb pdb))] ["Set Breakpoint" gud-break - :enable (not gud-running) + :enable (or (not gud-running) gud-async-running) :visible (gud-tool-bar-item-visible-no-fringe)] ["Temporary Breakpoint" gud-tbreak - :enable (not gud-running) + :enable (or (not gud-running) gud-async-running) :visible (memq gud-minor-mode '(gdbmi gdb sdb xdb))] ["Remove Breakpoint" gud-remove - :enable (not gud-running) + :enable (or (not gud-running) gud-async-running) :visible (gud-tool-bar-item-visible-no-fringe)] ["Continue to selection" gud-until :enable (not gud-running) @@ -283,7 +287,7 @@ gud-menu-map :visible (and (eq gud-minor-mode 'gdbmi) (gdb-show-run-p))] ["Run" gud-run - :enable (not gud-running) + :enable (or (not gud-running) gud-async-running) :visible (or (memq gud-minor-mode '(gdb dbx jdb)) (and (eq gud-minor-mode 'gdbmi) (or (not (gdb-show-run-p)) @@ -403,13 +407,15 @@ gud-find-file ;; Of course you may use `gud-def' with any other debugger command, including ;; user defined ones. -;; A macro call like (gud-def FUNC CMD KEY DOC) expands to a form +;; A macro call like (gud-def FUNC CMD KEY DOC ASYNC-OK) expands to a form ;; which defines FUNC to send the command CMD to the debugger, gives ;; it the docstring DOC, and binds that function to KEY in the GUD -;; major mode. The function is also bound in the global keymap with the +;; major mode. The FUNC still sends CMD when both ASYNC-OK and +;; `gud-async-running' are t even `gud-running' is t. +;; The function is also bound in the global keymap with the ;; GUD prefix. -(defmacro gud-def (func cmd key &optional doc) +(defmacro gud-def (func cmd key &optional doc async-ok) "Define FUNC to be a command sending CMD and bound to KEY, with optional doc string DOC. Certain %-escapes in the string arguments are interpreted specially if present. These are: @@ -434,7 +440,7 @@ gud-def (defalias ',func (lambda (arg) ,@(if doc (list doc)) (interactive "p") - (if (not gud-running) + (if (or (not gud-running) (and ,async-ok gud-async-running)) ,(if (stringp cmd) `(gud-call ,cmd arg) ;; Unused lexical warning if cmd does not use "arg". -- 2.27.0 --=-=-=-- From unknown Sat Aug 16 16:14:05 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Diancheng Wang Subject: bug#65612: closed (Re: bug#65612: gdb-mi non-stop mode can not set breakpoints when `gud-running' is t) Message-ID: References: <83fs3zeczs.fsf@gnu.org> <871qflwa1m.fsf@163.com> X-Gnu-PR-Message: they-closed 65612 X-Gnu-PR-Package: emacs Reply-To: 65612@debbugs.gnu.org Date: Thu, 31 Aug 2023 10:14:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1693476842-24959-1" This is a multi-part message in MIME format... ------------=_1693476842-24959-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #65612: gdb-mi non-stop mode can not set breakpoints when `gud-running' is t which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 65612@debbugs.gnu.org. --=20 65612: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D65612 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1693476842-24959-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 65612-done) by debbugs.gnu.org; 31 Aug 2023 10:13:48 +0000 Received: from localhost ([127.0.0.1]:54971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbegN-0006U3-QY for submit@debbugs.gnu.org; Thu, 31 Aug 2023 06:13:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55960) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbegM-0006Tq-7v for 65612-done@debbugs.gnu.org; Thu, 31 Aug 2023 06:13:46 -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 1qbeg7-0005JB-MV; Thu, 31 Aug 2023 06:13:31 -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=Mk2zsryhWTyonCyJ34TsRpM5PZHGqvC8YgGjFCWXYzM=; b=R4NMNK2QF/zl Imdi3xr7UaYhr6XE7Zg88LatPlSIXMQ3j5lY4ZhiJyYRdfRcROYw6sf8hMLLMcn5a0IejDOe1uuEo gM8BqKvlvQNMI6Ibon4vzhtt4wqOj+I4W+Kr/wG6bIDfNCsRADmOBl9Nk/ZIzFJcwBQxL3vtDjI1p McnN4R3ZhlCs8VAACdEo++cP52yA4Lf5X5fJa5MdJxR0ZNTxa+EqvXQiClH/xDWH99LPMRCv/cmxH +Hz16jLA3xxEhGIACSRXCU5DcCJt+3CjWiccHoFiHJHrdqjyCmNLAkMpotNqQA3GumgOifwQPwN4k i9ZdSS9jGuMFy5qCF1uq3Q==; Date: Thu, 31 Aug 2023 13:13:11 +0300 Message-Id: <83fs3zeczs.fsf@gnu.org> From: Eli Zaretskii To: Diancheng Wang In-Reply-To: <871qflwa1m.fsf@163.com> (message from Diancheng Wang on Wed, 30 Aug 2023 10:15:01 +0800) Subject: Re: bug#65612: gdb-mi non-stop mode can not set breakpoints when `gud-running' is t References: <871qflwa1m.fsf@163.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 65612-done Cc: 65612-done@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: Diancheng Wang > Date: Wed, 30 Aug 2023 10:15:01 +0800 > > When gdb-mi is running in non-stop mode (both `gud-running' and > `gdb-non-stop' are t), it can not set breakpoints using `gud-break' > function. But at the same situation, we can set breakpoints using gdb > CLI commands in gdb interactive buffer. > > Attached patch fixed this bug. The patch introduces a gud new variable: > `gud-async-running'. The marco `gud-def' still sends command to gdb if > `gud-async-running' is t even `gud-running' is t. Thanks, installed on the master branch and closing the bug. ------------=_1693476842-24959-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 30 Aug 2023 07:18:47 +0000 Received: from localhost ([127.0.0.1]:52023 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbFTP-0006zk-1M for submit@debbugs.gnu.org; Wed, 30 Aug 2023 03:18:47 -0400 Received: from lists.gnu.org ([2001:470:142::17]:57464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbAfW-0007Uq-A0 for submit@debbugs.gnu.org; Tue, 29 Aug 2023 22:10:56 -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 1qbAfJ-0003EW-GY for bug-gnu-emacs@gnu.org; Tue, 29 Aug 2023 22:10:41 -0400 Received: from m12.mail.163.com ([220.181.12.199]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbAfD-0007m3-Tc for bug-gnu-emacs@gnu.org; Tue, 29 Aug 2023 22:10:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version: Content-Type; bh=guBDfCD9WfzUpFMS80sXL98OQ9UOAFvSmVE3Umg150E=; b=TjijuRDyL+xIXyy+u0pjWd8sT8vAI5CL5ywzT9+6YZ8H1RfLl0ijW5WVIhBWDd frA4axCmC7sTT1xeCXkKLuvkSmzLeXPfXu2FvnMu+dRSKtENZpASRfOB+QOJ0fIA clqLxlea1SFHoBxigPqejn9WSrh5NIJJ/E1gP4r0oEmIY= Received: from hadleywang-LC0 (unknown [42.81.199.10]) by zwqz-smtp-mta-g1-0 (Coremail) with SMTP id _____wAnNAUKpe5kqpWrAg--.62215S3; Wed, 30 Aug 2023 10:10:19 +0800 (CST) From: Diancheng Wang To: bug-gnu-emacs@gnu.org Subject: gdb-mi non-stop mode can not set breakpoints when `gud-running' is t Date: Wed, 30 Aug 2023 10:15:01 +0800 Message-ID: <871qflwa1m.fsf@163.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-CM-TRANSID: _____wAnNAUKpe5kqpWrAg--.62215S3 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjxU70tCUUUUU X-Originating-IP: [42.81.199.10] X-CM-SenderInfo: xgld0u5khqwspzdqwqqrwthudrp/1tbiVwfbqVetsJLX3AABsw Received-SPF: pass client-ip=220.181.12.199; envelope-from=diancheng_wang@163.com; helo=m12.mail.163.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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_BL=0.001, RCVD_IN_MSPIKE_L4=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 30 Aug 2023 03:18:37 -0400 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.1 (/) --=-=-= Content-Type: text/plain Hi, When gdb-mi is running in non-stop mode (both `gud-running' and `gdb-non-stop' are t), it can not set breakpoints using `gud-break' function. But at the same situation, we can set breakpoints using gdb CLI commands in gdb interactive buffer. Attached patch fixed this bug. The patch introduces a gud new variable: `gud-async-running'. The marco `gud-def' still sends command to gdb if `gud-async-running' is t even `gud-running' is t. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-gdb-mi.el-Enable-to-set-breakpoints-even-all-threads.patch >From 717ab9c933308a1222844c0b4cca5c4c93f7ff4a Mon Sep 17 00:00:00 2001 From: Diancheng Wang Date: Wed, 9 Aug 2023 10:35:12 +0800 Subject: [PATCH] gdb-mi.el: Enable to set breakpoints even all threads of debugee are running. --- lisp/progmodes/gdb-mi.el | 17 ++++++++++------- lisp/progmodes/gud.el | 22 ++++++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index a1091de43e9..58629773974 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -928,7 +928,7 @@ gdb (setq-local comint-input-ring-file-name hfile)) (comint-read-input-ring t))) (gud-def gud-tbreak "tbreak %f:%l" "\C-t" - "Set temporary breakpoint at current line.") + "Set temporary breakpoint at current line." t) (gud-def gud-jump (progn (gud-call "tbreak %f:%l" arg) (gud-call "jump %f:%l")) "\C-j" "Set execution address to current line.") @@ -959,7 +959,7 @@ gdb "Finish executing current function.") (gud-def gud-run "-exec-run" nil - "Run the program.") + "Run the program." t) (gud-def gud-break (if (not (string-match "Disassembly" mode-name)) (gud-call "break %f:%l" arg) @@ -967,7 +967,7 @@ gdb (beginning-of-line) (forward-char 2) (gud-call "break *%a" arg))) - "\C-b" "Set breakpoint at current line or address.") + "\C-b" "Set breakpoint at current line or address." t) (gud-def gud-remove (if (not (string-match "Disassembly" mode-name)) (gud-call "clear %f:%l" arg) @@ -975,7 +975,7 @@ gdb (beginning-of-line) (forward-char 2) (gud-call "clear *%a" arg))) - "\C-d" "Remove breakpoint at current line or address.") + "\C-d" "Remove breakpoint at current line or address." t) ;; -exec-until doesn't support --all yet (gud-def gud-until (if (not (string-match "Disassembly" mode-name)) @@ -1044,6 +1044,7 @@ gdb (setq gdb-first-prompt t) (setq gud-running nil) + (setq gud-async-running nil) (gdb-update) @@ -2671,9 +2672,11 @@ gdb-starting ;; Set `gdb-non-stop' when `gdb-last-command' is a CLI background ;; running command e.g. "run &", attach &" or a MI command ;; e.g. "-exec-run" or "-exec-attach". - (when (or (string-match "&\s*$" gdb-last-command) - (string-match "^-" gdb-last-command)) - (gdb-try-check-target-async-support)) + (if (or (string-match "&\s*$" gdb-last-command) + (string-match "^-" gdb-last-command)) + (progn (gdb-try-check-target-async-support) + (setq gud-async-running t)) + (setq gud-async-running nil)) (gdb-force-mode-line-update (propertize gdb-inferior-status 'face font-lock-type-face)) diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 09860a4cbde..3cc63aab84f 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -128,6 +128,10 @@ gud-running "Non-nil if debugged program is running. Used to gray out relevant toolbar icons.") +(defvar gud-async-running nil + "Non-nil if debugged program is running in async mode. +Check it when `gud-running' is t") + (defvar gud-target-name "--unknown--" "The apparent name of the program being debugged in a gud buffer.") @@ -261,13 +265,13 @@ gud-menu-map :visible (memq gud-minor-mode '(gdbmi gdb guiler dbx xdb jdb pdb))] ["Set Breakpoint" gud-break - :enable (not gud-running) + :enable (or (not gud-running) gud-async-running) :visible (gud-tool-bar-item-visible-no-fringe)] ["Temporary Breakpoint" gud-tbreak - :enable (not gud-running) + :enable (or (not gud-running) gud-async-running) :visible (memq gud-minor-mode '(gdbmi gdb sdb xdb))] ["Remove Breakpoint" gud-remove - :enable (not gud-running) + :enable (or (not gud-running) gud-async-running) :visible (gud-tool-bar-item-visible-no-fringe)] ["Continue to selection" gud-until :enable (not gud-running) @@ -283,7 +287,7 @@ gud-menu-map :visible (and (eq gud-minor-mode 'gdbmi) (gdb-show-run-p))] ["Run" gud-run - :enable (not gud-running) + :enable (or (not gud-running) gud-async-running) :visible (or (memq gud-minor-mode '(gdb dbx jdb)) (and (eq gud-minor-mode 'gdbmi) (or (not (gdb-show-run-p)) @@ -403,13 +407,15 @@ gud-find-file ;; Of course you may use `gud-def' with any other debugger command, including ;; user defined ones. -;; A macro call like (gud-def FUNC CMD KEY DOC) expands to a form +;; A macro call like (gud-def FUNC CMD KEY DOC ASYNC-OK) expands to a form ;; which defines FUNC to send the command CMD to the debugger, gives ;; it the docstring DOC, and binds that function to KEY in the GUD -;; major mode. The function is also bound in the global keymap with the +;; major mode. The FUNC still sends CMD when both ASYNC-OK and +;; `gud-async-running' are t even `gud-running' is t. +;; The function is also bound in the global keymap with the ;; GUD prefix. -(defmacro gud-def (func cmd key &optional doc) +(defmacro gud-def (func cmd key &optional doc async-ok) "Define FUNC to be a command sending CMD and bound to KEY, with optional doc string DOC. Certain %-escapes in the string arguments are interpreted specially if present. These are: @@ -434,7 +440,7 @@ gud-def (defalias ',func (lambda (arg) ,@(if doc (list doc)) (interactive "p") - (if (not gud-running) + (if (or (not gud-running) (and ,async-ok gud-async-running)) ,(if (stringp cmd) `(gud-call ,cmd arg) ;; Unused lexical warning if cmd does not use "arg". -- 2.27.0 --=-=-=-- ------------=_1693476842-24959-1--