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]

[RFC] Sort #includes in gdb


As discussed previously on the list, here is the patch to sort
includes in gdb.  Include files are put into up to 4 stanzas; stanzas
are separated by newlines.  The stanzas are:

1. For non-header files, the "introductory" headers.  First either
   defs.h, common/common-defs.h, or server.h, depending on the
   location of the source file.  Next, if the .c file has a
   corresponding .h, that .h.  (There is one exception to this rule,
   thread-iter.c.)

2. System header files, which are determined by the use of <> in the
   include.

3. Header files that are part of binutils-gdb but not in the gdb
   subdirectory -- mostly things coming from libiberty or BFD.

4. gdb header files.


I've attached the patch compressed, as it is very large.
Even the ChangeLog (which was auto-generated) is large; perhaps it
should be replaced by something like "All files: sort headers"?

Should the stanzas have introductory comments?
Because the patch is auto-generated, this would be easy to do.


If you want to try the script yourself, it is here:

    https://github.com/tromey/gdb-refactoring-scripts

Run it like:

    cd $srcdir/gdb
    emacs --script ~/gdb/gdb-refactoring-scripts/rewriter.el includes


I did not push this to the buildbot, as I believe it is too large for
that as well.  If you want to try building it without running the
script, it is the branch "submit/sort-includes" in my github.

I did test that the script produces the same output if run twice.
(Actually it has a buglet where it still updates the ChangeLog the
second time, but I didn't feel like fixing this.)

Let me know what you think.  This does have some possibility of breaking
the build.

Tom

Attachment: P.gz
Description: sort includes patch


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