* [PATCH] Fix strict-aliasing violation
@ 2012-03-27 8:17 Andreas Schwab
0 siblings, 0 replies; only message in thread
From: Andreas Schwab @ 2012-03-27 8:17 UTC (permalink / raw)
To: gdb-patches
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."
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-03-27 8:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-27 8:17 [PATCH] Fix strict-aliasing violation Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox