PR ld/16021
[deliverable/binutils-gdb.git] / gdb / m68klinux-nat.c
index d4410e68034d398862836113b6d499e038669727..5e928e6ca9e532a9db1ff6728cd185264751f2c2 100644 (file)
@@ -1,6 +1,6 @@
 /* Motorola m68k native support for GNU/Linux.
 
-   Copyright (C) 1996, 1998, 2000-2012 Free Software Foundation, Inc.
+   Copyright (C) 1996-2013 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -29,7 +29,6 @@
 
 #include "m68k-tdep.h"
 
-#include <sys/param.h>
 #include <sys/dir.h>
 #include <signal.h>
 #include <sys/ptrace.h>
@@ -107,22 +106,23 @@ 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];
+  gdb_byte buf[MAX_REGISTER_SIZE];
   int tid;
 
   /* Overload thread id onto process id.  */
-  tid = TIDGET (inferior_ptid);
+  tid = ptid_get_lwp (inferior_ptid);
   if (tid == 0)
-    tid = PIDGET (inferior_ptid);      /* no thread id, just use
+    tid = ptid_get_pid (inferior_ptid);        /* no thread id, just use
                                           process id.  */
 
   regaddr = 4 * regmap[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,15 +160,15 @@ 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];
+  gdb_byte buf[MAX_REGISTER_SIZE];
 
   /* Overload thread id onto process id.  */
-  tid = TIDGET (inferior_ptid);
+  tid = ptid_get_lwp (inferior_ptid);
   if (tid == 0)
-    tid = PIDGET (inferior_ptid);      /* no thread id, just use
+    tid = ptid_get_pid (inferior_ptid);        /* no thread id, just use
                                           process id.  */
 
   regaddr = 4 * regmap[regno];
@@ -180,7 +180,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."),
@@ -419,9 +420,9 @@ m68k_linux_fetch_inferior_registers (struct target_ops *ops,
     }
 
   /* GNU/Linux LWP ID's are process ID's.  */
-  tid = TIDGET (inferior_ptid);
+  tid = ptid_get_lwp (inferior_ptid);
   if (tid == 0)
-    tid = PIDGET (inferior_ptid);      /* Not a threaded program.  */
+    tid = ptid_get_pid (inferior_ptid);        /* Not a threaded program.  */
 
   /* Use the PTRACE_GETFPXREGS request whenever possible, since it
      transfers more registers in one system call, and we'll cache the
@@ -476,9 +477,9 @@ m68k_linux_store_inferior_registers (struct target_ops *ops,
     }
 
   /* GNU/Linux LWP ID's are process ID's.  */
-  tid = TIDGET (inferior_ptid);
+  tid = ptid_get_lwp (inferior_ptid);
   if (tid == 0)
-    tid = PIDGET (inferior_ptid);      /* Not a threaded program.  */
+    tid = ptid_get_pid (inferior_ptid);        /* Not a threaded program.  */
 
   /* Use the PTRACE_SETFPREGS requests whenever possible, since it
      transfers more registers in one system call.  But remember that
This page took 0.025645 seconds and 4 git commands to generate.