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
This commit is contained in:
parent
7bd22f56a3
commit
3947f654ea
22 changed files with 219 additions and 173 deletions
21
gdb/source.c
21
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."), _("\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue