all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#61973: M-x gdb ends up with infinite prompts before starting the process
@ 2023-03-05  1:13 Dmitry Gutov
  2023-03-05  8:04 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Gutov @ 2023-03-05  1:13 UTC (permalink / raw)
  To: 61973

1. Run compiled 'emacs' from 'src'.
2. M-x gdb
3. Answer prompt: Run gdb (like this): gdb -i=mi ./emacs
4. See this prompt repeated indefinitely, no matter what I answer:

This GDB supports auto-downloading debuginfo from the following URLs:
https://debuginfod.ubuntu.com
Enable debuginfod for this session? (y or [n]) Please answer y or [n].

(Emacs 29, more or less latest.)





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#61973: M-x gdb ends up with infinite prompts before starting the process
  2023-03-05  1:13 bug#61973: M-x gdb ends up with infinite prompts before starting the process Dmitry Gutov
@ 2023-03-05  8:04 ` Eli Zaretskii
  2023-03-05 13:18   ` Dmitry Gutov
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2023-03-05  8:04 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 61973

> Date: Sun, 5 Mar 2023 03:13:35 +0200
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> 1. Run compiled 'emacs' from 'src'.
> 2. M-x gdb
> 3. Answer prompt: Run gdb (like this): gdb -i=mi ./emacs
> 4. See this prompt repeated indefinitely, no matter what I answer:
> 
> This GDB supports auto-downloading debuginfo from the following URLs:
> https://debuginfod.ubuntu.com
> Enable debuginfod for this session? (y or [n]) Please answer y or [n].
> 
> (Emacs 29, more or less latest.)

What GDB version is that?  If this is a recent problem, did it start
happening because you upgraded to a newer GDB version?

By "no matter what I answer, do you mean you tried both "y RET" and
"n RET", and the question is repeated regardless?

I don't have access to a system with a new enough GDB where debuginfod
is enabled, so I need you to please test the possible solutions.

First, if you invoke GDB from the shell's prompt in the same way,
i.e.

  $ gdb -i=mi ./emacs

does it then ask the same question?  And if you then type "y RET",
does it stop asking, and does debugging Emacs then works as expected?
Can you show me the entire output of this session invoked from the
shell's prompt, up to and including the reaction to your "y RET"
response?

Next, can you enable gdb-enable-debug minor mode, and post the
contents of gdb-debug-log (formatted with pp, please) after these
questions are asked and you answer them?

Finally, if you add the following line to your ~/.gdbinit, does the
problem go away?

  set debuginfod enabled on

(If you don't have a ~/.gdbinit file, create it and add this single
line to it.)  With this line, GDB should not ask the question at all.

Thanks.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#61973: M-x gdb ends up with infinite prompts before starting the process
  2023-03-05  8:04 ` Eli Zaretskii
@ 2023-03-05 13:18   ` Dmitry Gutov
  2023-03-05 15:19     ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Gutov @ 2023-03-05 13:18 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61973

On 05/03/2023 10:04, Eli Zaretskii wrote:
>> Date: Sun, 5 Mar 2023 03:13:35 +0200
>> From: Dmitry Gutov <dgutov@yandex.ru>
>>
>> 1. Run compiled 'emacs' from 'src'.
>> 2. M-x gdb
>> 3. Answer prompt: Run gdb (like this): gdb -i=mi ./emacs
>> 4. See this prompt repeated indefinitely, no matter what I answer:
>>
>> This GDB supports auto-downloading debuginfo from the following URLs:
>> https://debuginfod.ubuntu.com
>> Enable debuginfod for this session? (y or [n]) Please answer y or [n].
>>
>> (Emacs 29, more or less latest.)
> 
> What GDB version is that?  If this is a recent problem, did it start
> happening because you upgraded to a newer GDB version?

$ gdb --version
GNU gdb (Ubuntu 12.1-3ubuntu2) 12.1

I never really use 'M-x gdb', all the time before I just used it from 
the terminal. But I saw some recent GDB related post on Reddit where you 
asked for bug reports and decided to give it a try.

What I _can_ say, though, is that Emacs 25-28 all behave the same way.

All that as long as my src/.gdbinit is added with 
add-auto-load-safe-path in ~/.config/gdb/gdbinit.

