Re: [RFA] More completion improvements

Eli Zaretskii
2001-02-17T23:34:00Z

On Sun, 18 Feb 2001, Eli Zaretskii wrote:

> On Wed, 14 Feb 2001, Fernando Nasser wrote:
>
> > After committing, please post the final version so it makes into the list archives.
>
> Here's what I committed:
>
> 2001-02-18 Eli Zaretskii <eliz@is.elta.co.il>
>
> * completer.c (gdb_completer_file_name_break_characters): Remove
> slash from file-name break characters.
> [__MSDOS__]: Special definition for DOS/Windows file names.
> (line_completion_function): When completing on file names, bump
> `p' to the first file-name constituent character of `word', before
> invoking the completer.

Now that this is done, it's time to use it. The following patches make
some commands use file-name completion instead of the default symbol-name
completion. In addition, set-demangling-style now correctly completes on
the known style names.

People whose approval I'm seeking are:

Fernando is listed as the maintainer of the rdi stuff. Chris is
responsible for win32-nat.c. I think solib.c and tracepoint.c are
Michael Snyder's. cli-cmds.c seems to be Fernando's again. I couldn't
identify who are the maintainers for the rest.

2001-02-17 Eli Zaretskii <eliz@is.elta.co.il>

* demangle.c (demangling_style_names): New variable.
(_initialize_demangler): Fill demangling_style_names with the
names of known demangling styles from libiberty_demanglers[]. Use
add_set_enum_cmd instead of add_set_cmd, to get completion on
demangling style names.

* proc-api.c (_initialize_proc_api): Make `procfs-file' use
file-name completion.

* remote-rdi.c (_initialize_remote_rdi): Ditto for `rdilogfile'.

* solib.c (_initialize_solib): Ditto for `solib-search-path' and
`solib-absolute-prefix'.

* tracepoint.c (_initialize_tracepoint): Ditto for
`save-tracepoints'.

* win32-nat.c (_initialize_inftarg): Ditto for `dll-symbols'.

2001-02-12 Eli Zaretskii <eliz@is.elta.co.il>

* cli/cli-cmds.c (init_cli_cmds): Make `shell' and `make' use
file-name completion.

* infcmd.c (_initialize_infcmd): Make the following commands use
the file-name completer: `tty', `args', `path', `paths', and
`run'.

--- gdb/cli/cli-cmds.c~0 Fri Feb 2 21:37:48 2001
+++ gdb/cli/cli-cmds.c Mon Feb 12 23:22:28 2001
@@ -778,9 +778,10 @@
"Generic command for showing gdb debugging flags",
&showdebuglist, "show debug ", 0, &showlist);

- add_com ("shell", class_support, shell_escape,
- "Execute the rest of the line as a shell command. \n\
+ c = add_com ("shell", class_support, shell_escape,
+ "Execute the rest of the line as a shell command. \n\
With no arguments, run an inferior shell.");
+ c->completer = filename_completer;

/* NOTE: cagney/2000-03-20: Being able to enter ``(gdb) !ls'' would
be a really useful feature. Unfortunately, the below wont do
@@ -791,8 +792,9 @@
if (xdb_commands)
add_com_alias ("!", "shell", class_support, 0);

- add_com ("make", class_support, make_command,
- "Run the ``make'' program using the rest of the line as arguments.");
+ c = add_com ("make", class_support, make_command,
+ "Run the ``make'' program using the rest of the line as arguments.");
+ c->completer = filename_completer;
add_cmd ("user", no_class, show_user,
"Show definitions of user defined commands.\n\
Argument is the name of the user defined command.\n\
--- gdb/infcmd.c~0 Wed Jan 31 03:24:00 2001
+++ gdb/infcmd.c Mon Feb 12 23:03:02 2001
@@ -40,6 +40,7 @@
#endif
#include "event-top.h"
#include "parser-defs.h"
+#include "completer.h"

/* Functions exported for general use: */

