21

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?

xmllmx
  • 1,750
  • 2
  • 19
  • 29

1 Answers1

24

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.

Mark Plotnick
  • 24,913
  • 2
  • 59
  • 81