From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96878 invoked by alias); 23 Jan 2019 16:40:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 96806 invoked by uid 89); 23 Jan 2019 16:40:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=spots, Gary, gary, UD:server.h X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Jan 2019 16:40:11 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E59A736807; Wed, 23 Jan 2019 16:40:09 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADB756C207; Wed, 23 Jan 2019 16:40:07 +0000 (UTC) Subject: Re: [PATCH] Remove duplicate or commented-out #includes To: Tom Tromey , Gary Benson References: <20190119213007.23712-1-tom@tromey.com> <20190121172843.GA7007@blade.nx> <87muntpc6z.fsf@tromey.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <40c4819b-e15f-671c-51d7-7a6cedcad7de@redhat.com> Date: Wed, 23 Jan 2019 16:40:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <87muntpc6z.fsf@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-01/txt/msg00521.txt.bz2 On 01/22/2019 04:07 AM, Tom Tromey wrote: >>> It would be possible to sort #includes, or maybe run >>> include-what-you-use on gdb, but I haven't tried that. I'd be >>> interested to hear if you think this would be worthwhile, thoug. > > Gary> I'd consider it worthwhile. I'd really like sorted #includes. > Gary> Some files have random whitespace in the list too, that maybe > Gary> made sense once. > > I wrote a script to sort the includes. The output is rather voluminous, > not totally sure yet how I will submit it. > > It doesn't try to do a 100% job. For example, some files in gdb include > other files at random spots -- not all includes are at the top of the > file -- and the script doesn't try to handle this. > > It did find 40 .h files that don't have include guards. Maybe I will > try to automatically fix these. > > Building revealed a few minor order dependencies in the headers. I'll > submit this as an initial cleanup. > > > I chose to have the includes ordered this way: > > First stanza: > > 1. defs.h (or server.h or common-defs.h) > 2. for a .c file, the corresponding .h if it exists > (two exceptions were needed to this rule) > > Second stanza (stanzas separated by a blank line) holds system headers. > > Third stanzas holds includes of headers in binutils-gdb but not part of > gdb proper. > > Fourth stanza is gdb-specific headers. > > > It's reasonably easy to change this around though. That order seems fine to me. Thanks a lot for doing that! Looking forward. Thanks, Pedro Alves > It would be possible to modify this same script to try removing includes > from .c files and seeing whether the file still compiles. It would just > take a long time on this machine I have at the moment. > > If anyone wants to try it out for themselves, I can send the > instructions.