@@ -1792,16 +1793,18 @@
{
struct cmd_list_element *c;

- add_com ("tty", class_run, tty_command,
- "Set terminal for future runs of program being debugged.");
+ c= add_com ("tty", class_run, tty_command,
+ "Set terminal for future runs of program being debugged.");
+ c->completer = filename_completer;

add_show_from_set
- (add_set_cmd ("args", class_run, var_string_noescape,
- (char *) &inferior_args,
- "Set argument list to give program being debugged when it is started.\n\
+ (c = add_set_cmd ("args", class_run, var_string_noescape,
+ (char *) &inferior_args,
+ "Set argument list to give program being debugged when it is started.\n\
Follow this command with any number of args, to be passed to the program.",
&setlist),
&showlist);
+ c->completer = filename_completer;

c = add_cmd
("environment", no_class, environment_info,
@@ -1829,12 +1832,13 @@
&setlist);
c->completer = noop_completer;

- add_com ("path", class_files, path_command,
- "Add directory DIR(s) to beginning of search path for object files.\n\
+ c = add_com ("path", class_files, path_command,
+ "Add directory DIR(s) to beginning of search path for object files.\n\
$cwd in the path means the current working directory.\n\
This path is equivalent to the $PATH shell variable. It is a list of\n\
directories, separated by colons. These directories are searched to find\n\
fully linked executable files and separately compiled object files as needed.");
+ c->completer = filename_completer;

c = add_cmd ("paths", no_class, path_info,
"Current search path for finding object files.\n\
@@ -1926,13 +1930,14 @@
add_com_alias ("c", "cont", class_run, 1);
add_com_alias ("fg", "cont", class_run, 1);

- add_com ("run", class_run, run_command,
+ c = add_com ("run", class_run, run_command,
"Start debugged program. You may specify arguments to give it.\n\
Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
To cancel previous arguments and run with no arguments,\n\
use \"set args\" without arguments.");
+ c->completer = filename_completer;
add_com_alias ("r", "run", class_run, 1);
if (xdb_commands)
add_com ("R", class_run, run_no_args_command,

--- gdb/demangle.c~0 Fri Dec 15 03:01:46 2000
+++ gdb/demangle.c Sat Feb 17 13:43:02 2001
@@ -49,6 +49,11 @@ extern void _initialize_demangler (void)

static char *current_demangling_style_string;

+/* The array of names of the known demanglyng styles. Generated by
+ _initialize_demangler from libiberty_demanglers[] array. */
+
+static const char **demangling_style_names;
+
static void set_demangling_command (char *, int, struct cmd_list_element *);

/* Set current demangling style. Called by the "set demangle-style"
@@ -173,12 +178,26 @@ void
_initialize_demangler (void)
{
struct cmd_list_element *set, *show;
+ int i, ndems;

- set = add_set_cmd ("demangle-style", class_support, var_string_noescape,
- (char *) &current_demangling_style_string,
- "Set the current C++ demangling style.\n\
+ /* Fill the demangling_style_names[] array. */
+ for (ndems = 0;
+ libiberty_demanglers[ndems].demangling_style != unknown_demangling;
+ ndems++)
+ ;
+ demangling_style_names = xmalloc (ndems * sizeof (char *));
+ for (i = 0;
+ libiberty_demanglers[i].demangling_style != unknown_demangling;
+ i++)
+ demangling_style_names[i] =
+ xstrdup (libiberty_demanglers[i].demangling_style_name);
+
+ set = add_set_enum_cmd ("demangle-style", class_support,
+ demangling_style_names,
+ (const char **) &current_demangling_style_string,
+ "Set the current C++ demangling style.\n\
Use `set demangle-style' without arguments for a list of demangling styles.",
- &setlist);
+ &setlist);
show = add_show_from_set (set, &showlist);
set->function.sfunc = set_demangling_command;

--- gdb/proc-api.c~0 Sun Jul 30 04:48:26 2000
+++ gdb/proc-api.c Sat Feb 17 21:54:32 2001
@@ -777,5 +777,6 @@ _initialize_proc_api (void)

add_show_from_set (c, &showlist);
c->function.sfunc = set_procfs_file_cmd;
+ c->completer = filename_completer;
}
--- gdb/remote-rdi.c~0 Fri Feb 2 21:14:32 2001
+++ gdb/remote-rdi.c Sat Feb 17 22:42:10 2001
@@ -32,6 +32,7 @@
#include "gdbthread.h"
#include "gdbcore.h"
#include "breakpoint.h"
+#include "completer.h"

#ifdef USG
#include <sys/types.h>
@@ -1021,6 +1022,8 @@ rdilogenable_command (char *args, int fr
void
_initialize_remote_rdi (void)
{
+ struct cmd_list_element *c;
+
init_rdi_ops ();
add_target (&arm_rdi_ops);

@@ -1028,14 +1031,15 @@ _initialize_remote_rdi (void)
Adp_SetLogfile (log_filename);
Adp_SetLogEnable (log_enable);

- add_cmd ("rdilogfile", class_maintenance,
- rdilogfile_command,
- "Set filename for ADP packet log.\n\
+ c = add_cmd ("rdilogfile", class_maintenance,
+ rdilogfile_command,
+ "Set filename for ADP packet log.\n\
This file is used to log Angel Debugger Protocol packets.\n\
With a single argument, sets the logfile name to that value.\n\
Without an argument, shows the current logfile name.\n\
See also: rdilogenable\n",
&maintenancelist);
+ c->completer = filename_completer;

add_cmd ("rdilogenable", class_maintenance,
rdilogenable_command,
--- gdb/solib.c~0 Wed Jan 31 03:24:02 2001
+++ gdb/solib.c Sat Feb 17 22:42:36 2001
@@ -37,6 +37,7 @@
#include "environ.h"
#include "language.h"
#include "gdbcmd.h"
+#include "completer.h"

#include "solist.h"

@@ -789,6 +790,8 @@ sharedlibrary_command (char *args, int f
void
_initialize_solib (void)
{
+ struct cmd_list_element *c;
+
add_com ("sharedlibrary", class_files, sharedlibrary_command,
"Load shared object library symbols for files matching REGEXP.");
add_info ("sharedlibrary", info_sharedlibrary_command,
@@ -806,18 +809,20 @@ must be loaded manually, using `sharedli
&showlist);

add_show_from_set
- (add_set_cmd ("solib-absolute-prefix", class_support, var_filename,
- (char *) &solib_absolute_prefix,
- "Set prefix for loading absolute shared library symbol files.\n\
+ (c = add_set_cmd ("solib-absolute-prefix", class_support, var_filename,
+ (char *) &solib_absolute_prefix,
+ "Set prefix for loading absolute shared library symbol files.\n\
For other (relative) files, you can add values using `set solib-search-path'.",
&setlist),
&showlist);
+ c->completer = filename_completer;
+
add_show_from_set
- (add_set_cmd ("solib-search-path", class_support, var_string,
- (char *) &solib_search_path,
- "Set the search path for loading non-absolute shared library symbol files.\n\
+ (c = add_set_cmd ("solib-search-path", class_support, var_string,
+ (char *) &solib_search_path,
+ "Set the search path for loading non-absolute shared library symbol files.\n\
This takes precedence over the environment variables PATH and LD_LIBRARY_PATH.",
&setlist),
&showlist);
-
+ c->completer = filename_completer;
}
--- gdb/tracepoint.c~0 Fri Dec 15 03:01:50 2000
+++ gdb/tracepoint.c Sat Feb 17 22:42:54 2001
@@ -32,6 +32,7 @@
#include "tracepoint.h"
#include "remote.h"
#include "linespec.h"
+#include "completer.h"

#include "ax.h"
#include "ax-gdb.h"
@@ -2600,6 +2601,8 @@ get_traceframe_number (void)
void
_initialize_tracepoint (void)
{
+ struct cmd_list_element *c;
+
tracepoint_chain = 0;
tracepoint_count = 0;
traceframe_number = -1;
@@ -2651,9 +2654,10 @@ last tracepoint set.");

add_info_alias ("tp", "tracepoints", 1);

- add_com ("save-tracepoints", class_trace, tracepoint_save_command,
- "Save current tracepoint definitions as a script.\n\
+ c = add_com ("save-tracepoints", class_trace, tracepoint_save_command,
+ "Save current tracepoint definitions as a script.\n\
Use the 'source' command in another debug session to restore them.");
+ c->completer = filename_completer;

add_com ("tdump", class_trace, trace_dump_command,
"Print everything collected at the current tracepoint.");
--- gdb/win32-nat.c~0 Sat Jan 27 21:32:32 2001
+++ gdb/win32-nat.c Sat Feb 17 22:41:32 2001
@@ -30,6 +30,7 @@
#include "target.h"
#include "gdbcore.h"
#include "command.h"
+#include "completer.h"
#include <signal.h>
#include <sys/types.h>
#include <fcntl.h>
@@ -1377,10 +1378,13 @@ init_child_ops (void)
void
_initialize_inftarg (void)
{
+ struct cmd_list_element *c;
+
init_child_ops ();

- add_com ("dll-symbols", class_files, dll_symbol_command,
- "Load dll library symbols from FILE.");
+ c = add_com ("dll-symbols", class_files, dll_symbol_command,
+ "Load dll library symbols from FILE.");
+ c->completer = filename_completer;

auto_solib_add = 1;
add_com_alias ("sharedlibrary", "dll-symbols", class_alias, 1);