Without it, 'M-x gdb' can start Emacs, but then all the special commands 
are unavailable, of course.

> By "no matter what I answer, do you mean you tried both "y RET" and
> "n RET", and the question is repeated regardless?

That's right.

> I don't have access to a system with a new enough GDB where debuginfod
> is enabled, so I need you to please test the possible solutions.
> 
> First, if you invoke GDB from the shell's prompt in the same way,
> i.e.
> 
>    $ gdb -i=mi ./emacs
> 
> does it then ask the same question?  And if you then type "y RET",
> does it stop asking, and does debugging Emacs then works as expected?

It only stops at prompt, in which I'm supposed to input 'run -Q'.

After I do that, it doesn't ask me anything anymore. There is a lot of 
input there, but these lines look relevant (see the end):

(gdb)
run -Q
&"run -Q\n"
~"Starting program: /home/dgutov/vc/emacs/src/emacs -Q\n"
=thread-group-started,id="i1",pid="1352423"
=thread-created,id="1",group-id="i1"
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00005555555a5522",func="terminate_due_to_signal",file="emacs.c",fullname="/home/dgutov/vc/emacs/src/emacs.c",line="426",thread-groups=["i1"],times="0",original-location="terminate_due_to_signal"}
=breakpoint-modified,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0000555555699f70",func="x_error_quitter",file="xterm.c",fullname="/home/dgutov/vc/emacs/src/xterm.c",line="26119",thread-groups=["i1"],times="0",original-location="x_error_quitter"}
=library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1",ranges=[{from="0x00007ffff7fc80a0",to="0x00007ffff7ff0465"}]
~"Debuginfod has been enabled.\nTo make this setting permanent, add 'set 
debuginfod enabled on' to .gdbinit.\n"
^running
*running,thread-id="all"

> Can you show me the entire output of this session invoked from the
> shell's prompt, up to and including the reaction to your "y RET"
> response?

$ gdb emacs
GNU gdb (Ubuntu 12.1-3ubuntu2) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
     <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from emacs...
