Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define alias for gdb function

Tags:

gdb

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?

like image 819
Martin Wang Avatar asked Sep 18 '25 23:09

Martin Wang


2 Answers

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

(gdb) apropos alias
alias -- Alias one command to another
aliases -- Aliases of other commands
like image 39
matt Avatar answered Sep 23 '25 11:09

matt