From 56a9aa1d10f5ddb8a1f77e0de0d3c5ef48cdb848 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 15 Apr 2011 03:43:46 +0000 Subject: 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 --- gdb/ChangeLog | 5 +++++ gdb/remote-sim.c | 19 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'gdb') diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5796795..5398e1c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2011-04-14 Mike Frysinger + + * remote-sim.c (sim_command_completer): New function. + (_initialize_remote_sim): Set completer to sim_command_completer. + 2011-04-13 Thiago Jung Bauermann * breakpoint.c (print_exception_catchpoint): Rename to ... diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index baaf439..bf4e0ee 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -1193,6 +1193,18 @@ simulator_command (char *args, int from_tty) 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. */ static int @@ -1287,11 +1299,14 @@ init_gdbsim_ops (void) void _initialize_remote_sim (void) { + struct cmd_list_element *c; + init_gdbsim_ops (); add_target (&gdbsim_ops); - add_com ("sim", class_obscure, simulator_command, - _("Send a command to the simulator.")); + c = add_com ("sim", class_obscure, simulator_command, + _("Send a command to the simulator.")); + set_cmd_completer (c, sim_command_completer); sim_inferior_data_key = register_inferior_data_with_cleanup (sim_inferior_data_cleanup); -- cgit v1.1