假设我定义了一个包含别名的新 gdb 命令。
import gdb
import string
class PrettyPrintString (gdb.Command):
"Command to print strings with a mix of ascii and hex."
def __init__(self):
super (PrettyPrintString, self).__init__("ascii-print",
gdb.COMMAND_DATA,
gdb.COMPLETE_EXPRESSION, True)
gdb.execute("alias -a pp = ascii-print", True)
Run Code Online (Sandbox Code Playgroud)
现在,我想对脚本做一个小改动,并在同一个 gdb 会话中再次获取它。不幸的是,当我再次尝试获取源时,出现以下错误。
gdb.error: Alias already exists: pp
Run Code Online (Sandbox Code Playgroud)
如何删除原始别名并获取更新的脚本?
请注意,别名文档似乎没有说明删除别名的任何内容,我尝试过unalias,delete但都没有达到预期的效果。
您可以为函数定义关键字,而不是作为别名。例如我有
define w
where
end
Run Code Online (Sandbox Code Playgroud)
在我的 .gdbinit 中。重新定义作品,而不是重新别名。