Message ID | 20180712205208.32646-13-tom@tromey.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 53920 invoked by alias); 12 Jul 2018 20:52:17 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 53776 invoked by uid 89); 12 Jul 2018 20:52:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1615 X-HELO: gateway23.websitewelcome.com Received: from gateway23.websitewelcome.com (HELO gateway23.websitewelcome.com) (192.185.48.84) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Jul 2018 20:52:15 +0000 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 51CFB10694 for <gdb-patches@sourceware.org>; Thu, 12 Jul 2018 15:52:14 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id diZSfi3pbRPojdiZSfH6Bk; Thu, 12 Jul 2018 15:52:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=1sb/Nwcdv70z8+PKgixUaczMFIBUzxfwPa8Df6tBlv0=; b=WrTae3WJDyBMKM5AUV8W7/57Ud AplNnI8CGFin4lP0CHzZbH+1cQH5qvLy8Hxy/IXvZetRrnAQ+6YgBZ80UOb4TFFNL9vbUB+IM4uEs 9cPgI0vxEiPUclyGN5JE+7bHk; Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:49432 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from <tom@tromey.com>) id 1fdiZS-001ZuD-2E; Thu, 12 Jul 2018 15:52:14 -0500 From: Tom Tromey <tom@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey <tom@tromey.com> Subject: [RFA 12/13] Add ATTRIBUTE_UNUSED to regdat.sh output Date: Thu, 12 Jul 2018 14:52:07 -0600 Message-Id: <20180712205208.32646-13-tom@tromey.com> In-Reply-To: <20180712205208.32646-1-tom@tromey.com> References: <20180712205208.32646-1-tom@tromey.com> |
Commit Message
Tom Tromey
July 12, 2018, 8:52 p.m. UTC
This changes regdat.sh to emit ATTRIBUTE_UNUSED for the xmltarget_${name} variable. This seemed simpler than trying to figure out under exactly which circumstances each one was in fact used. 2018-07-12 Tom Tromey <tom@tromey.com> * regformats/regdat.sh: Mark xmltarget_${name} with ATTRIBUTE_UNUSED. --- gdb/ChangeLog | 5 +++++ gdb/regformats/regdat.sh | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-)
Comments
On 07/12/2018 09:52 PM, Tom Tromey wrote: > This changes regdat.sh to emit ATTRIBUTE_UNUSED for the > xmltarget_${name} variable. This seemed simpler than trying to figure > out under exactly which circumstances each one was in fact used. Can you give an example configuration where you got a warning? Thanks, Pedro Alves > > 2018-07-12 Tom Tromey <tom@tromey.com> > > * regformats/regdat.sh: Mark xmltarget_${name} with > ATTRIBUTE_UNUSED. > --- > gdb/ChangeLog | 5 +++++ > gdb/regformats/regdat.sh | 8 ++++---- > 2 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh > index 5a8564ac50c..7868e757582 100755 > --- a/gdb/regformats/regdat.sh > +++ b/gdb/regformats/regdat.sh > @@ -164,12 +164,12 @@ done > echo > echo "static const char *expedite_regs_${name}[] = { \"`echo ${expedite} | sed 's/,/", "/g'`\", 0 };" > if test "${feature}" != x; then > - echo "static const char *xmltarget_${name} = 0;" > + echo "static const char *xmltarget_${name} ATTRIBUTE_UNUSED = 0;" > elif test "${xmltarget}" = x; then > if test "${xmlarch}" = x && test "${xmlosabi}" = x; then > - echo "static const char *xmltarget_${name} = 0;" > + echo "static const char *xmltarget_${name} ATTRIBUTE_UNUSED = 0;" > else > - echo "static const char *xmltarget_${name} = \"@<target>\\" > + echo "static const char *xmltarget_${name} ATTRIBUTE_UNUSED = \"@<target>\\" > if test "${xmlarch}" != x; then > echo "<architecture>${xmlarch}</architecture>\\" > fi > @@ -179,7 +179,7 @@ elif test "${xmltarget}" = x; then > echo "</target>\";" > fi > else > - echo "static const char *xmltarget_${name} = \"${xmltarget}\";" > + echo "static const char *xmltarget_${name} ATTRIBUTE_UNUSED = \"${xmltarget}\";" > fi > echo > >
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes: Pedro> On 07/12/2018 09:52 PM, Tom Tromey wrote: >> This changes regdat.sh to emit ATTRIBUTE_UNUSED for the >> xmltarget_${name} variable. This seemed simpler than trying to figure >> out under exactly which circumstances each one was in fact used. Pedro> Can you give an example configuration where you got a warning? I only found this one via the buildbot: https://gdb-build.sergiodj.net/builders/Fedora-s390x-m64/builds/9085 It fails like so: s390-linux32-generated.c: In function ‘void init_registers_s390_linux32()’: s390-linux32-generated.c:141:20: error: unused variable ‘xmltarget_s390_linux32’ [-Werror=unused-variable] static const char *xmltarget_s390_linux32 = "s390-linux32.xml"; ^~~~~~~~~~~~~~~~~~~~~~ s390-linux32v1-generated.c: In function ‘void init_registers_s390_linux32v1()’: s390-linux32v1-generated.c:143:20: error: unused variable ‘xmltarget_s390_linux32v1’ [-Werror=unused-variable] static const char *xmltarget_s390_linux32v1 = "s390-linux32v1.xml"; ^~~~~~~~~~~~~~~~~~~~~~~~ s390-linux32-generated.c: At global scope: s390-linux32-generated.c:141:20: error: ‘xmltarget_s390_linux32’ defined but not used [-Werror=unused-variable] s390-linux32v1-generated.c: At global scope: s390-linux32v1-generated.c:143:20: error: ‘xmltarget_s390_linux32v1’ defined but not used [-Werror=unused-variable] Tom
On 07/16/2018 05:40 PM, Tom Tromey wrote: >>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes: > > Pedro> On 07/12/2018 09:52 PM, Tom Tromey wrote: >>> This changes regdat.sh to emit ATTRIBUTE_UNUSED for the >>> xmltarget_${name} variable. This seemed simpler than trying to figure >>> out under exactly which circumstances each one was in fact used. > > Pedro> Can you give an example configuration where you got a warning? > > I only found this one via the buildbot: > > https://gdb-build.sergiodj.net/builders/Fedora-s390x-m64/builds/9085 > > > It fails like so: > > s390-linux32-generated.c: In function ‘void init_registers_s390_linux32()’: > s390-linux32-generated.c:141:20: error: unused variable ‘xmltarget_s390_linux32’ [-Werror=unused-variable] > static const char *xmltarget_s390_linux32 = "s390-linux32.xml"; > ^~~~~~~~~~~~~~~~~~~~~~ > s390-linux32v1-generated.c: In function ‘void init_registers_s390_linux32v1()’: > s390-linux32v1-generated.c:143:20: error: unused variable ‘xmltarget_s390_linux32v1’ [-Werror=unused-variable] > static const char *xmltarget_s390_linux32v1 = "s390-linux32v1.xml"; > ^~~~~~~~~~~~~~~~~~~~~~~~ > s390-linux32-generated.c: At global scope: > s390-linux32-generated.c:141:20: error: ‘xmltarget_s390_linux32’ defined but not used [-Werror=unused-variable] > s390-linux32v1-generated.c: At global scope: > s390-linux32v1-generated.c:143:20: error: ‘xmltarget_s390_linux32v1’ defined but not used [-Werror=unused-variable] This is building an ipa object: s390-linux32-generated.c: In function ‘void init_registers_s390_linux32()’: s390-linux32-generated.c:141:20: error: unused variable ‘xmltarget_s390_linux32’ [-Werror=unused-variable] static const char *xmltarget_s390_linux32 = "s390-linux32.xml"; ^~~~~~~~~~~~~~~~~~~~~~ s390-linux32v1-generated.c: In function ‘void init_registers_s390_linux32v1()’: s390-linux32v1-generated.c:143:20: error: unused variable ‘xmltarget_s390_linux32v1’ [-Werror=unused-variable] static const char *xmltarget_s390_linux32v1 = "s390-linux32v1.xml"; ^~~~~~~~~~~~~~~~~~~~~~~~ s390-linux32-generated.c: At global scope: s390-linux32-generated.c:141:20: error: ‘xmltarget_s390_linux32’ defined but not used [-Werror=unused-variable] s390-linux32v1-generated.c: At global scope: s390-linux32v1-generated.c:143:20: error: ‘xmltarget_s390_linux32v1’ defined but not used [-Werror=unused-variable] cc1plus: all warnings being treated as errors make[4]: *** [Makefile:576: s390-linux32-ipa.o] Error 1 The generated files look something like this (here for x86-64): static const char *expedite_regs_amd64_linux[] = { "rbp", "rsp", "rip", 0 }; static const char *xmltarget_amd64_linux = 0; #ifndef IN_PROCESS_AGENT result->xmltarget = xmltarget_amd64_linux; #endif So the xmltarget_foo variable is defined unconditionally, but used only when #ifndef IN_PROCESS_AGENT. So if we wrap the variable definition in !IN_PROCESS_AGENT too, the warning should go away. I guess that getting warning or not is most likely dependent on GCC version. Thanks, Pedro Alves
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> So the xmltarget_foo variable is defined unconditionally, but
Pedro> used only when #ifndef IN_PROCESS_AGENT. So if we wrap the variable
Pedro> definition in !IN_PROCESS_AGENT too, the warning should go away.
Thanks for looking into this.
I'm testing a series with this update.
Tom
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes: >>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes: Pedro> So the xmltarget_foo variable is defined unconditionally, but Pedro> used only when #ifndef IN_PROCESS_AGENT. So if we wrap the variable Pedro> definition in !IN_PROCESS_AGENT too, the warning should go away. Tom> Thanks for looking into this. Tom> I'm testing a series with this update. To my surprise this turned out amazingly badly. I don't know why yet. Tom
diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh index 5a8564ac50c..7868e757582 100755 --- a/gdb/regformats/regdat.sh +++ b/gdb/regformats/regdat.sh @@ -164,12 +164,12 @@ done echo echo "static const char *expedite_regs_${name}[] = { \"`echo ${expedite} | sed 's/,/", "/g'`\", 0 };" if test "${feature}" != x; then - echo "static const char *xmltarget_${name} = 0;" + echo "static const char *xmltarget_${name} ATTRIBUTE_UNUSED = 0;" elif test "${xmltarget}" = x; then if test "${xmlarch}" = x && test "${xmlosabi}" = x; then - echo "static const char *xmltarget_${name} = 0;" + echo "static const char *xmltarget_${name} ATTRIBUTE_UNUSED = 0;" else - echo "static const char *xmltarget_${name} = \"@<target>\\" + echo "static const char *xmltarget_${name} ATTRIBUTE_UNUSED = \"@<target>\\" if test "${xmlarch}" != x; then echo "<architecture>${xmlarch}</architecture>\\" fi @@ -179,7 +179,7 @@ elif test "${xmltarget}" = x; then echo "</target>\";" fi else - echo "static const char *xmltarget_${name} = \"${xmltarget}\";" + echo "static const char *xmltarget_${name} ATTRIBUTE_UNUSED = \"${xmltarget}\";" fi echo