From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8974 invoked by alias); 27 Mar 2012 08:17:06 -0000 Received: (qmail 8956 invoked by uid 22791); 27 Mar 2012 08:17:00 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,TW_CP,TW_EG X-Spam-Check-By: sourceware.org Received: from mail-out.m-online.net (HELO mail-out.m-online.net) (212.18.0.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Mar 2012 08:16:47 +0000 Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3VH4nT5wzxz3hhfW for ; Tue, 27 Mar 2012 10:16:45 +0200 (CEST) Received: from igel.home (ppp-88-217-126-137.dynamic.mnet-online.de [88.217.126.137]) by mail.mnet-online.de (Postfix) with ESMTPA id 3VH4nT5Fvmz4KK35 for ; Tue, 27 Mar 2012 10:16:45 +0200 (CEST) Received: by igel.home (Postfix, from userid 501) id 0D761CA2A0; Tue, 27 Mar 2012 10:16:44 +0200 (CEST) From: Andreas Schwab To: gdb-patches@sourceware.org Subject: [PATCH] Fix strict-aliasing violation X-Yow: The SAME WAVE keeps coming in and COLLAPSING like a rayon MUU-MUU.. Date: Tue, 27 Mar 2012 08:17:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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: 2012-03/txt/msg00902.txt.bz2 Committed. Andreas. * m68klinux-nat.c (fetch_register): Fix strict-aliasing violation. (store_register): Likewise. diff --git a/gdb/m68klinux-nat.c b/gdb/m68klinux-nat.c index d4410e6..3be7c14 100644 --- a/gdb/m68klinux-nat.c +++ b/gdb/m68klinux-nat.c @@ -107,7 +107,7 @@ static void fetch_register (struct regcache *regcache, int regno) { struct gdbarch *gdbarch = get_regcache_arch (regcache); - long regaddr; + long regaddr, val; int i; char buf[MAX_REGISTER_SIZE]; int tid; @@ -122,7 +122,8 @@ fetch_register (struct regcache *regcache, int regno) for (i = 0; i < register_size (gdbarch, regno); i += sizeof (long)) { errno = 0; - *(long *) &buf[i] = ptrace (PTRACE_PEEKUSER, tid, regaddr, 0); + val = ptrace (PTRACE_PEEKUSER, tid, regaddr, 0); + memcpy (&buf[i], &val, sizeof (long)); regaddr += sizeof (long); if (errno != 0) error (_("Couldn't read register %s (#%d): %s."), @@ -160,7 +161,7 @@ static void store_register (const struct regcache *regcache, int regno) { struct gdbarch *gdbarch = get_regcache_arch (regcache); - long regaddr; + long regaddr, val; int i; int tid; char buf[MAX_REGISTER_SIZE]; @@ -180,7 +181,8 @@ store_register (const struct regcache *regcache, int regno) for (i = 0; i < register_size (gdbarch, regno); i += sizeof (long)) { errno = 0; - ptrace (PTRACE_POKEUSER, tid, regaddr, *(long *) &buf[i]); + memcpy (&val, &buf[i], sizeof (long)); + ptrace (PTRACE_POKEUSER, tid, regaddr, val); regaddr += sizeof (long); if (errno != 0) error (_("Couldn't write register %s (#%d): %s."), -- 1.7.9.4 -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."