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.