public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@cygnus.com>
To: David Taylor <taylor@cygnus.com>
Cc: gdb@sourceware.cygnus.com
Subject: Re: Proposal: convert function definitions to prototyped form
Date: Fri, 02 Jun 2000 12:10:00 -0000	[thread overview]
Message-ID: <1000602191042.ZM30936@ocotillo.lan> (raw)
In-Reply-To: <200006021539.LAA25912@texas.cygnus.com>

On Jun 2, 11:39am, David Taylor wrote:

> With any solution, either you're going to have to check the results or
> you're going to have to hand convert some of the stuff.  It's a
> tradeoff.  From what you say below, your script also requires some
> later hand conversions.

Yes.  But, it's conservative in that it won't break your builds.
(Or at least that's the intent.)

> Does your script produce substantially less that needs to be hand
> converted?

I only ran protoize on breakpoint.c to see what the problems were. 
This was the file that required the most conversion, however, so
hopefully it's a good representative sample.  For this file, protoize
converted 126 function declarations and fix-decls converted 138.  In
addition, not counting reformatting, the protoized version of
breakpoint.c would require 5 hand edits in order to fix problems
introduced in the conversion.  The fix-decls version requires 0 hand
edits.  After conversion, the protoized version of breakpoint.c
still had 15 functions which would need to be converted by hand (or
some other tool) whereas the fix-decls version had only 3.  Here's
a table to summarizing the above:

                        breakpoint.c conversion
                                              | protoize | fix-decls |
----------------------------------------------+----------+-----------+
Functions converted                           |   126    |   138     |
----------------------------------------------+----------+-----------+
Hand edits needed afterwards to fix problems  |          |           |
in the conversion process                     |     5    |     0     |
----------------------------------------------+----------+-----------+
Functions remaining to be converted           |    15    |     3     |
----------------------------------------------+----------+-----------+
Total number of hand edits required           |    20    |     3     |
----------------------------------------------+----------+-----------+

Recall that over all of the gdb sources, fix-decls converted slightly
over 5200 declarations.  I believe that there are only around 140 left
to consider.  This is somewhat higher than I would like and I may be
able to reduce it somewhat by making the script a little bit smarter. 
But I also want to be certain that no errors are introduced in the
process. 

I should note that there are many settings where protoize is a
completely acceptable (and probably better) tool.  With gdb, however,
we have a lot of developers scattered across the globe who need to be
able to deterministically apply the same transformations to their
sources in order to make merges and checkins easier.

With protoize, I think it's going be be difficult to guarantee
determinism since the results will vary depending upon which platform
you use to do the transformation.

> 	3) ``protoize'' screws up on PTR types.  E.g, in breakpoint.c, it
> 	   converted
> 
> 		static int
> 		cover_target_enable_exception_callback (arg)
> 		     PTR arg;
> 
> 	   to
> 
> 		static int
> 		cover_target_enable_exception_callback (__builtin_va_list arg)
> 
> I consider this to be a more serious problem than the other complaints
> you have.

I think the setup issue is important too.  (I don't know if it's more
serious though.)  As I mentioned in my first point (which is no longer
quoted), you have to do a configure in the source directory above gdb
in order to to properly run protoize or else it complains that it
can't find certain header files.  Also, you need to make sure that the
bfd header files are generated before you start.  None of these
problems are insurmountable, but to do things safely with protoize,
and in order to avoid polluting your sources with files that belong in
a build tree, it would be necessary for a script using protoize to
make a complete copy of the source tree somewhere else in order to do
the work.

> 	4) ``protoize'' does not reformat long argument lists.  The lists
> 	   end up entirely contained on one line.
> 
> So... adopt the same solution for it that you chose to adopt for your
> script -- run indent on the output!

Granted.  A suitably imaginative script could identify just the lines
that protoize touched and reformat those.  I don't think we want to
run indent on entire files however, at least not for this activity.

>     For more information on protoize, see the "Running protoize" page:
> 
> 	http://gcc.gnu.org/onlinedocs/gcc_2.html#SEC48
> 
>     and the "Caveats of using protoize" page:
> 
> 	http://gcc.gnu.org/onlinedocs/gcc_7.html#SEC135
> 
> I've used protoize before with good results.  It was a fairly
> substantial project, though not as big as gdb.

Okay.  Out of curiousity, did the project in question have a large
number of active developers?  (This doesn't necessarily matter, but
I think it's probably easier to manage this kind of thing when only
a handful of developers are affected.)

>     Two of my goals in creating the scripts for the PARAMS purging
>     activities was that the scripts should be 1) easy to invoke and 2)
>     require no hand editing of the output when done.  I.e, you shouldn't
>     have to edit any of the files that these scripts touch in order to fix
> 
> I trust that "3)" is:
> 
>     "be conservative; not convert something if it can't be sure
>     of getting it right".

You're right.  I should have mentioned this.

> I'd much rather hand convert more of the code than have it make a
> subtle but incorrect change.

I agree completely.

[...]

