From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id PomqJifeAmZs6hYAWB0awg (envelope-from ) for ; Tue, 26 Mar 2024 10:39:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1711463975; bh=Nh/uPaqXq1eYL48TCvY8Tuki0EwqOUYd04ICSbIVbm4=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=bew772Fvmgvf2SstcdwUHvdVSh3VCg75DV/nU1QwXVKFV8yO34E5/elnrbW8vHVJ4 C7HSmOS437i2ONL+QrZnUu3NVQpe4OJDDhoVC/sLdT226ljgMkdRYyaNJpeyaWn4Wz bQqMokXaDQcEr6u/4Ozp2vaaa99leCghtZU9NiOk= Received: by simark.ca (Postfix, from userid 112) id 8DD281E0C0; Tue, 26 Mar 2024 10:39:35 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=LwJf9j37; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 67F8C1E030 for ; Tue, 26 Mar 2024 10:39:33 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1E4FD3858436 for ; Tue, 26 Mar 2024 14:39:33 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 39C863858C56 for ; Tue, 26 Mar 2024 14:39:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 39C863858C56 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 39C863858C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711463954; cv=none; b=icrkxW2mfIWTEcf+iuXQjNGTMJbVuII4XaByzzVgTuJIjnVLdq6EZaQkALeBiYH2D0lDr+Ug8ggONHczm5MO7eVuBa0ffyRbAGJyOvgFZ8PEa2sB8qd0h05raRanrE93VUCM9aXqARmxi8nlW+PQ5Qn1GAg0rTKtQGxVIXmPvD4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711463954; c=relaxed/simple; bh=Nh/uPaqXq1eYL48TCvY8Tuki0EwqOUYd04ICSbIVbm4=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=Xtq8z2yQGZMzi9VYXmhzqI/yYGMEKt6w9SIGehU/xvXHhpctvrEiuLtunumIZw1Z72Y8m2kCfFhaqof3o9M6y6wDFjaTVDmBZwGW7iqzR7mGsGkmouAkiDvrRAkUgYNKhNlois+xJNVQ/oZP7PQPC1mLM+vbghiZJ8/0zsVrun4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1711463950; bh=Nh/uPaqXq1eYL48TCvY8Tuki0EwqOUYd04ICSbIVbm4=; h=Date:Subject:To:References:From:In-Reply-To:From; b=LwJf9j37E5rmee974XwBAclvrmYBWA1U4yp1CrUOYS971gulifdsREhopepS+P51r cu1fgbBDiZXeNPwC0tggwfs7mmhZkzkaSatQglgpVcNffY2OVJSi0mWi25WIxcYaJS miLAdnDx4thSc0CZw9q6nOX1FxPxVtBwh+9+7u60= Received: from [10.0.0.170] (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 8E2D51E030; Tue, 26 Mar 2024 10:39:10 -0400 (EDT) Message-ID: Date: Tue, 26 Mar 2024 10:39:10 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 3/4] gdb, gdbserver, gdbsupport: include early header files with `-include` To: Pedro Alves , Simon Marchi , gdb-patches@sourceware.org References: <20240323021648.154109-1-simon.marchi@efficios.com> <20240323021648.154109-4-simon.marchi@efficios.com> Content-Language: fr From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org On 3/26/24 7:57 AM, Pedro Alves wrote: > On 2024-03-23 02:14, Simon Marchi wrote: > >> With this change, clangd picks up the -include option from the compile >> command, and is able to analyze the header file correctly, as it sees >> all that stuff included or defined but that -include option. That works > > but that -> by that Fixed. >> - There is one problem for gdbserver's Makefile: we do not want to >> include server.h when building `gdbreplay.o`. So we can't simply put >> the `-include` in `INTERNAL_CFLAGS`. I added the `-include` option >> to the `COMPILE` and `IPAGENT_COMPILE` variables, and added a special >> rule to compile `gdbreplay.o`. >> > > ... > > >> diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in >> index 45073abca493..4d29491a8721 100644 >> --- a/gdbserver/Makefile.in >> +++ b/gdbserver/Makefile.in >> @@ -69,9 +69,11 @@ COMPILE.pre = $(CXX) $(CXX_DIALECT) >> COMPILE.post = -c -o $@ >> POSTCOMPILE = @true >> >> +INCLUDE_SERVER_H = -include $(srcdir)/server.h >> + > > ... > >> +# 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 : /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? Simon