2

I want to debug some C++ code in emacs with gdb. I tried to enter gdb with the command:

M-x RET gdb RET

Then I get a prompt that reads:

Enable debuginfod for this session? (y or [n])

Whatever I type, the exact same prompt comes up. I can run gdb from the command line perfectly fine and compiled it with g++ main.cpp -o main -g. However, inside of emacs, I can't.

I encountered something similar while trying to type input in the compilation buffer which I couldn't do. There the command C-u M-x compile command helped. I wanted to try this in this scenario as well but still the same prompt comes up over and over again. I don't have much experience with emacs in general so I appreciate any help :)

2 Answers 2

1

Emacs isn’t expecting a prompt from GDB here, so just change your GDB configuration so that there is no prompt. A quick search that anyone could have done suggests that adding set debuginfod enabled to your ~/.gdbinit file will fix it.

4
  • I didn't have that file. I created it, added the snippet. But it still shows up. I also added that off option afterwards.. Didn't work Jul 14, 2023 at 20:38
  • I also have a ~/.gdbinit file and adding it above the python script and it worked with the off option. Thanks Jul 14, 2023 at 20:47
  • I think the correct config file now is ~/.gdbinit, not ~/.gdbrc Jan 16 at 18:53
  • It’s always been ~/.gdbinit, as far as I know. It’s just that every other program in the world uses a filename that ends in rc.
    – db48x
    Jan 17 at 5:45
0

I think your problem is a recent regression. That's not the way it used to behave.

Sometimes, when M-x gdb RET fails, M-x gud-gdb RET still works. The gud-gdb mode doesn't have a rich graphical interface, so it's not the best debugging that emacs offers. However, it still shows the current line in your source code when single-stepping, so it's still better than gdb alone. If your only goal is to use gdb from emacs, this may work for you.

You will need to know gdb commands to use gud-gdb.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.