Martin Wang
Martin Wang

Reputation: 1007

How to define alias for gdb function

GDB supports function by command define. I want to write a helper script for GDB, and I hope each function has a meaningful name and an alias, just like bt and backtrace.

Does GDB support this feature?

Upvotes: 3

Views: 4826

Answers (2)

An example to complete matt's answer:

alias ir = info registers
ir

as documented at: https://sourceware.org/gdb/onlinedocs/gdb/Aliases.html

Unlike Bash aliases, you cannot pass arguments to the definition of those aliases, e.g.:

alias ir = info registers eax

The registers part is only accepted because it is not an argument, but a subcommand.

But you can pass arguments when using the alias:

ir eax

You can then list all currently defined aliases with:

help aliases

Upvotes: 4

matt
matt

Reputation: 5614

(gdb) apropos alias
alias -- Alias one command to another
aliases -- Aliases of other commands

Upvotes: 1

Related Questions