[RFA, doc RFA] Add gdb.add_command_alias

Pedro Alves pedro@codesourcery.com
Thu Sep 22 14:08:00 GMT 2011


Thanks!

On Wednesday 21 September 2011 22:12:11, Doug Evans wrote:
> +      make_cleanup ((make_cleanup_ftype *) dyn_string_delete, from_prefix);
> +      to_prefix = dyn_string_new (10);
> +      make_cleanup ((make_cleanup_ftype *) dyn_string_delete, to_prefix);

Please don't add more casts to make_cleanup_ftype.

  /* NOTE: cagney/2000-03-04: This typedef is strictly for the
     make_cleanup function declarations below.  Do not use this typedef
     as a cast when passing functions into the make_cleanup() code.
     Instead either use a bounce function or add a wrapper function.
     Calling a f(char*) function with f(void*) is non-portable.  */
  typedef void (make_cleanup_ftype) (void *);


Any special reason `-f "maint bah foo" -t "info bar"' is forbidden?
I was thinking that we'd only verify whether "info" exists.  But maybe
that shouldn't either be verified.  Having aliases not erroring out if the
destination doesn't exist allows one putting aliases in .gdbinit
without worrying if the gdb that'll load has FROM already (it may be
too old, but not old enough to not support "alias").  

It's fine with me to put this in as in.  I'll try to change this
at some point if I feel so inclined.  I realize the alias mechanism
as is today does not even create the alias if the FROM does not
exist.  So this branch ...

> +  if (to_argv[1] == NULL)
> +    {
> +      /* add_cmd requires we allocate space for name, hence the xstrdup.  */
> +      add_com_alias (xstrdup (to_argv[0]), from, class_alias, abbrev_flag);
> +    }

is silent if FROM does not exist, though the other branch errors out.
Just pointing it out -- not sure it was on purpose.

With the make_cleahup_ftype thing fixed, this is fine with me.
Thanks again!

-- 
Pedro Alves



More information about the Gdb-patches mailing list