warning: File "/home/dgutov/vc/emacs-28/src/.gdbinit" auto-loading has 
been declined by your `auto-load safe-path' set to 
"$debugdir:$datadir/auto-load:/home/dgutov/vc/emacs/src/.gdbinit:/home/dgutov/vc/emacs-master/src/.gdbinit".
To enable execution of this file add
	add-auto-load-safe-path /home/dgutov/vc/emacs-28/src/.gdbinit
line to your configuration file "/home/dgutov/.config/gdb/gdbinit".
To completely disable this security protection add
	set auto-load safe-path /
line to your configuration file "/home/dgutov/.config/gdb/gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the 
shell:
	info "(gdb)Auto-loading safe path"
(gdb) run -Q
Starting program: /home/dgutov/vc/emacs-28/src/emacs -Q

This GDB supports auto-downloading debuginfo from the following URLs:
https://debuginfod.ubuntu.com
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

(emacs:1350264): dbind-WARNING **: 14:41:06.146: Couldn't connect to 
accessibility bus: Failed to connect to socket 
/root/.cache/at-spi/bus_1: Permission denied
[New Thread 0x7ffff0dff6c0 (LWP 1350270)]
[New Thread 0x7fffebfff6c0 (LWP 1350271)]
[New Thread 0x7fffeb7fe6c0 (LWP 1350272)]
[New Thread 0x7fffeaffd6c0 (LWP 1350273)]
[Thread 0x7fffeaffd6c0 (LWP 1350273) exited]
[New Thread 0x7fffeaffd6c0 (LWP 1350274)]
[New Thread 0x7fffea7fc6c0 (LWP 1350275)]
[Thread 0x7fffeaffd6c0 (LWP 1350274) exited]
[Thread 0x7fffea7fc6c0 (LWP 1350275) exited]
[New Thread 0x7fffea7fc6c0 (LWP 1350276)]

> Next, can you enable gdb-enable-debug minor mode, and post the
> contents of gdb-debug-log (formatted with pp, please) after these
> questions are asked and you answer them?

Seems to be pretty-printed already (note that I only pressed 'y' twice):

((recv . "~\"Please answer y or [n].\\n\"
~\"\\nThis GDB supports auto-downloading debuginfo from the following 
URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
session? (y or [n]) \"
")
  (mi-send .
	  #("-interpreter-exec console \"y\"
" 27 28
(fontified t)))
  (recv . "~\"Please answer y or [n].\\n\"
~\"\\nThis GDB supports auto-downloading debuginfo from the following 
URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
session? (y or [n]) \"
")
  (mi-send .
	  #("-interpreter-exec console \"y\"
" 27 28
(fontified t)))
  (recv . "~\"Please answer y or [n].\\n\"
~\"\\nThis GDB supports auto-downloading debuginfo from the following 
URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
session? (y or [n]) \"
~\"Please answer y or [n].\\n\"
~\"\\nThis GDB supports auto-downloading debuginfo from the following 
URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
session? (y or [n]) \"
~\"Please answer y or [n].\\n\"
~\"\\nThis GDB supports auto-downloading debuginfo from the following 
URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
session? (y or [n]) \"
~\"Please answer y or [n].\\n\"
~\"\\nThis GDB supports auto-downloading debuginfo from the following 
URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
session? (y or [n]) \"
")
  (send-item "17-list-target-features" gdb-check-target-async)
  (send-item "16-gdb-set target-async 1" ignore)
  (send-item "15-break-list" #f(compiled-function
			       (&rest args)
			       #<bytecode 0x991682c1965c328>))
  (send-item "14-thread-info" #f(compiled-function
				(&rest args)
				#<bytecode 0x991682cb100d328>))
  (recv . "~\"Breakpoint 2 at 0x145f70: file xterm.c, line 26119.\\n\"
=breakpoint-created,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x0000000000145f70\",func=\"x_error_quitter\",file=\"xterm.c\",fullname=\"/home/dgutov/vc/emacs/src/xterm.c\",line=\"26119\",thread-groups=[\"i1\"],times=\"0\",original-location=\"x_error_quitter\"}
(gdb)
1^done
(gdb)
2^done
(gdb)
3^done
(gdb)
4^done
(gdb)
5^done
(gdb)
~\"\\nThis GDB supports auto-downloading debuginfo from the following 
URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
session? (y or [n]) \"
~\"Please answer y or [n].\\n\"
~\"\\nThis GDB supports auto-downloading debuginfo from the following 
URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
session? (y or [n]) \"
~\"Please answer y or [n].\\n\"
~\"\\nThis GDB supports auto-downloading debuginfo from the following 
URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
session? (y or [n]) \"
~\"Please answer y or [n].\\n\"
~\"\\nThis GDB supports auto-downloading debuginfo from the following 
URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
session? (y or [n]) \"
~\"Please answer y or [n].\\n\"
~\"\\nThis GDB supports auto-downloading debuginfo from the following 
URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
session? (y or [n]) \"
~\"Please answer y or [n].\\n\"
~\"\\nThis GDB supports auto-downloading debuginfo from the following 
URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
session? (y or [n]) \"
~\"Please answer y or [n].\\n\"
~\"\\nThis GDB supports auto-downloading debuginfo from the following 
URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
session? (y or [n]) \"
~\"Please answer y or [n].\\n\"
~\"\\nThis GDB supports auto-downloading debuginfo from the following 
URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
session? (y or [n]) \"
")
  (recv . "=cmd-param-changed,param=\"print pretty\",value=\"on\"
=cmd-param-changed,param=\"print sevenbit-strings\",value=\"on\"
~\"DISPLAY = :1\\n\"
~\"TERM = dumb\\n\"
=breakpoint-created,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x0000000000051522\",func=\"terminate_due_to_signal\",file=\"emacs.c\",fullname=\"/home/dgutov/vc/emacs/src/emacs.c\",line=\"426\",thread-groups=[\"i1\"],times=\"0\",original-location=\"terminate_due_to_signal\"}
")
  (recv . "~\"SIGINT is used by the debugger.\\nAre you sure you want to 
change it? \"
~\"(y or n) [answered Y; input not from terminal]\\n\"
")
  (recv . 
"=cmd-param-changed,param=\"directories\",value=\"/home/dgutov/vc/emacs/src/../lwlib:$cdir:$cwd\"
")
  (recv . "~\"Reading symbols from emacs...\\n\"
")
  (recv . "=thread-group-added,id=\"i1\"
~\"GNU gdb (Ubuntu 12.1-3ubuntu2) 12.1\\n\"
~\"Copyright (C) 2022 Free Software Foundation, Inc.\\n\"
~\"License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>\\nThis is free software: you are free 
to change and redistribute it.\\nThere is NO WARRANTY, to the extent 
permitted by law.\"
~\"\\nType \\\"show copying\\\" and \\\"show warranty\\\" for details.\\n\"
~\"This GDB was configured as \\\"x86_64-linux-gnu\\\".\\n\"
~\"Type \\\"show configuration\\\" for configuration details.\\n\"
~\"For bug reporting instructions, please see:\\n\"
~\"<https://www.gnu.org/software/gdb/bugs/>.\\n\"
~\"Find the GDB manual and other documentation resources online at:\\n 
  <http://www.gnu.org/software/gdb/documentation/>.\"
~\"\\n\\n\"
~\"For help, type \\\"help\\\".\\n\"
~\"Type \\\"apropos word\\\" to search for commands related to 
\\\"word\\\"...\\n\"
")
  (send-item "13-break-list" #f(compiled-function
			       (&rest args)
			       #<bytecode 0x991682c1965c328>))
  (send-item "12-thread-info" #f(compiled-function
				(&rest args)
				#<bytecode 0x991682cb100d328>))
  (send-item "11-break-list" #f(compiled-function
			       (&rest args)
			       #<bytecode 0x991682c1965c328>))
  (send-item "10-thread-info" #f(compiled-function
				(&rest args)
				#<bytecode 0x991682cb100d328>))
  (send-item "9-stack-info-frame" gdb-frame-handler)
  (send-item "8-gdb-show prompt" gdb-get-prompt)
  (send-item "7-file-list-exec-source-file" gdb-get-source-file)
  (send-item "6-file-list-exec-source-files" gdb-get-source-file-list)
  (send-item "5-enable-frame-filters" ignore)
  (send-item "4-enable-pretty-printing" ignore)
  (send-item "3-gdb-set non-stop 1" gdb-non-stop-handler)
  (send-item "2-gdb-set height 0" ignore)
  (send-item "1-inferior-tty-set /dev/pts/10" ignore))

> Finally, if you add the following line to your ~/.gdbinit, does the
> problem go away?
> 
>    set debuginfod enabled on

That helps. 'set debuginfod enabled off' also works.

> (If you don't have a ~/.gdbinit file, create it and add this single
> line to it.)  With this line, GDB should not ask the question at all.

I had to use ~/.config/gdb/gdbinit, on account of its existence.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#61973: M-x gdb ends up with infinite prompts before starting the process
  2023-03-05 13:18   ` Dmitry Gutov
