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#61973: M-x gdb ends up with infinite prompts before starting the process Date: Mon, 06 Mar 2023 20:22:57 +0200 Message-ID: <83r0u17n9a.fsf@gnu.org> References: <7e2c2b51-f389-191e-9048-4021232a06e6@yandex.ru> <83v8jf8vz8.fsf@gnu.org> <0ad69ade-528f-e14e-1841-66c6967bb672@yandex.ru> <83jzzv8bv2.fsf@gnu.org> <8e3e1bf7-618f-93ec-af09-643b9b49978a@yandex.ru> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8258"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61973@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 06 19:24:53 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 1pZFVz-0001rr-53 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Mar 2023 19:24:51 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZFVI-0001kI-N3; Mon, 06 Mar 2023 13:24:08 -0500 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 1pZFVC-0001jr-Pr for bug-gnu-emacs@gnu.org; Mon, 06 Mar 2023 13:24:04 -0500 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 1pZFVC-0007TY-G9 for bug-gnu-emacs@gnu.org; Mon, 06 Mar 2023 13:24:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pZFVC-0008D2-5F for bug-gnu-emacs@gnu.org; Mon, 06 Mar 2023 13:24:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Mar 2023 18:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61973 X-GNU-PR-Package: emacs Original-Received: via spool by 61973-submit@debbugs.gnu.org id=B61973.167812699231500 (code B ref 61973); Mon, 06 Mar 2023 18:24:02 +0000 Original-Received: (at 61973) by debbugs.gnu.org; 6 Mar 2023 18:23:12 +0000 Original-Received: from localhost ([127.0.0.1]:43600 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZFUN-0008C0-Fh for submit@debbugs.gnu.org; Mon, 06 Mar 2023 13:23:11 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:47200) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZFUL-0008Bn-Nc for 61973@debbugs.gnu.org; Mon, 06 Mar 2023 13:23:10 -0500 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 1pZFUG-0006vH-AW; Mon, 06 Mar 2023 13:23:04 -0500 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=ArHOCWz+dQMm4NOD2KaUnF74oQcbEq201lBzDpXXVRM=; b=RAdIH2OiY8PF up0l66uQfnf9xeKAsQn7U2MTqYZrRu5StdxDZ6uKtGXVl21ubZJ7PKu7DVwf0EMu/u6i0xcCpZwkW 7v907WtNMW0ukcntCcyi/5hB7kblP4IU+Cu4wP9o1pbKH2fWKwF2f8JyQl1tPCwGNZ5mIZX4GV6UN PNoVUV7lDiqrGkqcz84W4CtTVuGMsA6M46bMe4pjLJ6USeMGnGn/OB8WBhCZykSeeZOBAjYEP+8R7 8Tw6VEvsWQjN8N3IxkN+OnpnXcOhuVUihkRQIedIWRKI5uqq2jvzZjn/uvgJoXyX7Q8himccE2qyC x4wFILKh8SgyJnxoeDGQmA==; 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 1pZFUF-00052T-QJ; Mon, 06 Mar 2023 13:23:04 -0500 In-Reply-To: <8e3e1bf7-618f-93ec-af09-643b9b49978a@yandex.ru> (message from Dmitry Gutov on Sun, 5 Mar 2023 17:26:08 +0200) 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:257409 Archived-At: > Date: Sun, 5 Mar 2023 17:26:08 +0200 > Cc: 61973@debbugs.gnu.org > From: Dmitry Gutov > > On 05/03/2023 17:19, Eli Zaretskii wrote: > > This confirms my suspicion: we don't recognize the situation > > where GDB waits for a response, and interpret your "y" response as a > > GDB command. > > First of all, though, it sends the debuginfod-related prompt to me 12 > times. I'm guessing that's because there is some scenario running > internally that tries to send some other commands to GDB while it's > waiting for a particular response (y/n), so it repeats the question 11 > times instead of reacting to those commands. Could you please try the patch below? I don't have access to a system where GDB can actually download the files from debuginfod servers, so I could test this only partially. Please test all the 3 possible values of the new defcustom gdb-debuginfod-enable-setting. TIA. diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 8b157dd..dc18938 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -255,6 +255,9 @@ gdb-non-stop It is initialized to `gdb-non-stop-setting' at the beginning of every GDB session.") +(defvar gdb-debuginfod-enable nil + "Whether the current GDB session can query debuginfod servers.") + (defvar-local gdb-buffer-type nil "One of the symbols bound in `gdb-buffer-rules'.") @@ -467,6 +470,26 @@ gdb-non-stop-setting :group 'gdb-non-stop :version "26.1") +(defcustom gdb-debuginfod-enable-setting 'ask + "Whether to enable downloading missing debug info from debuginfod servers. +The debuginfod servers are HTTP servers for distributing source +files and debug info files of programs. If GDB was built with +debuginfod support, it can query these servers when you debug a +program for which some of these files are not available locally, +and download the files if the servers have them. + +The value nil means never to download from debuginfod servers. +The value t means always download from debuginfod servers when +some source or debug info files are missing. +The value `ask', the default, means ask at the beginning of each +debugging session whether to download from debuginfod servers +during that session." + :type '(choice (const :tag "Never download from debuginfod servers" nil) + (const :tag "Download from debuginfod servers when necessary" t) + (const :tag "Ask whether to download for each session" ask)) + :group 'gdb + :version "29.1") + ;; TODO Some commands can't be called with --all (give a notice about ;; it in setting doc) (defcustom gdb-gud-control-all-threads t @@ -1021,6 +1044,11 @@ gdb (run-hooks 'gdb-mode-hook)) +(defconst gdb--string-regexp (rx "\"" + (* (or (seq "\\" nonl) + (not (any "\"\\")))) + "\"")) + (defun gdb-init-1 () ;; (Re-)initialize. (setq gdb-selected-frame nil @@ -1044,7 +1072,8 @@ gdb-init-1 gdb-threads-list '() gdb-breakpoints-list '() gdb-register-names '() - gdb-non-stop gdb-non-stop-setting) + gdb-non-stop gdb-non-stop-setting + gdb-debuginfod-enable gdb-debuginfod-enable-setting) ;; (gdbmi-bnf-init) ;; @@ -1053,6 +1082,15 @@ gdb-init-1 (gdb-force-mode-line-update (propertize "initializing..." 'face font-lock-variable-name-face)) + ;; This needs to be done before we ask GDB for anything that might + ;; 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?"))) + (gdb-input (format "-gdb-set debuginfod enabled %s" + (if gdb-debuginfod-enable "on" "off")) + 'gdb-debuginfod-message) + (gdb-get-buffer-create 'gdb-inferior-io) (gdb-clear-inferior-io) (gdb-inferior-io--init-proc (get-process "gdb-inferior")) @@ -1080,6 +1118,18 @@ gdb-init-1 (gdb-input "-file-list-exec-source-file" 'gdb-get-source-file) (gdb-input "-gdb-show prompt" 'gdb-get-prompt)) +(defun gdb-debuginfod-message () + "Show in the echo area GDB error response for a debuginfod command, if any." + (goto-char (point-min)) + (cond + ((re-search-forward "msg=\\(\".+\"\\)$" nil t) + ;; Supports debuginfod, but cannot perform command. + (message "%s" (buffer-substring (1+ (match-beginning 1)) + (1- (line-end-position))))) + ((re-search-forward "No symbol" nil t) + (message "This version of GDB doesn't support debuginfod commands.")) + (t (message nil)))) + (defun gdb-non-stop-handler () (goto-char (point-min)) (if (re-search-forward "No symbol" nil t) @@ -1148,11 +1198,6 @@ gdb-create-define-alist (declare-function tooltip-show "tooltip" (text &optional use-echo-area text-face default-face)) -(defconst gdb--string-regexp (rx "\"" - (* (or (seq "\\" nonl) - (not (any "\"\\")))) - "\"")) - (defun gdb-tooltip-print (expr) (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer) (goto-char (point-min))