public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: Ignore some stringop-overflow and restrict warnings on sparc
@ 2023-01-15  0:51 Mark Wielaard
  2023-01-23 11:45 ` Mark Wielaard
  2023-01-23 16:17 ` Simon Marchi
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Wielaard @ 2023-01-15  0:51 UTC (permalink / raw)
  To: gdb-patches; +Cc: Sam James, Mark Wielaard

For some reason g++ 11.2.1 on s390x produces a spurious warning for
stringop-overread and restruct in fsb-tdep.c for some memcpy calls.
Add new DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW and
DIAGNOSTIC_IGNORE_RESTRICT macro to suppress these warning.

include/ChangeLog:

	* diagnostics.h (DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW): New
	macro.
	(DIAGNOSTIC_IGNORE_RESTRICT): Likewise.

gdb/ChangeLog:

	* fsb-tdep.c (fbsd_make_note_desc): Use
	DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW and
	DIAGNOSTIC_IGNORE_RESTRICT on sparc.
---
 gdb/fbsd-tdep.c       | 10 ++++++++++
 include/diagnostics.h | 10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 203390d9880..ee2a4b54e85 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -19,6 +19,7 @@
 
 #include "defs.h"
 #include "auxv.h"
+#include "diagnostics.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "objfiles.h"
@@ -663,7 +664,16 @@ fbsd_make_note_desc (enum target_object object, uint32_t structsize)
 
   gdb::byte_vector desc (sizeof (structsize) + buf->size ());
   memcpy (desc.data (), &structsize, sizeof (structsize));
+#if defined (__sparc__)
+  /* g++ 12.2.1 on sparc seems confused about the vector buf sizes.  */
+  DIAGNOSTIC_PUSH
+  DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW
+  DIAGNOSTIC_IGNORE_RESTRICT
+#endif
   memcpy (desc.data () + sizeof (structsize), buf->data (), buf->size ());
+#if defined (__sparc__)
+  DIAGNOSTIC_POP
+#endif
   return desc;
 }
 
diff --git a/include/diagnostics.h b/include/diagnostics.h
index d3ff27bc008..617943ae0d7 100644
--- a/include/diagnostics.h
+++ b/include/diagnostics.h
@@ -94,6 +94,11 @@
   DIAGNOSTIC_IGNORE ("-Wstringop-overread")
 #endif
 
+# if __GNUC__ >= 7
+# define DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW \
+  DIAGNOSTIC_IGNORE ("-Wstringop-overflow")
+#endif
+
 # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
   DIAGNOSTIC_IGNORE ("-Wformat-nonliteral")
 
@@ -113,6 +118,7 @@
 #  define DIAGNOSTIC_ERROR_SWITCH DIAGNOSTIC_ERROR ("-Wswitch")
 # endif
 
+#define DIAGNOSTIC_IGNORE_RESTRICT DIAGNOSTIC_IGNORE ("-Wrestrict")
 #endif
 
 #ifndef DIAGNOSTIC_IGNORE_SELF_MOVE
@@ -139,6 +145,10 @@
 # define DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD
 #endif
 
+#ifndef DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW
+# define DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW
+#endif
+
 #ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
 # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
 #endif
-- 
2.31.1


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

* Re: [PATCH] gdb: Ignore some stringop-overflow and restrict warnings on sparc
  2023-01-15  0:51 [PATCH] gdb: Ignore some stringop-overflow and restrict warnings on sparc Mark Wielaard
@ 2023-01-23 11:45 ` Mark Wielaard
  2023-01-23 16:17 ` Simon Marchi
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Wielaard @ 2023-01-23 11:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Sam James

Hi,

On Sun, 2023-01-15 at 01:51 +0100, Mark Wielaard wrote:
> For some reason g++ 12.2.1 on sparc produces a spurious warning for
> stringop-overread and restruct in fsb-tdep.c for some memcpy calls.
> Add new DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW and
> DIAGNOSTIC_IGNORE_RESTRICT macro to suppress these warning.
> 
> include/ChangeLog:
> 
> 	* diagnostics.h (DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW): New
> 	macro.
> 	(DIAGNOSTIC_IGNORE_RESTRICT): Likewise.
> 
> gdb/ChangeLog:
> 
> 	* fsb-tdep.c (fbsd_make_note_desc): Use
> 	DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW and
> 	DIAGNOSTIC_IGNORE_RESTRICT on sparc.

Ping. This is the last patch needed to build gdb on the new gentoo-
sparc buildbot worker.

