aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-05-27 13:59:01 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-05-27 14:00:07 -0400
commit3947f654eabb1b6ccf8aad11ece46dc4b027f0f0 (patch)
treece1f687f4929daf2ce5aa10741c244cb1ab6e7ab /gdb/tui
parent7bd22f56a3cf47c6743f7f7989a6fa07f935d31b (diff)
downloadbinutils-3947f654eabb1b6ccf8aad11ece46dc4b027f0f0.zip
binutils-3947f654eabb1b6ccf8aad11ece46dc4b027f0f0.tar.gz
binutils-3947f654eabb1b6ccf8aad11ece46dc4b027f0f0.tar.bz2
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
Diffstat (limited to 'gdb/tui')
-rw-r--r--gdb/tui/tui-win.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index f036127..4e75a66 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -990,7 +990,6 @@ _initialize_tui_win ()
{
static struct cmd_list_element *tui_setlist;
static struct cmd_list_element *tui_showlist;
- struct cmd_list_element *cmd;
/* Define the classes of commands.
They will appear in the help list in the reverse of this order. */
@@ -1004,26 +1003,29 @@ _initialize_tui_win ()
add_com ("refresh", class_tui, tui_refresh_all_command,
_("Refresh the terminal display."));
- cmd = add_com ("tabset", class_tui, tui_set_tab_width_command, _("\
+ cmd_list_element *tabset_cmd
+ = add_com ("tabset", class_tui, tui_set_tab_width_command, _("\
Set the width (in characters) of tab stops.\n\
Usage: tabset N"));
- deprecate_cmd (cmd, "set tui tab-width");
+ deprecate_cmd (tabset_cmd, "set tui tab-width");
- cmd = add_com ("winheight", class_tui, tui_set_win_height_command, _("\
+ cmd_list_element *winheight_cmd
+ = add_com ("winheight", class_tui, tui_set_win_height_command, _("\
Set or modify the height of a specified window.\n\
Usage: winheight WINDOW-NAME [+ | -] NUM-LINES\n\
Use \"info win\" to see the names of the windows currently being displayed."));
- add_com_alias ("wh", "winheight", class_tui, 0);
- set_cmd_completer (cmd, winheight_completer);
+ add_com_alias ("wh", winheight_cmd, class_tui, 0);
+ set_cmd_completer (winheight_cmd, winheight_completer);
add_info ("win", tui_all_windows_info,
_("List of all displayed windows.\n\
Usage: info win"));
- cmd = add_com ("focus", class_tui, tui_set_focus_command, _("\
+ cmd_list_element *focus_cmd
+ = add_com ("focus", class_tui, tui_set_focus_command, _("\
Set focus to named window or next/prev window.\n\
Usage: focus [WINDOW-NAME | next | prev]\n\
Use \"info win\" to see the names of the windows currently being displayed."));
- add_com_alias ("fs", "focus", class_tui, 0);
- set_cmd_completer (cmd, focus_completer);
+ add_com_alias ("fs", focus_cmd, class_tui, 0);
+ set_cmd_completer (focus_cmd, focus_completer);
add_com ("+", class_tui, tui_scroll_forward_command, _("\
Scroll window forward.\n\
Usage: + [N] [WIN]\n\