From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25876 invoked by alias); 19 Nov 2010 17:46:55 -0000 Received: (qmail 25857 invoked by uid 22791); 19 Nov 2010 17:46:52 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 19 Nov 2010 17:46:47 +0000 Received: (qmail 24205 invoked from network); 19 Nov 2010 17:46:46 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 19 Nov 2010 17:46:46 -0000 From: Pedro Alves To: gdb-patches@sourceware.org, pmuldoon@redhat.com Subject: Re: (reposted) Fix -fprofile-use warnings/errors. Date: Fri, 19 Nov 2010 17:46:00 -0000 User-Agent: KMail/1.13.5 (Linux/2.6.33-29-realtime; KDE/4.4.5; x86_64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201011191746.40239.pedro@codesourcery.com> X-IsSubscribed: yes 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 X-SW-Source: 2010-11/txt/msg00264.txt.bz2 On Friday 19 November 2010 16:13:30, Phil Muldoon wrote: > Phil Muldoon writes: > > > Phil Muldoon writes: > > > >> This patch corrects (and in some cases, appeases) compiler warnings > >> generated through the use of -fprofile-use. We've had a variant patch > >> for sometime in the Fedora GDB. This updates HEAD. > > > > And just as soon as I post the patch I realize some of the profile data > > was stale. Sorry for the noise, but I will post another (larger) patch > > very shortly. > > Here is an updated patch Interesting, $ make CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -fprofile-use" -j4 -k only shows these for me: ../../src/gdb/remote-m32r-sdi.c: In function 'm32r_can_use_hw_watchpoint': ../../src/gdb/remote-m32r-sdi.c:1699: note: file /home/pedro/gdb/baseline/build-profile-use/gdb/remote-m32r-sdi.gcda not found, execution counts estimated cc1: warnings being treated as errors ../../src/gdb/macroexp.c: In function 'expand': ../../src/gdb/macroexp.c:1184: error: 'va_arg_name.len' may be used uninitialized in this function ../../src/gdb/macroexp.c:1184: error: 'va_arg_name.text' may be used uninitialized in this function make: *** [macroexp.o] Error 1 cc1: warnings being treated as errors ../../src/gdb/remote-m32r-sdi.c: In function 'm32r_open': ../../src/gdb/remote-m32r-sdi.c:276: error: 'val' may be used uninitialized in this function ../../src/gdb/remote-m32r-sdi.c:276: note: 'val' was declared here ../../src/gdb/remote-m32r-sdi.c:276: error: 'val' may be used uninitialized in this function ../../src/gdb/remote-m32r-sdi.c:276: note: 'val' was declared here make: *** [remote-m32r-sdi.o] Error 1 make: Target `all' not remade because of errors. (ubuntu 10.4's gcc 4.4.3) > gdbserver: > > 2010-11-19 Phil Muldoon > > * linux-x86-low.c (ATTR_NOINLINE_NOCLONE): Define. > (add_insns): Use ATTR_NOLINE_NOCLONE. Hmm, what's the warning like? (In fact, it's always a good idea to paste the warnings log being fixed for patches like these. Makes it oh so much easier to review.) > diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c > index 2b67927..bd06950 100644 > --- a/gdb/remote-m32r-sdi.c > +++ b/gdb/remote-m32r-sdi.c > @@ -273,7 +273,7 @@ send_three_arg_cmd (unsigned char cmd, unsigned long arg1, unsigned long arg2, > static unsigned char > recv_char_data (void) > { > - unsigned char val; > + unsigned char val = 0; /* GCC -fprofile-use warning. */ > > recv_data (&val, 1); > return val; > diff --git a/gdb/symfile.c b/gdb/symfile.c > index f1c2941..098962b 100644 I only took a look at this one, but the warning looks correct to me. When recv_data returns -1, &val is not set. So, this pacifies the warning, Index: src/gdb/remote-m32r-sdi.c =================================================================== --- src.orig/gdb/remote-m32r-sdi.c 2010-10-19 19:54:31.000000000 +0100 +++ src/gdb/remote-m32r-sdi.c 2010-11-19 17:36:06.000000000 +0000 @@ -275,7 +275,9 @@ recv_char_data (void) { unsigned char val; - recv_data (&val, 1); + if (recv_data (&val, 1) < 0) + return 0; + return val; } but in wrapper functions that don't have an error return, we usually throw an error instead of returning a garbage value (0). It may be better in this case, it may not. In any case, I didn't look at the other cases, but I'd be better if we knew we were silencing real bogus warnings, instead of blindingly shutting them up, and papering over bugs. Can you clarify whether you investigated the warnings? -- Pedro Alves