>     Finally, I should note that I've done a test build on GNU/Linux/x86
>     and had no build problems, nor did I see any regressions when I ran
>     the testsuite.
> 
>     The fix-decls script is below.  I'd be interested in finding out if
>     anyone else has a favorite script for doing this sort of thing.  Other
>     comments welcome too.
> 
> I'd be tempted to do a build before running your script; stash away the
> object files; run the script; do another build; compare the object
> files...

Good idea.  I'll have to see what gcc does to compare object files.
(I don't think a simple cmp works for ELF files.)

> I consider the lack of (prototyped) function declarations to be more
> serious "problem" than the use of old style function definitions in
> old code.  I'd like to see:
> 
> . declarations near the top of every file (i.e., before the first
>   function definition) for every static function in the file.
> 
> . a declaration in an included header file for every non static
>   function definition and for every non static function used.
> 
> . changes to the default configuration to "encourage" developers to
>   include the above declarations.

I don't disagree, but I think that adding prototypes for everything
should be a separate activity.  The question is whether it should
occur before the activity covered by my proposal.  And if it should
occur before, once again, we'll need to find a way to help automate
the process because if we attempt to do it incrementally by hand
over a period of time, it is likely that it'll never get done.

Kevin

  reply	other threads:[~2000-06-02 12:10 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-02  8:40 David Taylor
2000-06-02 12:10 ` Kevin Buettner [this message]
2000-06-03  3:58   ` Eli Zaretskii
     [not found]     ` <eliz@delorie.com>
2000-06-03 10:50       ` Kevin Buettner
2000-06-03 11:37         ` Eli Zaretskii
2000-06-03 18:18         ` Andrew Cagney
2000-06-03 15:42       ` Kevin Buettner
2001-02-16  0:45       ` [RFC] Unified watchpoints for x86 platforms Kevin Buettner
  -- strict thread matches above, loose matches on Subject: below --
2000-09-07  1:55 gdb doesn't work very well with dynamic linked binaries James Cownie
2000-09-07  3:09 ` Mark Kettenis
2000-09-07  8:02   ` Eli Zaretskii
2000-09-08  8:30     ` Mark Kettenis
2001-02-10  7:34       ` [RFC] Unified watchpoints for x86 platforms Eli Zaretskii
2001-02-10 10:19         ` H . J . Lu
2001-02-10 11:28           ` Eli Zaretskii
2001-02-15  3:48         ` Eli Zaretskii
2001-02-15  8:17           ` Mark Kettenis
2001-02-15  9:32             ` Eli Zaretskii
2001-02-15 10:33               ` Mark Kettenis
2001-02-15 13:26                 ` Eli Zaretskii
2001-02-15 10:41             ` Kevin Buettner
2001-02-15 13:26               ` Eli Zaretskii
2001-02-15 14:46                 ` J.T. Conklin
2001-02-15 16:11                   ` Kevin Buettner
2001-02-15 23:29                     ` Eli Zaretskii
2001-02-24 10:14                     ` Eli Zaretskii
2001-02-27  3:28                       ` Mark Kettenis
2001-02-27 10:57                         ` Eli Zaretskii
2001-03-21 15:59                         ` [RFA] " Eli Zaretskii
2001-02-15 23:30                   ` [RFC] " Eli Zaretskii
2001-02-16 10:52                     ` J.T. Conklin
2001-02-16  0:00                   ` Mark Kettenis
2001-02-15  9:08           ` H . J . Lu
2000-09-09 14:39   ` gdb doesn't work very well with dynamic linked binaries Peter.Schauer
2000-06-02 13:11 Proposal: convert function definitions to prototyped form David Taylor
2000-06-02  0:50 Kevin Buettner
2000-06-02  2:42 ` Andrew Cagney
2000-06-03  0:13   ` Kevin Buettner
2000-06-03  0:21   ` Kevin Buettner
2000-06-03  4:52     ` Andrew Cagney
2000-06-02  5:26 ` Mark Kettenis
2000-06-02  8:16   ` Kevin Buettner
2000-06-02 10:44     ` J.T. Conklin
2000-06-03  5:17       ` Andrew Cagney
2000-06-05 11:05         ` J.T. Conklin
2000-06-12 16:30       ` Eric Bachalo
2000-06-12 17:29         ` Andrew Cagney
2000-06-12 18:03           ` Daniel Berlin
2000-06-12 18:15             ` Stan Shebs
2000-06-12 18:23               ` Daniel Berlin
2000-06-12 19:16                 ` Anatoly Vorobey
2000-06-12 19:42                   ` Daniel Berlin
2000-06-12 18:55         ` Kevin Buettner
2000-06-13  3:34         ` Eli Zaretskii
2000-06-03  4:48 ` Andrew Cagney
2000-06-12 18:10 ` Andrew Cagney
2000-06-12 19:48   ` Kevin Buettner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1000602191042.ZM30936@ocotillo.lan \
    --to=kevinb@cygnus.com \
    --cc=gdb@sourceware.cygnus.com \
    --cc=taylor@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).