diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-05-27 13:59:01 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-05-27 14:00:07 -0400 |
commit | 3947f654eabb1b6ccf8aad11ece46dc4b027f0f0 (patch) | |
tree | ce1f687f4929daf2ce5aa10741c244cb1ab6e7ab /gdb/source.c | |
parent | 7bd22f56a3cf47c6743f7f7989a6fa07f935d31b (diff) | |
download | fsf-binutils-gdb-3947f654eabb1b6ccf8aad11ece46dc4b027f0f0.zip fsf-binutils-gdb-3947f654eabb1b6ccf8aad11ece46dc4b027f0f0.tar.gz fsf-binutils-gdb-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/source.c')
-rw-r--r-- | gdb/source.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/gdb/source.c b/gdb/source.c index 54cb45f..94e61cc 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1904,8 +1904,6 @@ void _initialize_source (); void _initialize_source () { - struct cmd_list_element *c; - init_source_path (); /* The intention is to use POSIX Basic Regular Expressions. @@ -1914,7 +1912,8 @@ _initialize_source () just an approximation. */ re_set_syntax (RE_SYNTAX_GREP); - c = add_cmd ("directory", class_files, directory_command, _("\ + cmd_list_element *directory_cmd + = add_cmd ("directory", class_files, directory_command, _("\ Add directory DIR to beginning of search path for source files.\n\ Forget cached info on source file locations and line positions.\n\ DIR can also be $cwd for the current working directory, or $cdir for the\n\ @@ -1923,9 +1922,9 @@ With no argument, reset the search path to $cdir:$cwd, the default."), &cmdlist); if (dbx_commands) - add_com_alias ("use", "directory", class_files, 0); + add_com_alias ("use", directory_cmd, class_files, 0); - set_cmd_completer (c, filename_completer); + set_cmd_completer (directory_cmd, filename_completer); add_setshow_optional_filename_cmd ("directories", class_files, @@ -1959,16 +1958,18 @@ This sets the default address for \"x\" to the line's first instruction\n\ so that \"x/i\" suffices to start examining the machine code.\n\ The address is also stored as the value of \"$_\".")); - add_com ("forward-search", class_files, forward_search_command, _("\ + cmd_list_element *forward_search_cmd + = add_com ("forward-search", class_files, forward_search_command, _("\ Search for regular expression (see regex(3)) from last line listed.\n\ The matching line number is also stored as the value of \"$_\".")); - add_com_alias ("search", "forward-search", class_files, 0); - add_com_alias ("fo", "forward-search", class_files, 1); + add_com_alias ("search", forward_search_cmd, class_files, 0); + add_com_alias ("fo", forward_search_cmd, class_files, 1); - add_com ("reverse-search", class_files, reverse_search_command, _("\ + cmd_list_element *reverse_search_cmd + = add_com ("reverse-search", class_files, reverse_search_command, _("\ Search backward for regular expression (see regex(3)) from last line listed.\n\ The matching line number is also stored as the value of \"$_\".")); - add_com_alias ("rev", "reverse-search", class_files, 1); + add_com_alias ("rev", reverse_search_cmd, class_files, 1); add_setshow_integer_cmd ("listsize", class_support, &lines_to_list, _("\ Set number of source lines gdb will list by default."), _("\ |