* Avoid gcc warning on sparc solaris 9
@ 2007-10-23 16:46 Pedro Alves
2007-10-23 17:56 ` Ulrich Weigand
0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2007-10-23 16:46 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2454 bytes --]
Hi,
Building HEAD on a native gdb on sparc solaris 9 with gcc 3.4.6 stops due to:
gcc -c -g -O2 -I. -I../../src/gdb -I../../src/gdb/config
-DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H
-I../../src/gdb/../include/opcode -I../../src/gdb/../readline/..
-I../bfd -I../../src/gdb/../bfd -I../../src/gdb/../include -I./../intl
-DMI_OUT=1 -DTUI=1 -I/usr/local/include -Wall
-Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral
-Wno-unused -Wno-switch -Wno-char-subscripts -Werror
../../src/gdb/sol-thread.c
../../src/gdb/sol-thread.c: In function `sol_thread_fetch_registers':
../../src/gdb/sol-thread.c:533: warning: dereferencing type-punned
pointer will break strict-aliasing rules
make: *** [sol-thread.o] Error 1
gcc -v
Reading specs from /usr/local/lib/gcc/sparc-sun-solaris2.9/3.4.6/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as
--with-ld=/usr/ccs/bin/ld --enable-shared --enable-languages=c,c++,f77
Thread model: posix
gcc version 3.4.6
uname -a
SunOS ol154 5.9 Generic_117171-13 sun4u sparc SUNW,Sun-Fire-480R Solaris
The attached patch gets me going.
config/sparc/nm-sol2.h has these, so it looks safe on sparc:
#define GDB_GREGSET_T prgregset_t
#define GDB_FPREGSET_T prfpregset_t
Here's a simplified preprocessed output of sol-thread.c:
typedef prgregset_t gdb_gregset_t;
typedef prfpregset_t gdb_fpregset_t;
extern void supply_gregset (struct regcache *regcache,
const gdb_gregset_t *gregs);
extern void supply_fpregset (struct regcache *regcache,
const gdb_fpregset_t *fpregs);
static void
sol_thread_fetch_registers (struct regcache *regcache, int regnum)
{
prgregset_t gregset;
prfpregset_t fpregset;
supply_gregset (regcache, (const gdb_gregset_t *) &gregset);
supply_fpregset (regcache, (const gdb_fpregset_t *) &fpregset);
}
But I'm not sure it's correct, since the i386 sparc config files don't set
GDB_{G|FP}REGSET, so they should be defaulting to:
gregset.h:
#ifndef GDB_GREGSET_T
#define GDB_GREGSET_T gregset_t
#endif
#ifndef GDB_FPREGSET_T
#define GDB_FPREGSET_T fpregset_t
#endif
I ran the testsuite on it, and this is what I got:
=== gdb Summary ===
# of expected passes 10898
# of unexpected failures 81
# of unexpected successes 2
# of expected failures 47
# of known failures 42
# of unresolved testcases 3
# of untested testcases 8
# of unsupported tests 25
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: solaris.diff --]
[-- Type: text/x-patch; name=solaris.diff, Size: 1368 bytes --]
2007-10-23 Pedro Alves <pedro_alves@portugalmail.pt>
* sol-thread.c (sol_thread_fetch_registers): Avoid alias warning.
Add assertion to verify correct size of gdb_gregset_t and
gdb_fpregset_t.
---
gdb/sol-thread.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Index: src/gdb/sol-thread.c
===================================================================
--- src.orig/gdb/sol-thread.c 2007-10-23 15:14:44.529038000 +0100
+++ src/gdb/sol-thread.c 2007-10-23 15:15:49.819263000 +0100
@@ -484,6 +484,10 @@ sol_thread_fetch_registers (struct regca
td_err_e val;
prgregset_t gregset;
prfpregset_t fpregset;
+
+ gdb_assert (sizeof (prgregset_t) == sizeof (gdb_gregset_t));
+ gdb_assert (sizeof (prfpregset_t) == sizeof (gdb_fpregset_t));
+
#if 0
int xregsize;
caddr_t xregset;
@@ -530,8 +534,8 @@ sol_thread_fetch_registers (struct regca
calling the td routines because the td routines call ps_lget*
which affect the values stored in the registers array. */
- supply_gregset (regcache, (const gdb_gregset_t *) &gregset);
- supply_fpregset (regcache, (const gdb_fpregset_t *) &fpregset);
+ supply_gregset (regcache, (const gdb_gregset_t *) (void *) &gregset);
+ supply_fpregset (regcache, (const gdb_fpregset_t *) (void *) &fpregset);
#if 0
/* FIXME: libthread_db doesn't seem to handle this right. */
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: Avoid gcc warning on sparc solaris 9
2007-10-23 16:46 Avoid gcc warning on sparc solaris 9 Pedro Alves
@ 2007-10-23 17:56 ` Ulrich Weigand
2007-10-24 13:28 ` Pedro Alves
0 siblings, 1 reply; 7+ messages in thread
From: Ulrich Weigand @ 2007-10-23 17:56 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
Pedro Alves wrote:
> Building HEAD on a native gdb on sparc solaris 9 with gcc 3.4.6 stops due to:
>
> ../../src/gdb/sol-thread.c: In function `sol_thread_fetch_registers':
> ../../src/gdb/sol-thread.c:533: warning: dereferencing type-punned
> pointer will break strict-aliasing rules
We've seen this on other platforms with gcc 3.4 as well. I think
the best fix would be replace the problematic construct
supply_gregset (regcache, (const gdb_gregset_t *) &gregset);
with
gdb_gregset_t *gregset_p = &gregset;
supply_gregset (regcache, (const gdb_gregset_t *) gregset_p);
That seemed to fix the problems e.g. in i386-linux-nat.c (fetch_regs).
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Avoid gcc warning on sparc solaris 9
2007-10-23 17:56 ` Ulrich Weigand
@ 2007-10-24 13:28 ` Pedro Alves
2007-10-24 13:45 ` Ulrich Weigand
0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2007-10-24 13:28 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 871 bytes --]
Ulrich Weigand wrote:
> Pedro Alves wrote:
>
> > Building HEAD on a native gdb on sparc solaris 9 with gcc 3.4.6 stops due to:
> >
> > ../../src/gdb/sol-thread.c: In function `sol_thread_fetch_registers':
> > ../../src/gdb/sol-thread.c:533: warning: dereferencing type-punned
> > pointer will break strict-aliasing rules
>
> We've seen this on other platforms with gcc 3.4 as well. I think
> the best fix would be replace the problematic construct
> supply_gregset (regcache, (const gdb_gregset_t *) &gregset);
> with
>
> gdb_gregset_t *gregset_p = &gregset;
>
> supply_gregset (regcache, (const gdb_gregset_t *) gregset_p);
>
> That seemed to fix the problems e.g. in i386-linux-nat.c (fetch_regs).
>
Indeed it does fix it here too. Much nicer. Thanks for the pointer.
Testsuite shows the same results as the previous version.
OK now?
--
Cheers,
Pedro Alves
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: solaris.diff --]
[-- Type: text/x-patch; name=solaris.diff, Size: 1244 bytes --]
2007-10-24 Pedro Alves <pedro_alves@portugalmail.pt>
* sol-thread.c (sol_thread_fetch_registers): Work around gcc 3.4
alias warning bug.
---
gdb/sol-thread.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
Index: src/gdb/sol-thread.c
===================================================================
--- src.orig/gdb/sol-thread.c 2007-10-23 17:07:07.604730000 +0100
+++ src/gdb/sol-thread.c 2007-10-24 13:35:37.380474000 +0100
@@ -484,6 +484,9 @@ sol_thread_fetch_registers (struct regca
td_err_e val;
prgregset_t gregset;
prfpregset_t fpregset;
+ gdb_gregset_t *gregset_p = &gregset;
+ gdb_fpregset_t *fpregset_p = &fpregset;
+
#if 0
int xregsize;
caddr_t xregset;
@@ -530,8 +533,8 @@ sol_thread_fetch_registers (struct regca
calling the td routines because the td routines call ps_lget*
which affect the values stored in the registers array. */
- supply_gregset (regcache, (const gdb_gregset_t *) &gregset);
- supply_fpregset (regcache, (const gdb_fpregset_t *) &fpregset);
+ supply_gregset (regcache, (const gdb_gregset_t *) gregset_p);
+ supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset_p);
#if 0
/* FIXME: libthread_db doesn't seem to handle this right. */
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: Avoid gcc warning on sparc solaris 9
2007-10-24 13:28 ` Pedro Alves
@ 2007-10-24 13:45 ` Ulrich Weigand
2007-10-24 13:48 ` Daniel Jacobowitz
0 siblings, 1 reply; 7+ messages in thread
From: Ulrich Weigand @ 2007-10-24 13:45 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
Pedro Alves wrote:
>2007-10-24 Pedro Alves <pedro_alves@portugalmail.pt>
>
> * sol-thread.c (sol_thread_fetch_registers): Work around gcc 3.4
> alias warning bug.
This is OK, thanks.
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Avoid gcc warning on sparc solaris 9
2007-10-24 13:45 ` Ulrich Weigand
@ 2007-10-24 13:48 ` Daniel Jacobowitz
2007-10-24 13:58 ` Pedro Alves
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Jacobowitz @ 2007-10-24 13:48 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: Pedro Alves, gdb-patches
On Wed, Oct 24, 2007 at 03:39:38PM +0200, Ulrich Weigand wrote:
> Pedro Alves wrote:
>
> >2007-10-24 Pedro Alves <pedro_alves@portugalmail.pt>
> >
> > * sol-thread.c (sol_thread_fetch_registers): Work around gcc 3.4
> > alias warning bug.
>
> This is OK, thanks.
This is also PR gdb/2341. Pedro, could you add that to the
changelog, and also commit to the 6.7 branch? Or ask me if you don't
have it checked out and I can handle it.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Avoid gcc warning on sparc solaris 9
2007-10-24 13:48 ` Daniel Jacobowitz
@ 2007-10-24 13:58 ` Pedro Alves
2007-10-24 14:56 ` Daniel Jacobowitz
0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2007-10-24 13:58 UTC (permalink / raw)
To: Ulrich Weigand, Pedro Alves, gdb-patches
Daniel Jacobowitz wrote:
> On Wed, Oct 24, 2007 at 03:39:38PM +0200, Ulrich Weigand wrote:
> > Pedro Alves wrote:
> >
> > >2007-10-24 Pedro Alves <pedro_alves@portugalmail.pt>
> > >
> > > * sol-thread.c (sol_thread_fetch_registers): Work around gcc 3.4
> > > alias warning bug.
> >
> > This is OK, thanks.
>
> This is also PR gdb/2341. Pedro, could you add that to the
> changelog, and also commit to the 6.7 branch? Or ask me if you don't
> have it checked out and I can handle it.
>
Could you please? I don't have access to cvs from here.
Thanks!
Cheers,
Pedro Alves
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-10-24 13:58 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-23 16:46 Avoid gcc warning on sparc solaris 9 Pedro Alves
2007-10-23 17:56 ` Ulrich Weigand
2007-10-24 13:28 ` Pedro Alves
2007-10-24 13:45 ` Ulrich Weigand
2007-10-24 13:48 ` Daniel Jacobowitz
2007-10-24 13:58 ` Pedro Alves
2007-10-24 14:56 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox