aboutsummaryrefslogtreecommitdiff
path: root/gdb/completer.c
diff options
context:
space:
mode:
authorAndreas Arnez <arnez@linux.vnet.ibm.com>2014-12-12 17:11:22 +0100
committerAndreas Krebbel <krebbel@linux.vnet.ibm.com>2014-12-12 17:11:22 +0100
commit71c247087cbff23fbbe10333a9e504f3e197c107 (patch)
treef7d0e7ce48353d176a38f17a4870b9516ece95a6 /gdb/completer.c
parentf5b95c01fbe709f73ca3ba60136ff973dcb706a5 (diff)
Provide completer for "info registers"
Provide a new completion function for the argument of "info registers", "info all-registers", and the "lr" command in dbx mode. Without this patch the default symbol completer is used, which is more confusing than helpful. Also add a test for this new feature to "completion.exp": Determine the target's available set of registers/reggroups and compare this to the completion of "info registers ". For determining the available registers involve the new "maint print user-registers" command. gdb/ChangeLog: * completer.c: Include "target.h", "reggroups.h", and "user-regs.h". (reg_or_group_completer): New. * completer.h (reg_or_group_completer): Declare. * infcmd.c (_initialize_infcmd): Set reg_or_group_completer for the "info registers" and "info all-registers" commands and the dbx-mode "lr" command. gdb/testsuite/ChangeLog: * gdb.base/completion.exp: Add test for completion of "info registers ".
Diffstat (limited to 'gdb/completer.c')
-rw-r--r--gdb/completer.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/gdb/completer.c b/gdb/completer.c
index a0f3fa32ac..6767225542 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -23,6 +23,9 @@
#include "filenames.h" /* For DOSish file names. */
#include "language.h"
#include "gdb_signals.h"
+#include "target.h"
+#include "reggroups.h"
+#include "user-regs.h"
#include "cli/cli-decode.h"
@@ -836,6 +839,45 @@ signal_completer (struct cmd_list_element *ignore,
return return_val;
}
+/* Complete on a register or reggroup. */
+
+VEC (char_ptr) *
+reg_or_group_completer (struct cmd_list_element *ignore,
+ const char *text, const char *word)
+{
+ VEC (char_ptr) *result = NULL;
+ size_t len = strlen (word);
+ struct gdbarch *gdbarch;
+ struct reggroup *group;
+ const char *name;
+ int i;
+
+ if (!target_has_registers)
+ return result;
+
+ gdbarch = get_frame_arch (get_selected_frame (NULL));
+
+ for (i = 0;
+ (name = user_reg_map_regnum_to_name (gdbarch, i)) != NULL;
+ i++)
+ {
+ if (*name != '\0' && strncmp (word, name, len) == 0)
+ VEC_safe_push (char_ptr, result, xstrdup (name));
+ }
+
+ for (group = reggroup_next (gdbarch, NULL);
+ group != NULL;
+ group = reggroup_next (gdbarch, group))
+ {
+ name = reggroup_name (group);
+ if (strncmp (word, name, len) == 0)
+ VEC_safe_push (char_ptr, result, xstrdup (name));
+ }
+
+ return result;
+}
+
+
/* Get the list of chars that are considered as word breaks
for the current command. */