> ---
>  gdb/fbsd-tdep.c       | 10 ++++++++++
>  include/diagnostics.h | 10 ++++++++++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
> index 203390d9880..ee2a4b54e85 100644
> --- a/gdb/fbsd-tdep.c
> +++ b/gdb/fbsd-tdep.c
> @@ -19,6 +19,7 @@
>  
>  #include "defs.h"
>  #include "auxv.h"
> +#include "diagnostics.h"
>  #include "gdbcore.h"
>  #include "inferior.h"
>  #include "objfiles.h"
> @@ -663,7 +664,16 @@ fbsd_make_note_desc (enum target_object object, uint32_t structsize)
>  
>    gdb::byte_vector desc (sizeof (structsize) + buf->size ());
>    memcpy (desc.data (), &structsize, sizeof (structsize));
> +#if defined (__sparc__)
> +  /* g++ 12.2.1 on sparc seems confused about the vector buf sizes.  */
> +  DIAGNOSTIC_PUSH
> +  DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW
> +  DIAGNOSTIC_IGNORE_RESTRICT
> +#endif
>    memcpy (desc.data () + sizeof (structsize), buf->data (), buf->size ());
> +#if defined (__sparc__)
> +  DIAGNOSTIC_POP
> +#endif
>    return desc;
>  }
>  
> diff --git a/include/diagnostics.h b/include/diagnostics.h
> index d3ff27bc008..617943ae0d7 100644
> --- a/include/diagnostics.h
> +++ b/include/diagnostics.h
> @@ -94,6 +94,11 @@
>    DIAGNOSTIC_IGNORE ("-Wstringop-overread")
>  #endif
>  
> +# if __GNUC__ >= 7
> +# define DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW \
> +  DIAGNOSTIC_IGNORE ("-Wstringop-overflow")
> +#endif
> +
>  # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
>    DIAGNOSTIC_IGNORE ("-Wformat-nonliteral")
>  
> @@ -113,6 +118,7 @@
>  #  define DIAGNOSTIC_ERROR_SWITCH DIAGNOSTIC_ERROR ("-Wswitch")
>  # endif
>  
> +#define DIAGNOSTIC_IGNORE_RESTRICT DIAGNOSTIC_IGNORE ("-Wrestrict")
>  #endif
>  
>  #ifndef DIAGNOSTIC_IGNORE_SELF_MOVE
> @@ -139,6 +145,10 @@
>  # define DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD
>  #endif
>  
> +#ifndef DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW
> +# define DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW
> +#endif
> +
>  #ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
>  # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
>  #endif


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

* Re: [PATCH] gdb: Ignore some stringop-overflow and restrict warnings on sparc
  2023-01-15  0:51 [PATCH] gdb: Ignore some stringop-overflow and restrict warnings on sparc Mark Wielaard
  2023-01-23 11:45 ` Mark Wielaard
@ 2023-01-23 16:17 ` Simon Marchi
  2023-01-24  0:42   ` Mark Wielaard
  1 sibling, 1 reply; 4+ messages in thread
From: Simon Marchi @ 2023-01-23 16:17 UTC (permalink / raw)
  To: Mark Wielaard, gdb-patches; +Cc: Sam James



On 1/14/23 19:51, Mark Wielaard wrote:
> For some reason g++ 11.2.1 on s390x produces a spurious warning for
> stringop-overread and restruct in fsb-tdep.c for some memcpy calls.

fsb -> fbsd
restruct -> restrict

> Add new DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW and
> DIAGNOSTIC_IGNORE_RESTRICT macro to suppress these warning.

Can you please put examples of the diagnostics it gets rid of in the
commit message?

Simon

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

* Re: [PATCH] gdb: Ignore some stringop-overflow and restrict warnings on sparc
  2023-01-23 16:17 ` Simon Marchi
@ 2023-01-24  0:42   ` Mark Wielaard
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Wielaard @ 2023-01-24  0:42 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches, Sam James

Hi Simon,

On Mon, Jan 23, 2023 at 11:17:17AM -0500, Simon Marchi wrote:
> 
> 
> On 1/14/23 19:51, Mark Wielaard wrote:
> > stringop-overread and restruct in fsb-tdep.c for some memcpy calls.
> 
> fsb -> fbsd
> restruct -> restrict

Gah, so many typos, apologies. Fixed.
 
> > Add new DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW and
> > DIAGNOSTIC_IGNORE_RESTRICT macro to suppress these warning.
> 
> Can you please put examples of the diagnostics it gets rid of in the
> commit message?

Added.

I'll sent a V2 with the updated commit message.

Thanks,

Mark

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

end of thread, other threads:[~2023-01-24  0:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-15  0:51 [PATCH] gdb: Ignore some stringop-overflow and restrict warnings on sparc Mark Wielaard
2023-01-23 11:45 ` Mark Wielaard
2023-01-23 16:17 ` Simon Marchi
2023-01-24  0:42   ` Mark Wielaard

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).