@ 2023-03-05 15:19     ` Eli Zaretskii
  2023-03-05 15:26       ` Dmitry Gutov
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2023-03-05 15:19 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 61973

> Date: Sun, 5 Mar 2023 15:18:48 +0200
> Cc: 61973@debbugs.gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> > Next, can you enable gdb-enable-debug minor mode, and post the
> > contents of gdb-debug-log (formatted with pp, please) after these
> > questions are asked and you answer them?
> 
> Seems to be pretty-printed already (note that I only pressed 'y' twice):
> 
> ((recv . "~\"Please answer y or [n].\\n\"
> ~\"\\nThis GDB supports auto-downloading debuginfo from the following 
> URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
> session? (y or [n]) \"
> ")
>   (mi-send .
> 	  #("-interpreter-exec console \"y\"
> " 27 28
> (fontified t)))
>   (recv . "~\"Please answer y or [n].\\n\"
> ~\"\\nThis GDB supports auto-downloading debuginfo from the following 
> URLs:\\nhttps://debuginfod.ubuntu.com \\nEnable debuginfod for this 
> session? (y or [n]) \"
> ")
>   (mi-send .
> 	  #("-interpreter-exec console \"y\"
> " 27 28
> (fontified t)))

Thanks.  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.  So we send it as a command: that's what the
"-interpreter-exec console" thing is about.  So GDB waits for "y" or
"n", but gets "-interpreter-exec console \"y\"".

We need to teach gdb-mi.el to recognize these prompts.  Will look into
that.

> > Finally, if you add the following line to your ~/.gdbinit, does the
> > problem go away?
> > 
> >    set debuginfod enabled on
> 
> That helps. 'set debuginfod enabled off' also works.

Yes, anything other than "ask" (which is the default).

This will serve as a workaround until the solution is found and
installed.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#61973: M-x gdb ends up with infinite prompts before starting the process
  2023-03-05 15:19     ` Eli Zaretskii
@ 2023-03-05 15:26       ` Dmitry Gutov
  2023-03-06 18:22         ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Gutov @ 2023-03-05 15:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61973

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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#61973: M-x gdb ends up with infinite prompts before starting the process
  2023-03-05 15:26       ` Dmitry Gutov
@ 2023-03-06 18:22         ` Eli Zaretskii
  2023-03-06 22:48           ` Dmitry Gutov
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2023-03-06 18:22 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 61973

> Date: Sun, 5 Mar 2023 17:26:08 +0200
> Cc: 61973@debbugs.gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> 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))





^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#61973: M-x gdb ends up with infinite prompts before starting the process
  2023-03-06 18:22         ` Eli Zaretskii
@ 2023-03-06 22:48           ` Dmitry Gutov
  2023-03-07 12:49             ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Gutov @ 2023-03-06 22:48 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61973

On 06/03/2023 20:22, Eli Zaretskii wrote:
>> Date: Sun, 5 Mar 2023 17:26:08 +0200
>> Cc:61973@debbugs.gnu.org
>> From: Dmitry Gutov<dgutov@yandex.ru>
>>
>> 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.

Looking good! Thank you.

I have tries all 3 possible values, and the behavior looks as expected. 
With 't', I even see a small delay when launching the process, 
presumably from contacting some debuginfo server.

I haven't been able to verify that the debuginfo stuff is actually 
working (nor sure where to look), but the basic functionality is now okay.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#61973: M-x gdb ends up with infinite prompts before starting the process
  2023-03-06 22:48           ` Dmitry Gutov
@ 2023-03-07 12:49             ` Eli Zaretskii
  2023-03-07 18:27               ` Dmitry Gutov
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2023-03-07 12:49 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 61973-done

> Date: Tue, 7 Mar 2023 00:48:59 +0200
> Cc: 61973@debbugs.gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> > 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.
> 
> Looking good! Thank you.

Thanks, installed, and closing the bug.

> I have tries all 3 possible values, and the behavior looks as expected. 
> With 't', I even see a small delay when launching the process, 
> presumably from contacting some debuginfo server.
> 
> I haven't been able to verify that the debuginfo stuff is actually 
> working (nor sure where to look), but the basic functionality is now okay.

Apparently, if you do:

  set debuginfo verbose 1

(probably in your ~/.gdbinit file or somesuch, so that it is set from
the beginning of the session), it is supposed to show you messages
about downloading.  But this is documented to be 1 by default, so
maybe you don't see it because gdb-mi.el "swallows" those messages?
Try from the shell prompt and see if you get any messages.  They are
supposed to begin with "Downloading".  I think the download will only
happen if you debug a program whose sources and/or debug info are not
available locally.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#61973: M-x gdb ends up with infinite prompts before starting the process
  2023-03-07 12:49             ` Eli Zaretskii
@ 2023-03-07 18:27               ` Dmitry Gutov
  0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Gutov @ 2023-03-07 18:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61973-done

On 07/03/2023 14:49, Eli Zaretskii wrote:
> They are
> supposed to begin with "Downloading".  I think the download will only
> happen if you debug a program whose sources and/or debug info are not
> available locally.

Indeed, that seems to happen in this case.

Thanks.





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-03-07 18:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-05  1:13 bug#61973: M-x gdb ends up with infinite prompts before starting the process Dmitry Gutov
2023-03-05  8:04 ` Eli Zaretskii
2023-03-05 13:18   ` Dmitry Gutov
2023-03-05 15:19     ` Eli Zaretskii
2023-03-05 15:26       ` Dmitry Gutov
2023-03-06 18:22         ` Eli Zaretskii
2023-03-06 22:48           ` Dmitry Gutov
2023-03-07 12:49             ` Eli Zaretskii
2023-03-07 18:27               ` Dmitry Gutov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.