public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC] Sort #includes in gdb
@ 2019-01-26 15:40 Tom Tromey
  2019-01-27  4:58 ` Joel Brobecker
  2019-01-28 19:08 ` Pedro Alves
  0 siblings, 2 replies; 19+ messages in thread
From: Tom Tromey @ 2019-01-26 15:40 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1679 bytes --]

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 #2: sort includes patch --]
[-- Type: application/gzip, Size: 104002 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2019-04-04  3:40 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-26 15:40 [RFC] Sort #includes in gdb Tom Tromey
2019-01-27  4:58 ` Joel Brobecker
2019-02-15 20:46   ` Tom Tromey
2019-01-28 19:08 ` Pedro Alves
2019-01-28 22:31   ` Matt Rice
2019-02-15 20:55   ` Tom Tromey
2019-03-15 23:13     ` Tom Tromey
2019-03-20 17:42       ` Pedro Alves
2019-03-29 20:52         ` Tom Tromey
2019-03-29 21:05           ` Simon Marchi
2019-03-30 18:35             ` Tom Tromey
2019-04-03 18:58               ` Pedro Alves
2019-04-03 19:29                 ` Sergio Durigan Junior
2019-04-03 20:34                 ` Sergio Durigan Junior
2019-04-04  2:47                   ` Tom Tromey
2019-04-04  3:40                     ` Sergio Durigan Junior
2019-04-03 19:00             ` Pedro Alves
2019-04-03 20:11               ` Tom Tromey
2019-04-03 21:00                 ` Pedro Alves

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).