Aliases are a feature of the shell. Defining an alias creates a new shell command name. It's recognized only by the shell, and only when it appears as a command name.
For example, if you type
> ff
at a shell prompt, it will invoke your alias, but if you type
> echo ff
the ff
is just an argument, not a command. (At least in bash, you can play some tricks if the alias definition ends with a space. See Stéphane Chazelas's answer for a possible solution if you're determined to use shell aliases.)
You typed
> gdb ff
so the shell invoked gdb
, passing it the string ff
as an argument.
You can pass arguments to the debugged program via the gdb
command line, but you have to use the --args
option. For example:
> gdb firefox --safe-mode
tries (and fails) to treat --safe-mode
as an option to gdb
. To run the command with an argument, you can do it manually:
> gdb firefox
...
(gdb) run --safe-mode
or, as thrig's answer reminds me, you can use --args
:
> gdb --args firefox --safe-mode
...
(gdb) run
(The first argument following --args
is the command name; all remaining arguments are passed to the invoked command.)
It's possible to extract the arguments from a shell alias, but I'd recommend just defining a separate alias:
alias ff='firefox --safe-mode'
alias gdbff='gdb --args firefox --safe-mode'
Or, better, use shell functions, which are much more versatile. The bash manual says:
For almost every purpose, shell functions are preferred over aliases.
gdb zsh -c ff
instead.