Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Simon Marchi <simark@simark.ca>,
	Simon Marchi <simon.marchi@efficios.com>,
	gdb-patches@sourceware.org
Subject: Re: [PATCH v2 3/4] gdb, gdbserver, gdbsupport: include early header files with `-include`
Date: Tue, 26 Mar 2024 15:31:58 +0000	[thread overview]
Message-ID: <80ffa3c0-7049-4b11-8c28-1a6b6ac5c0d7@palves.net> (raw)
In-Reply-To: <e04db2ab-1be9-4c8c-b02c-521db68e1d0e@simark.ca>

On 2024-03-26 14:39, Simon Marchi wrote:
> On 3/26/24 7:57 AM, Pedro Alves wrote:
>> On 2024-03-23 02:14, Simon Marchi wrote:

>>
>>> +# Rule for gdbreplay.o.  This is the same as COMPILE, without INCLUDE_SERVER_H.
>>> +
>>> +gdbreplay.o: gdbreplay.cc
>>> +	$(ECHO_CXX) $(COMPILE.pre) $(INTERNAL_CFLAGS) $(CXXFLAGS) $(COMPILE.post) $<
>>
>> It would seem better to make gdbreplay include common-defs.h with -include, to me.  Any
>> reason not to do that?
> 
> No, I just didn't give much attention to gdbreplay because... I never
> used it.
> 
> Really the simplest would be if gdbreplay could use the same -include as
> the rest of gdbserver.  The immediate problem I got when using `-include
> server.h` for gdbreplay.cc is:
> 
>       CXX    gdbreplay.o
>     /home/smarchi/src/binutils-gdb/gdbserver/gdbreplay.cc:80:1: error: ‘void remote_close()’ was declared ‘extern’ and later ‘static’ [-fpermissive]
>        80 | remote_close (void)
>           | ^~~~~~~~~~~~
>     In file included from /home/smarchi/src/binutils-gdb/gdbserver/server.h:94,
>                      from <command-line>:
>     /home/smarchi/src/binutils-gdb/gdbserver/remote-utils.h:36:6: note: previous declaration of ‘void remote_close()’
>        36 | void remote_close (void);
>           |      ^~~~~~~~~~~~
> 
> That is, if gdbreplay includes server.h, it sees some declaration of
> remote_close() which conflicts with its own declaration of
> remote_close().
> 
> One quick solution to that could be renaming gdbreplay's remote_close
> function.  Or, put all of gdbreplay.cc (except main()) in an anonymous
> namespace, which would be the appropriate C++ thing to do anyway.  Now,
> if gdbreplay.cc uses `-include server.h`, it will "see" more things than
> it needs to, but if it builds, it should work?  I guess?  And anyway a
> subsequent goal will be to strip server.h to the bare minimum.
> Ultimately, it should only contain just a few things that should be
> suitable to both gdbserver and gdbreplay (include of
> gdbsupport/common-defs.h, include of gdbserver/config.h and a few other
> basic things).  Does that sound good to you?

You said a lot of different things, so I'm not sure which part I'd be agreeing with.  :-)

gdbreplay is a separate program that happens share a few bits of code with gdbserver, but
not that much.  It currently includes common-defs.h at the top of its source file.
So I think the really simplest is to make the rule for gdbreplay.o you were
adding use "-include common-defs.h".  Or add a new gdbreplay.h header that includes
common-defs.h and -include that one.

Anything else than that seems like a distraction at this point, and I wouldn't call those
other options simpler.  The look certainly more debatable to me.

  reply	other threads:[~2024-03-26 15:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-23  2:14 [PATCH v2 0/4] Include early include " Simon Marchi
2024-03-23  2:14 ` [PATCH v2 1/4] gdb, gdbserver, gdbsupport: reformat some Makefile variables, one entry per line Simon Marchi
2024-03-23  2:14 ` [PATCH v2 2/4] {gdb, gdbserver}/Makefile.in: remove unnecessary intermediary variables Simon Marchi
2024-03-23  2:14 ` [PATCH v2 3/4] gdb, gdbserver, gdbsupport: include early header files with `-include` Simon Marchi
2024-03-26 11:57   ` Pedro Alves
2024-03-26 14:39     ` Simon Marchi
2024-03-26 15:31       ` Pedro Alves [this message]
2024-03-26 15:49         ` Simon Marchi
2024-03-23  2:14 ` [PATCH v2 4/4] gdb, gdbserver, gdbsupport: remove includes of early headers Simon Marchi
2024-03-26 11:59   ` Pedro Alves
2024-03-26 14:58     ` Simon Marchi

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=80ffa3c0-7049-4b11-8c28-1a6b6ac5c0d7@palves.net \
    --to=pedro@palves.net \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    --cc=simon.marchi@efficios.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