From 3947f654eabb1b6ccf8aad11ece46dc4b027f0f0 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 27 May 2021 13:59:01 -0400 Subject: gdb: make add_com_alias accept target as a cmd_list_element The alias creation functions currently accept a name to specify the target command. They pass this to add_alias_cmd, which needs to lookup the target command by name. Given that: - We don't support creating an alias for a command before that command exists. - We always use add_info_alias just after creating that target command, and therefore have access to the target command's cmd_list_element. ... change add_com_alias to accept the target command as a cmd_list_element (other functions are done in subsequent patches). This ensures we don't create the alias before the target command, because you need to get the cmd_list_element from somewhere when you call the alias creation function. And it avoids an unecessary command lookup. So it seems better to me in every aspect. gdb/ChangeLog: * command.h (add_com_alias): Accept target as cmd_list_element. Update callers. Change-Id: I24bed7da57221cc77606034de3023fedac015150 --- gdb/guile/guile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gdb/guile/guile.c') diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index 0166355..a707c89 100644 --- a/gdb/guile/guile.c +++ b/gdb/guile/guile.c @@ -726,8 +726,8 @@ cmd_list_element *guile_cmd_element = nullptr; static void install_gdb_commands (void) { - add_com ("guile-repl", class_obscure, - guile_repl_command, + cmd_list_element *guile_repl_cmd + = add_com ("guile-repl", class_obscure, guile_repl_command, #ifdef HAVE_GUILE _("\ Start an interactive Guile prompt.\n\ @@ -742,7 +742,7 @@ Guile scripting is not supported in this copy of GDB.\n\ This command is only a placeholder.") #endif /* HAVE_GUILE */ ); - add_com_alias ("gr", "guile-repl", class_obscure, 1); + add_com_alias ("gr", guile_repl_cmd, class_obscure, 1); /* Since "help guile" is easy to type, and intuitive, we add general help in using GDB+Guile to this command. */ @@ -778,7 +778,7 @@ Guile scripting is not supported in this copy of GDB.\n\ This command is only a placeholder.") #endif /* HAVE_GUILE */ ); - add_com_alias ("gu", "guile", class_obscure, 1); + add_com_alias ("gu", guile_cmd_element, class_obscure, 1); add_basic_prefix_cmd ("guile", class_obscure, _("Prefix command for Guile preference settings."), -- cgit v1.1