public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* Fix -fprofile-use warnings/errors.
@ 2010-11-19 14:50 Phil Muldoon
  2010-11-19 15:20 ` Phil Muldoon
  0 siblings, 1 reply; 4+ messages in thread
From: Phil Muldoon @ 2010-11-19 14:50 UTC (permalink / raw)
  To: gdb-patches


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.

For reference, my configure and compile setup:

../gdb-patched/configure --enable-targets=all --prefix=/usr
                         --libdir=/usr/lib64 --sysconfdir=/etc --mandir=/usr/share/man
                         --infodir=/usr/share/info --with-gdb-datadir=/usr/share/gdb
                         --with-pythondir=/usr/share/gdb/python
                         --enable-gdb-build-warnings=,-Wno-unused --enable-werror
                         --with-separate-debug-dir=/usr/lib/debug --disable-sim --disable-rpath
                         --with-system-readline --with-expat --without-libexpat-prefix
                         --enable-tui --with-python --with-rpm=librpm.so.1 --without-libunwind
                         --enable-64-bit-bfd x86_64-redhat-linux-gnu

make CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
     -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic
     -fprofile-use"


Test on x8664 with no regressions.

Cheers,

Phil

--
2010-11-19  Phil Muldoon  <pmuldoon@redhat.com>

	* cris-tdep.c (cris_software_single_step): Initialize variables
          to appease fprofile-use warnings.
        * macroexp.c (expand): Ditto.
        * remote-m32r-sdi.c: Ditto.
        * xcoffread.c (read_xcoff_symtab): Ditto.

gdbserver:

2010-11-19  Phil Muldoon  <pmuldoon@redhat.com>

        * linux-x86-low.c (ATTR_NOINLINE_NOCLONE): Define.
        (add_insns): Use ATTR_NOLINE_NOCLONE.

--

diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 52a89de..7045cb9 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -2134,10 +2134,15 @@ cris_software_single_step (struct frame_info *frame)
   struct gdbarch *gdbarch = get_frame_arch (frame);
   struct address_space *aspace = get_frame_address_space (frame);
   inst_env_type inst_env;
+  int status;
+
+  /* GCC -fprofile-use warning.  */
+  memset (&inst_env, 0, sizeof (inst_env));
 
   /* Analyse the present instruction environment and insert 
      breakpoints.  */
-  int status = find_step_target (frame, &inst_env);
+  status = find_step_target (frame, &inst_env);
+
   if (status == -1)
     {
       /* Could not find a target.  Things are likely to go downhill 
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 49e9e55..bfd4698 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -89,6 +89,12 @@ static const char *xmltarget_amd64_linux_no_xml = "@<target>\
 #define ARCH_GET_GS 0x1004
 #endif
 
+#if defined(__GNUC__)
+#  define ATTR_NOINLINE_NOCLONE __attribute__((noinline, noclone))
+#else
+#  define ATTR_NOINLINE_NOCLONE
+#endif
+
 /* Per-process arch-specific data we want to keep.  */
 
 struct arch_process_info
@@ -1520,7 +1526,7 @@ x86_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
 						adjusted_insn_addr_end);
 }
 
-static void
+static void ATTR_NOINLINE_NOCLONE
 add_insns (unsigned char *start, int len)
 {
   CORE_ADDR buildaddr = current_insn_ptr;
diff --git a/gdb/macroexp.c b/gdb/macroexp.c
index 86689c3..972e953 100644
--- a/gdb/macroexp.c
+++ b/gdb/macroexp.c
@@ -1184,6 +1184,9 @@ expand (const char *id,
       struct macro_buffer va_arg_name;
       int is_varargs = 0;
 
+      /* GCC false -fprofile-use warning.  */
+      memset (&va_arg_name, 0, sizeof (va_arg_name));
+
       if (def->argc >= 1)
 	{
 	  if (strcmp (def->argv[def->argc - 1], "...") == 0)
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/xcoffread.c b/gdb/xcoffread.c
index 902d48f..196fec1 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -961,6 +961,9 @@ read_xcoff_symtab (struct partial_symtab *pst)
   CORE_ADDR last_csect_val;
   int last_csect_sec;
 
+  /* GCC -fprofile-use warning.  */
+  memset (&fcn_aux_saved, 0, sizeof (fcn_aux_saved));
+
   this_symtab_psymtab = pst;
 
   /* Get the appropriate COFF "constants" related to the file we're

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fix -fprofile-use warnings/errors.
  2010-11-19 14:50 Fix -fprofile-use warnings/errors Phil Muldoon
@ 2010-11-19 15:20 ` Phil Muldoon
  2010-11-19 16:13   ` (reposted) " Phil Muldoon
  0 siblings, 1 reply; 4+ messages in thread
From: Phil Muldoon @ 2010-11-19 15:20 UTC (permalink / raw)
  To: gdb-patches

Phil Muldoon <pmuldoon@redhat.com> 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.

Cheers,

Phil

^ permalink raw reply	[flat|nested] 4+ messages in thread

* (reposted) Fix -fprofile-use warnings/errors.
  2010-11-19 15:20 ` Phil Muldoon
