Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: Tom Tromey <tom@tromey.com>
Cc: Andreas Schwab <schwab@linux-m68k.org>, gdb-patches@sourceware.org
Subject: Re: [FYI] Sort includes for files gdb/[a-f]*.[chyl].
Date: Sat, 06 Apr 2019 19:29:00 -0000	[thread overview]
Message-ID: <45086ce5-2528-2cc0-4008-e250aa4c0e98@FreeBSD.org> (raw)
In-Reply-To: <m2pnpzk4s6.fsf@linux-m68k.org>

On 4/5/19 11:48 PM, Andreas Schwab wrote:
> On Apr 05 2019, Tom Tromey <tom@tromey.com> wrote:
> 
>> diff --git a/gdb/aarch64-fbsd-nat.c b/gdb/aarch64-fbsd-nat.c
>> index bb187a600d0..cb4130a2844 100644
>> --- a/gdb/aarch64-fbsd-nat.c
>> +++ b/gdb/aarch64-fbsd-nat.c
>> @@ -18,16 +18,18 @@
>>     along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
>>  
>>  #include "defs.h"
>> -#include "target.h"
>>  
>> -#include <sys/types.h>
>> -#include <sys/ptrace.h>
>> +/* Standard C includes.  */
>>  #include <machine/reg.h>
>> +#include <sys/ptrace.h>
>> +#include <sys/types.h>
> 
> These are not really "Standard C includes".

I agree that these are pretty OS-specific.  Also, FreeBSD doesn't make all of its
headers standalone and sys/types.h probably has to come first before any other
sys/*.h, etc.  (I had forgotten about this until now).  You can think of
<sys/types.h> (or <sys/param.h> if needed) as being like GDB's "defs.h".  As it
is, my guess is that this change doesn't compile as <machine/reg.h> almost
certainly uses types defined in <sys/types.h> on all FreeBSD architectures.

The sorting rules that FreeBSD uses in its source tree is something like:

<sys/param.h> or <sys/types.h> (but not both)
<sys/*.h> (sorted)
<machine|net|netinet|*/*.h> (sorted which naturally groups them by subdir)
<*.h> (sorted)

I'm not sure if we want to treat sys/types.h special in your script, but POSIX in
the past did used to require it before other headers (e.g. socket() used to
formally require <sys/types.h> before <sys/socket.h>).  I'm also not sure if we want
to sort <sys/*.h> before other groups, but FreeBSD might very well need that at
least.  I'm fine with fixing any build breakages post commit (I know there aren't
any functional FreeBSD buildbots currently).  I just don't know how much you care
about the script being completely correct.  It might also depend on if any of the
non-nat files that include <sys/types.h> end up breaking on FreeBSD (or other OS's)
after the sorting changes.  I'm happy to pull down a branch and do a test build if
that would work best for you.

The one use of sys/param.h in the tree is bsd-kvm.c which is effectively a nat file
only used on the BSD's and the natural sort order of the sys/*.h headers in that
file would sort correctly anyway FWIW.

-- 
John Baldwin


  reply	other threads:[~2019-04-06 19:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-06  1:17 Tom Tromey
2019-04-06  6:48 ` Andreas Schwab
2019-04-06 19:29   ` John Baldwin [this message]
2019-04-06 19:36     ` Tom Tromey
2019-04-06 19:33   ` Tom Tromey

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=45086ce5-2528-2cc0-4008-e250aa4c0e98@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    --cc=schwab@linux-m68k.org \
    --cc=tom@tromey.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