This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v4 2/5] Add support to catch groups of syscalls.
- From: Pedro Alves <palves at redhat dot com>
- To: Gabriel Krisman Bertazi <gabriel at krisman dot be>, sergiodj at redhat dot com
- Cc: gdb-patches at sourceware dot org, dje at google dot com
- Date: Wed, 13 May 2015 11:38:39 +0100
- Subject: Re: [PATCH v4 2/5] Add support to catch groups of syscalls.
- Authentication-results: sourceware.org; auth=none
- References: <87wq0gtfxu dot fsf at redhat dot com> <1431304069-19647-1-git-send-email-gabriel at krisman dot be> <1431304069-19647-3-git-send-email-gabriel at krisman dot be>
On 05/11/2015 01:27 AM, Gabriel Krisman Bertazi wrote:
> catch_syscall_completer (struct cmd_list_element *cmd,
> const char *text, const char *word)
> {
> - 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 ();
> + struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
> + VEC (char_ptr) *group_retlist = NULL;
> + VEC (char_ptr) *syscall_retlist = NULL;
> + VEC (char_ptr) *retlist = NULL;
> + const char **group_list = NULL;
> + const char **syscall_list = NULL;
> + const char *prefix;
> + int i;
> +
> + /* Complete with both, syscall names and groups. */
> + syscall_list = get_syscall_names (gdbarch);
> + group_list = get_syscall_group_names (gdbarch);
> +
> + /* Append "group:" prefix to syscall groups. */
> + for (i = 0; group_list[i] != NULL; i++)
> + {
> + char *prefixed_group = xstrprintf ("group:%s", group_list[i]);
> +
> + group_list[i] = prefixed_group;
> + make_cleanup (xfree, prefixed_group);
> + }
> +
...
> + VEC_free (char_ptr, syscall_retlist);
> + VEC_free (char_ptr, group_retlist);
> + xfree (syscall_list);
> + xfree (group_list);
> + do_cleanups (cleanups);
>
Odd pattern of mixing VEC_free/xfree and cleanups.
Any reason those don't go through cleanups too? Note: for
VECs, there's VEC_cleanup.
> - xfree (list);
> return retlist;
> }
>
Thanks,
Pedro Alves