This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v4 2/5] Add support to catch groups of syscalls.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]