This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: [REPOST] patch: command deprecator
- To: David Whedon <davidw at gordian dot com>
- Subject: Re: [REPOST] patch: command deprecator
- From: Fernando Nasser <fnasser at redhat dot com>
- Date: Wed, 23 Feb 2000 15:24:29 +0000
- CC: gdb-patches at sourceware dot cygnus dot com, Elena Zannoni <ezannoni at cygnus dot com>
- Organization: Red Hat, Inc. - Toronto
- References: <Pine.BSF.3.96.1000222201302.23851V-100000@ares.gordian.com>
David,
I have not looked in the details, but this is looks like a model
submission, with testcase, documentation fixes etc. Thank you very
much.
The maintainers are both Elena and I. I am leaving for one week, so I
wonder if Elena could do me a favor of dealing with your patch. Will
you Elena? Please...
Cheers,
Fernando
David Whedon wrote:
>
> I cleaned up my patch, deleted worthless lines, etc. thanks for the
> suggestions Elena. I may not have found all missing gnu-isms, but I gave
> it a shot. I do wonder what the thinking is as far as keeping things
> looking the same within one file, i.e K & R style functions for most, but
> new ones standard.
>
> I want to make a few quick notes about why I chose to do this the way that
> I did, so things make a bit of sense, and also so that someone can find a
> better way if they want, and it also will help those looking at the logic
> of what I did.
>
> I decided that I wanted the warning to print out the full command name,
> for example:
> (gdb) set end b
> Warning: command 'set endian big' is deprecated.
> Use 'bigendian'.
> (gdb)
>
> At the time the command 'big' is called, we only have that command name
> "big". I thought that a warning message:
> Warning: command 'big' is deprecated.
>
> would be confusing. Also:
> Warning: command 'set end b' is deprecated.
>
> looks somewhat dumb.
>
> I found that I needed therefore to decode the command
> line in order to figure out what the actual command name was. This is
> because postfix commands (don't know of a better name, I mean the ones
> that come after prefix commands) don't retain any knowledge of their
> prefix command. If they did, then we could simply lookup the prefixname on
> the prefix command, and we would be set. I don't see an easy way of
> adding that info since when a command is added it is added to a list, and
> that list doesn't have any knowledge of the commands that are using it
> (the list) as a prefixlist (I'd call it a postfixlist).
>
> This led me to write lookup_cmd_composition which is admittedly an
> iterative version of lookup_cmd_1. The recursive version can't work (as
> far as I can tell) with what I am trying to do because we need to know
> both the command that is going to be executed _and_ its prefix command.
>
> In addition, I wanted to be able to deprecate aliases alone. That is,
> deprecate the alias and not the command.
>
> Tests were done on i686-pc-linux-gnu.
>
> Test results before:
>
> === gdb Summary ===
>
> # of expected passes 6356
> # of unexpected failures 13
> # of expected failures 200
> # of unresolved testcases 3
>
> Test results after, I added about 10 new tests that test the deprecator:
>
> === gdb Summary ===
>
> # of expected passes 6368
> # of unexpected failures 13
> # of expected failures 200
> # of unresolved testcases 3
>
> And now, here comes the patch:
>
> 1999-02-22 David Whedon <dwhedon@gordian.com>
>
> * top.c (execute_command): checks all commands beore executing
> to see if the user needs to be warned that the command is
> deprecated, warns user if appropriate.
> (add_info), (add_info_alias), (add_com) , (add_com_alias): changed
> return values from void to struct cmd_list_element *.
>
> * command.c (lookup_cmd_1): check aliases before following link
> in case user needs to be warned about a deprecated alias.
> (deprecate_cmd): new exported function for command deprecation,
> sets flags and posibly a replacement string.
> (deprecated_cmd_warning): new exported funciton to warn user about
> a deprecated command.
> (lookup_cmd_composition): new exported function that determines
> alias, prefix_command, and cmd based on a string. This is useful
> is we want to full name of a command.
>
> * command.h : added prototypes for deprecate_cmd,
> deprecated_warn_user and lookup_cmd_composition, added flags to
> the cmd_list_element structure, changed return values for
> add_com_* and add_info_* from void to cmd_list_element.
>
> * maint.c : (maintenance_deprecate): new function to deprecate a
> command. This exists only so that the testsuite can deprecate
> commands at runtime and check the warning behavior.
> (maintenance_undeprecate) : new function, drops deprecated flags.
> (maintenance_do_deprecate): actually does the (un)deprecation.
> (initialize_maint_cmds): added the above new deprecate commands.
>
> * gdbint.texinfo : added paragraph about command deprecation.
>
> * commands.exp : added command deprecator tests.
>
>
--
Fernando Nasser
Red Hat, Inc. - Toronto E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300 Tel: 416-482-2661 ext. 311
Toronto, Ontario M4P 2C9 Fax: 416-482-6299