diff options
author | Andreas Schwab <schwab@linux-m68k.org> | 2012-03-27 08:15:26 +0000 |
---|---|---|
committer | Andreas Schwab <schwab@linux-m68k.org> | 2012-03-27 08:15:26 +0000 |
commit | 89e028e2efcfd30d822e94bd8a2b20e6064bdbab (patch) | |
tree | 7ccd1bca27bdccffb98a5481df768a0f218393dd /gdb | |
parent | e6ab98cd1c6b6cc2af40e3cde1cebb08bae0df0f (diff) | |
download | gdb-89e028e2efcfd30d822e94bd8a2b20e6064bdbab.zip gdb-89e028e2efcfd30d822e94bd8a2b20e6064bdbab.tar.gz gdb-89e028e2efcfd30d822e94bd8a2b20e6064bdbab.tar.bz2 |
* m68klinux-nat.c (fetch_register): Fix strict-aliasing violation.
(store_register): Likewise.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/m68klinux-nat.c | 10 |
2 files changed, 11 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5304e17..e43963e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2012-03-27 Andreas Schwab <schwab@linux-m68k.org> + + * m68klinux-nat.c (fetch_register): Fix strict-aliasing violation. + (store_register): Likewise. + 2012-03-26 Oza Pawandeep <oza.pawandeep@gmail.com> * MAINTAINERS (Write After Approval): Add myself to the list. 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."), |