gdb: sim: add command line completion
For now, only the sub-command name is completed. No support yet for completing options to that command. But even this is a huge step as currently, nothing is completed, and the basic "help sim" is fairly obtuse as to what exactly the "sim" command accepts. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
parent
d2cfa400a1
commit
56a9aa1d10
6 changed files with 86 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2011-04-14 Mike Frysinger <vapier@gentoo.org>
|
||||||
|
|
||||||
|
* remote-sim.c (sim_command_completer): New function.
|
||||||
|
(_initialize_remote_sim): Set completer to sim_command_completer.
|
||||||
|
|
||||||
2011-04-13 Thiago Jung Bauermann <bauerman@br.ibm.com>
|
2011-04-13 Thiago Jung Bauermann <bauerman@br.ibm.com>
|
||||||
|
|
||||||
* breakpoint.c (print_exception_catchpoint): Rename to ...
|
* breakpoint.c (print_exception_catchpoint): Rename to ...
|
||||||
|
|
|
@ -1193,6 +1193,18 @@ simulator_command (char *args, int from_tty)
|
||||||
registers_changed ();
|
registers_changed ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char **
|
||||||
|
sim_command_completer (struct cmd_list_element *ignore, char *text, char *word)
|
||||||
|
{
|
||||||
|
struct sim_inferior_data *sim_data;
|
||||||
|
|
||||||
|
sim_data = inferior_data (current_inferior (), sim_inferior_data_key);
|
||||||
|
if (sim_data == NULL || sim_data->gdbsim_desc == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return sim_complete_command (sim_data->gdbsim_desc, text, word);
|
||||||
|
}
|
||||||
|
|
||||||
/* Check to see if a thread is still alive. */
|
/* Check to see if a thread is still alive. */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -1287,11 +1299,14 @@ init_gdbsim_ops (void)
|
||||||
void
|
void
|
||||||
_initialize_remote_sim (void)
|
_initialize_remote_sim (void)
|
||||||
{
|
{
|
||||||
|
struct cmd_list_element *c;
|
||||||
|
|
||||||
init_gdbsim_ops ();
|
init_gdbsim_ops ();
|
||||||
add_target (&gdbsim_ops);
|
add_target (&gdbsim_ops);
|
||||||
|
|
||||||
add_com ("sim", class_obscure, simulator_command,
|
c = add_com ("sim", class_obscure, simulator_command,
|
||||||
_("Send a command to the simulator."));
|
_("Send a command to the simulator."));
|
||||||
|
set_cmd_completer (c, sim_command_completer);
|
||||||
|
|
||||||
sim_inferior_data_key
|
sim_inferior_data_key
|
||||||
= register_inferior_data_with_cleanup (sim_inferior_data_cleanup);
|
= register_inferior_data_with_cleanup (sim_inferior_data_cleanup);
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2011-04-14 Mike Frysinger <vapier@gentoo.org>
|
||||||
|
|
||||||
|
* remote-sim.h (sim_complete_command): New prototype.
|
||||||
|
|
||||||
2011-03-05 Mike Frysinger <vapier@gentoo.org>
|
2011-03-05 Mike Frysinger <vapier@gentoo.org>
|
||||||
|
|
||||||
* sim-bfin.h: New file.
|
* sim-bfin.h: New file.
|
||||||
|
|
|
@ -276,6 +276,10 @@ void sim_stop_reason (SIM_DESC sd, enum sim_stop *reason, int *sigrc);
|
||||||
|
|
||||||
void sim_do_command (SIM_DESC sd, char *cmd);
|
void sim_do_command (SIM_DESC sd, char *cmd);
|
||||||
|
|
||||||
|
/* Complete a command based on the available sim commands. Returns an
|
||||||
|
array of possible matches. */
|
||||||
|
char **sim_complete_command (SIM_DESC sd, char *text, char *word);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2011-04-14 Mike Frysinger <vapier@gentoo.org>
|
||||||
|
|
||||||
|
* sim-options.c (complete_option_list, sim_complete_command):
|
||||||
|
New functions.
|
||||||
|
|
||||||
2011-04-02 Mike Frysinger <vapier@gentoo.org>
|
2011-04-02 Mike Frysinger <vapier@gentoo.org>
|
||||||
|
|
||||||
* dv-glue.c: Fix up style.
|
* dv-glue.c: Fix up style.
|
||||||
|
|
|
@ -915,6 +915,57 @@ find_match (SIM_DESC sd, sim_cpu *cpu, char *argv[], int *pargi)
|
||||||
return matching_opt;
|
return matching_opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char **
|
||||||
|
complete_option_list (char **ret, size_t *cnt, const struct option_list *ol,
|
||||||
|
char *text, char *word)
|
||||||
|
{
|
||||||
|
const OPTION *opt = NULL;
|
||||||
|
int argi;
|
||||||
|
size_t len = strlen (word);
|
||||||
|
|
||||||
|
for ( ; ol != NULL; ol = ol->next)
|
||||||
|
for (opt = ol->options; OPTION_VALID_P (opt); ++opt)
|
||||||
|
{
|
||||||
|
const char *name = opt->opt.name;
|
||||||
|
|
||||||
|
/* A long option to match against? */
|
||||||
|
if (!name)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Does this option actually match? */
|
||||||
|
if (strncmp (name, word, len))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ret = xrealloc (ret, ++*cnt * sizeof (ret[0]));
|
||||||
|
ret[*cnt - 2] = xstrdup (name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* All leading text is stored in @text, while the current word being
|
||||||
|
completed is stored in @word. Trailing text of @word is not. */
|
||||||
|
char **
|
||||||
|
sim_complete_command (SIM_DESC sd, char *text, char *word)
|
||||||
|
{
|
||||||
|
char **ret = NULL;
|
||||||
|
size_t cnt = 1;
|
||||||
|
sim_cpu *cpu;
|
||||||
|
|
||||||
|
/* Only complete first word for now. */
|
||||||
|
if (text != word)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
cpu = STATE_CPU (sd, 0);
|
||||||
|
if (cpu)
|
||||||
|
ret = complete_option_list (ret, &cnt, CPU_OPTIONS (cpu), text, word);
|
||||||
|
ret = complete_option_list (ret, &cnt, STATE_OPTIONS (sd), text, word);
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
ret[cnt - 1] = NULL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
SIM_RC
|
SIM_RC
|
||||||
sim_args_command (SIM_DESC sd, char *cmd)
|
sim_args_command (SIM_DESC sd, char *cmd)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue