@@ -1,3 +1,16 @@
+2015-03-26 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * completer.c (set_gdb_completion_word_break_characters_string):
+ New function.
+ (set_gdb_completion_word_break_characters): Use new function.
+ * completer.h (set_gdb_completion_word_break_characters_string):
+ Declare.
+ * tui/tui-layout.c: Add 'completer.h' include.
+ (layout_completer): New function.
+ (layout_brkchars): New function.
+ (_initialize_tui_layout): Set completer and brkchars on layout
+ command.
+
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
@@ -457,16 +457,26 @@ expression_completer (struct cmd_list_element *ignore,
/* See definition in completer.h. */
void
+set_gdb_completion_word_break_characters_string (char *c)
+{
+ rl_completer_word_break_characters = c;
+}
+
+/* See definition in completer.h. */
+
+void
set_gdb_completion_word_break_characters (completer_ftype *fn)
{
/* So far we are only interested in differentiating filename
completers from everything else. */
+ char *c;
+
if (fn == filename_completer)
- rl_completer_word_break_characters
- = gdb_completer_file_name_break_characters;
+ c = gdb_completer_file_name_break_characters;
else
- rl_completer_word_break_characters
- = gdb_completer_command_word_break_characters;
+ c = gdb_completer_command_word_break_characters;
+
+ set_gdb_completion_word_break_characters_string (c);
}
/* Here are some useful test cases for completion. FIXME: These
@@ -107,6 +107,10 @@ extern char *gdb_completion_word_break_characters (void);
extern void set_gdb_completion_word_break_characters (completer_ftype *fn);
+/* Set the word break characters array to the set STR. */
+
+extern void set_gdb_completion_word_break_characters_string (char *STR);
+
/* Exported to linespec.c */
extern const char *skip_quoted_chars (const char *, const char *,
@@ -1,5 +1,10 @@
2015-03-27 Andrew Burgess <andrew.burgess@embecosm.com>
+ * gdb.base/completion.exp: Add test for completion of layout
+ names.
+
+2015-03-27 Andrew Burgess <andrew.burgess@embecosm.com>
+
* lib/gdb.exp (skip_tui_tests): New proc.
* gdb.base/tui-layout.exp: Check skip_tui_tests.
@@ -859,3 +859,21 @@ gdb_test_multiple "" "$test" {
pass "$test"
}
}
+
+gdb_test_no_output "set max-completions unlimited"
+
+if {![skip_tui_tests]} {
+ set test "test completion of layout names"
+ send_gdb "layout\t\t\t"
+ gdb_test_multiple "" "$test" {
+ -re "\\\$fregs \\\$gregs \\\$regs \\\$sregs asm next prev regs split src *\r\n$gdb_prompt layout $" {
+ pass "$test"
+ }
+ }
+ send_gdb "\003"
+ gdb_test_multiple "" "$test" {
+ -re "$gdb_prompt $" {
+ pass "quit command input after testing layout completion"
+ }
+ }
+}
@@ -25,6 +25,7 @@
#include "symtab.h"
#include "frame.h"
#include "source.h"
+#include "completer.h"
#include <ctype.h>
#include "tui/tui.h"
@@ -373,6 +374,50 @@ tui_default_win_viewport_height (enum tui_win_type type,
return h;
}
+/* Complete possible layout names. TEXT is the complete text entered so
+ far, WORD is the word currently being completed. */
+
+static VEC (char_ptr) *
+layout_completer (struct cmd_list_element *ignore,
+ const char *text, const char *word)
+{
+ VEC (char_ptr) *return_val = NULL;
+ const char **tmp, *p;
+ size_t len;
+
+ static const char *layout_names [] =
+ { "src", "asm", "split", "regs", "next", "prev",
+ TUI_FLOAT_REGS_NAME_LOWER,
+ TUI_GENERAL_REGS_NAME_LOWER,
+ TUI_SPECIAL_REGS_NAME_LOWER,
+ TUI_GENERAL_SPECIAL_REGS_NAME_LOWER,
+ NULL };
+
+ gdb_assert (text != NULL);
+ p = strchr (text, ' ');
+ len = (p == NULL) ? strlen (text) : p - text;
+
+ for (tmp = layout_names; *tmp != NULL; ++tmp)
+ {
+ if (strncmp (text, *tmp, len) == 0)
+ {
+ char *str = xstrdup (*tmp);
+ VEC_safe_push (char_ptr, return_val, str);
+ }
+ }
+
+ return return_val;
+}
+
+static void
+layout_brkchars (struct cmd_list_element *command,
+ const char *text, const char *word)
+{
+ /* This set of characters should be the same set returned by
+ DEFAULT_WORD_BREAK_CHARACTERS but with '$' removed. */
+ set_gdb_completion_word_break_characters_string
+ (" \t\n!@#%^&*()+=|~`}{[]\"';:?/>.<,");
+}
/* Function to initialize gdb commands, for tui window layout
manipulation. */
@@ -383,8 +428,10 @@ extern initialize_file_ftype _initialize_tui_layout;
void
_initialize_tui_layout (void)
{
- add_com ("layout", class_tui, tui_layout_command, _("\
-Change the layout of windows.\n\
+ struct cmd_list_element *cmd;
+
+ cmd = add_com ("layout", class_tui, tui_layout_command, _("\
+Change the layout of windows.\n \
Usage: layout prev | next | <layout_name> \n\
Layout names are:\n\
src : Displays source and command windows.\n\
@@ -396,6 +443,8 @@ Layout names are:\n\
source/assembly/command (split) is displayed, \n\
the register window is displayed with \n\
the window that has current logical focus.\n"));
+ set_cmd_completer (cmd, layout_completer);
+ set_cmd_completer_handle_brkchars (cmd, layout_brkchars);
if (xdb_commands)
{
add_com ("td", class_tui, tui_toggle_layout_command, _("\