- const char **list = get_syscall_names (get_current_arch ());
- VEC (char_ptr) *retlist
- = (list == NULL) ? NULL : complete_on_enum (list, word, word);
+ struct gdbarch *gdbarch = get_current_arch ();
+ gdb::unique_xmalloc_ptr<const char *> group_list;
+ const char *prefix;
+
+ /* Completion considers ':' to be a word separator, so we use this to
+ verify whether the previous word was a group prefix. If so, we
+ build the completion list using group names only. */
+ for (prefix = word; prefix != text && prefix[-1] != ' '; prefix--)
+ ;
+
+ if (startswith (prefix, "g:") || startswith (prefix, "group:"))
+ {
+ /* Perform completion inside 'group:' namespace only. */
+ group_list.reset (get_syscall_group_names (gdbarch));
+ if (group_list != NULL)
+ complete_on_enum (tracker, group_list.get (), word, word);
+ }
+ else
+ {
+ /* Complete with both, syscall names and groups. */
+ gdb::unique_xmalloc_ptr<const char *> syscall_list
+ (get_syscall_names (gdbarch));
+ group_list.reset (get_syscall_group_names (gdbarch));
+
+ const char **group_ptr = group_list.get ();
+
+ /* Hold on to strings while we're using them. */
+ std::vector<std::string> holders;
+
+ /* Append "group:" prefix to syscall groups. */
+ for (int i = 0; group_ptr[i] != NULL; i++)
+ holders.push_back (string_printf ("group:%s", group_ptr[i]));