How to make gdb not ask me "y or n"?

6,773

gdb will ask you to confirm certain commands, if the value of the confirm setting is on. From Optional Warnings and Messages:

  • set confirm off
    Disables confirmation requests. Note that running GDB with the --batch option (see -batch) also automatically disables confirmation requests.
  • set confirm on
    Enables confirmation requests (the default).
  • show confirm
    Displays state of confirmation requests.

That's a single global setting for confirm. In case you want to disable confirmation just for the add-symbol-file command, you can define two hooks, which will run before and after the command:

(gdb) define hook-add-symbol-file
set confirm off
end
(gdb) define hookpost-add-symbol-file
set confirm on
end

If you want to disable confirmation just for a single invocation of a command, precede it with the server keyword, which is part of gdb's annotation system.

Share:
6,773

Related videos on Youtube

xmllmx
Author by

xmllmx

Updated on September 18, 2022

Comments

  • xmllmx
    xmllmx over 1 year

    When I use GDB command add-symbol-file to load the symbol, GDB always asks me 'y or n', like this:

    gdb> add-symbol-file mydrv.ko 0xa0070000
    add symbol table from file "mydrv.ko" at
            .text_addr = 0xa0070000
    (y or n)
    

    How to make it not ask and execute quietly?

    • Admin
      Admin over 9 years
      Try set confirm off.
    • Admin
      Admin over 9 years
      @MarkPlotnick, Thanks very much. It works!