Get rid of "quit anyway" prompt using GDB: Just kill the process and quit

Gdb

Gdb Problem Overview


Consider:

(gdb) q
A debugging session is active.

        Inferior 1 [process 9018] will be killed.

Quit anyway? (y or n) y

What is a .gdbinit option to make GDB always kill the running process at a quit request?

I know that GDB can attach to already-running processes, so it would be bad to kill them at quit. But for a processes started from it, a need to confirm your actions starts to annoy at a second quit.

Gdb Solutions


Solution 1 - Gdb

Turning confirmation prompts off globally disabled many other useful checks, such as the one to ask you if you really want to delete all breakpoints when you type "delete".

It would be better to disable the prompt only for the quit command. You can do that by adding this hook to your ~/.gdbinit (for current user) or /etc/gdb/gdbinit (for all users):

define hook-quit
    set confirm off
end

Solution 2 - Gdb

set confirm off

See gdb doc for details

Solution 3 - Gdb

Another option is to define a new command that quits without asking for confirmation:

define qquit
  set confirm off
  quit
end
document qquit
Quit without asking for confirmation.
end

Now you can use qquit or just qq to exit quickly, without changing the default behaviour of quit

Solution 4 - Gdb

In conclusion this will run the program directly and don't ask for quit confirmation:

gdb -ex="set confirm off" -ex=r --args ...

Solution 5 - Gdb

Type:Ctrl + D

Before

xx@yy: ~>

> (gdb)

After > (gdb) quit

Then

xx@yy: ~>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionkagali-sanView Question on Stackoverflow
Solution 1 - GdbEricView Answer on Stackoverflow
Solution 2 - Gdbks1322View Answer on Stackoverflow
Solution 3 - GdbJonathan WakelyView Answer on Stackoverflow
Solution 4 - GdbMattias WadmanView Answer on Stackoverflow
Solution 5 - GdbregView Answer on Stackoverflow