@ 2010-11-19 16:13   ` Phil Muldoon
  2010-11-19 17:46     ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Phil Muldoon @ 2010-11-19 16:13 UTC (permalink / raw)
  To: gdb-patches

Phil Muldoon <pmuldoon@redhat.com> writes:

> Phil Muldoon <pmuldoon@redhat.com> 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


2010-11-19  Phil Muldoon  <pmuldoon@redhat.com>

	* cris-tdep.c (cris_software_single_step): Initialize variables
          to appease fprofile-use warnings.
        * macroexp.c (expand): Ditto.
        * remote-m32r-sdi.c: Ditto.
        * xcoffread.c (read_xcoff_symtab): Ditto.
        * gcore.c (objfile_find_memory_regions): Ditto.
        * infcall.c (find_function_addr): Ditto.
        * printcmd.c (sym_info): Ditto.
        * symfile.c (overlay_invalidate_all, find_pc_overlay,
          find_pc_mapped_section, list_overlays_command,
          map_overlay_command, unmap_overlay_command): Ditto.
        * xcoffread.c (read_xcoff_symtab): Ditto.

gdbserver:

2010-11-19  Phil Muldoon  <pmuldoon@redhat.com>

        * linux-x86-low.c (ATTR_NOINLINE_NOCLONE): Define.
        (add_insns): Use ATTR_NOLINE_NOCLONE.

--
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 52a89de..7045cb9 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -2134,10 +2134,15 @@ cris_software_single_step (struct frame_info *frame)
   struct gdbarch *gdbarch = get_frame_arch (frame);
   struct address_space *aspace = get_frame_address_space (frame);
   inst_env_type inst_env;
+  int status;
+
+  /* GCC -fprofile-use warning.  */
+  memset (&inst_env, 0, sizeof (inst_env));
 
   /* Analyse the present instruction environment and insert 
      breakpoints.  */
-  int status = find_step_target (frame, &inst_env);
+  status = find_step_target (frame, &inst_env);
+
   if (status == -1)
     {
       /* Could not find a target.  Things are likely to go downhill 
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 9fc0a7f..e45a8df 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -465,7 +465,7 @@ objfile_find_memory_regions (find_memory_region_ftype func, void *obfd)
 {
   /* Use objfile data to create memory sections.  */
   struct objfile *objfile;
-  struct obj_section *objsec;
+  struct obj_section *objsec = NULL; /* GCC -fprofile-use warning.  */
   bfd_vma temp_bottom, temp_top;
 
   /* Call callback function for each objfile section.  */
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 49e9e55..bfd4698 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -89,6 +89,12 @@ static const char *xmltarget_amd64_linux_no_xml = "@<target>\
 #define ARCH_GET_GS 0x1004
 #endif
 
+#if defined(__GNUC__)
+#  define ATTR_NOINLINE_NOCLONE __attribute__((noinline, noclone))
+#else
+#  define ATTR_NOINLINE_NOCLONE
+#endif
+
 /* Per-process arch-specific data we want to keep.  */
 
 struct arch_process_info
@@ -1520,7 +1526,7 @@ x86_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
 						adjusted_insn_addr_end);
 }
 
-static void
+static void ATTR_NOINLINE_NOCLONE
 add_insns (unsigned char *start, int len)
 {
   CORE_ADDR buildaddr = current_insn_ptr;
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 7f60e56..0f63baf 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -235,7 +235,7 @@ find_function_addr (struct value *function, struct type **retval_type)
   struct gdbarch *gdbarch = get_type_arch (ftype);
   enum type_code code = TYPE_CODE (ftype);
   struct type *value_type = NULL;
-  CORE_ADDR funaddr;
+  CORE_ADDR funaddr = 0;  /* GCC -fprofile-use warning.  */
 
   /* If it's a member function, just look at the function
      part of it.  */
diff --git a/gdb/macroexp.c b/gdb/macroexp.c
index 86689c3..972e953 100644
--- a/gdb/macroexp.c
+++ b/gdb/macroexp.c
@@ -1184,6 +1184,9 @@ expand (const char *id,
       struct macro_buffer va_arg_name;
       int is_varargs = 0;
 
+      /* GCC false -fprofile-use warning.  */
+      memset (&va_arg_name, 0, sizeof (va_arg_name));
+
       if (def->argc >= 1)
 	{
 	  if (strcmp (def->argv[def->argc - 1], "...") == 0)
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 5586767..a518958 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1089,7 +1089,7 @@ sym_info (char *arg, int from_tty)
 {
   struct minimal_symbol *msymbol;
   struct objfile *objfile;
-  struct obj_section *osect;
+  struct obj_section *osect = NULL;   /* GCC -fprofile-use warning.  */
   CORE_ADDR addr, sect_addr;
   int matches = 0;
   unsigned int offset;
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
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2872,7 +2872,7 @@ static void
 overlay_invalidate_all (void)
 {
   struct objfile *objfile;
-  struct obj_section *sect;
+  struct obj_section *sect = NULL; /* GCC -fprofile-use warning.  */
 
   ALL_OBJSECTIONS (objfile, sect)
     if (section_is_overlay (sect))
@@ -3050,7 +3050,8 @@ struct obj_section *
 find_pc_overlay (CORE_ADDR pc)
 {
   struct objfile *objfile;
-  struct obj_section *osect, *best_match = NULL;
+  /* GCC -fprofile-use warning.  Set to NULL*/
+  struct obj_section *osect = NULL, *best_match = NULL;
 
   if (overlay_debugging)
     ALL_OBJSECTIONS (objfile, osect)
@@ -3077,7 +3078,7 @@ struct obj_section *
 find_pc_mapped_section (CORE_ADDR pc)
 {
   struct objfile *objfile;
-  struct obj_section *osect;
+  struct obj_section *osect = NULL;  /* GCC -fprofile-use warning.  */
 
   if (overlay_debugging)
     ALL_OBJSECTIONS (objfile, osect)
@@ -3095,7 +3096,7 @@ list_overlays_command (char *args, int from_tty)
 {
   int nmapped = 0;
   struct objfile *objfile;
-  struct obj_section *osect;
+  struct obj_section *osect = NULL;   /* GCC -fprofile-use warning.  */
 
   if (overlay_debugging)
     ALL_OBJSECTIONS (objfile, osect)
@@ -3134,7 +3135,9 @@ void
 map_overlay_command (char *args, int from_tty)
 {
   struct objfile *objfile, *objfile2;
-  struct obj_section *sec, *sec2;
+  /* GCC -fprofile-use warning.  Set to NULL*/
+  struct obj_section *sec = NULL, *sec2 = NULL;
+
 
   if (!overlay_debugging)
     error (_("\
@@ -3179,7 +3182,7 @@ void
 unmap_overlay_command (char *args, int from_tty)
 {
   struct objfile *objfile;
-  struct obj_section *sec;
+  struct obj_section *sec = NULL; /* GCC-fprofile-use warning.  */
 
   if (!overlay_debugging)
     error (_("\
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 902d48f..196fec1 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -961,6 +961,9 @@ read_xcoff_symtab (struct partial_symtab *pst)
   CORE_ADDR last_csect_val;
   int last_csect_sec;
 
+  /* GCC -fprofile-use warning.  */
+  memset (&fcn_aux_saved, 0, sizeof (fcn_aux_saved));
+
   this_symtab_psymtab = pst;
 
   /* Get the appropriate COFF "constants" related to the file we're

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: (reposted) Fix -fprofile-use warnings/errors.
  2010-11-19 16:13   ` (reposted) " Phil Muldoon
@ 2010-11-19 17:46     ` Pedro Alves
  0 siblings, 0 replies; 4+ messages in thread
From: Pedro Alves @ 2010-11-19 17:46 UTC (permalink / raw)
  To: gdb-patches, pmuldoon

On Friday 19 November 2010 16:13:30, Phil Muldoon wrote:
> Phil Muldoon <pmuldoon@redhat.com> writes:
> 
> > Phil Muldoon <pmuldoon@redhat.com> 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  <pmuldoon@redhat.com>
> 
>         * 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-11-19 17:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-19 14:50 Fix -fprofile-use warnings/errors Phil Muldoon
2010-11-19 15:20 ` Phil Muldoon
2010-11-19 16:13   ` (reposted) " Phil Muldoon
2010-11-19 17:46     ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).