Address review comments for the previous series
[deliverable/binutils-gdb.git] / gdb / rs6000-nat.c
index 68fb5c9cb0252e48977a6c61ba66ece6becf8c80..d985fce644dc63ed47f1ce75c2bd2dcf5d716f68 100644 (file)
@@ -1,6 +1,6 @@
 /* IBM RS/6000 native-dependent code for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2014 Free Software Foundation, Inc.
+   Copyright (C) 1986-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -23,9 +23,7 @@
 #include "gdbcore.h"
 #include "symfile.h"
 #include "objfiles.h"
-#include "libbfd.h"            /* For bfd_default_set_arch_mach (FIXME) */
 #include "bfd.h"
-#include "exceptions.h"
 #include "gdb-stabs.h"
 #include "regcache.h"
 #include "arch-utils.h"
@@ -144,9 +142,9 @@ rs6000_ptrace64 (int req, int id, long long addr, int data, void *buf)
 {
 #ifdef ARCH3264
 #  ifdef HAVE_PTRACE64
-  int ret = ptrace64 (req, id, addr, data, buf);
+  int ret = ptrace64 (req, id, addr, data, (PTRACE_TYPE_ARG5) buf);
 #  else
-  int ret = ptracex (req, id, addr, data, buf);
+  int ret = ptracex (req, id, addr, data, (PTRACE_TYPE_ARG5) buf);
 #  endif
 #else
   int ret = 0;
@@ -163,9 +161,10 @@ rs6000_ptrace64 (int req, int id, long long addr, int data, void *buf)
 static void
 fetch_register (struct regcache *regcache, int regno)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  int addr[MAX_REGISTER_SIZE];
+  struct gdbarch *gdbarch = regcache->arch ();
+  int addr[PPC_MAX_REGISTER_SIZE];
   int nr, isfloat;
+  pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
 
   /* Retrieved values may be -1, so infer errors from errno.  */
   errno = 0;
@@ -174,7 +173,7 @@ fetch_register (struct regcache *regcache, int regno)
 
   /* Floating-point registers.  */
   if (isfloat)
-    rs6000_ptrace32 (PT_READ_FPR, ptid_get_pid (inferior_ptid), addr, nr, 0);
+    rs6000_ptrace32 (PT_READ_FPR, pid, addr, nr, 0);
 
   /* Bogus register number.  */
   else if (nr < 0)
@@ -190,15 +189,13 @@ fetch_register (struct regcache *regcache, int regno)
   else
     {
       if (!ARCH64 ())
-       *addr = rs6000_ptrace32 (PT_READ_GPR, ptid_get_pid (inferior_ptid),
-                                (int *) nr, 0, 0);
+       *addr = rs6000_ptrace32 (PT_READ_GPR, pid, (int *) nr, 0, 0);
       else
        {
          /* PT_READ_GPR requires the buffer parameter to point to long long,
             even if the register is really only 32 bits.  */
          long long buf;
-         rs6000_ptrace64 (PT_READ_GPR, ptid_get_pid (inferior_ptid),
-                          nr, 0, &buf);
+         rs6000_ptrace64 (PT_READ_GPR, pid, nr, 0, &buf);
          if (register_size (gdbarch, regno) == 8)
            memcpy (addr, &buf, 8);
          else
@@ -223,9 +220,10 @@ fetch_register (struct regcache *regcache, int regno)
 static void
 store_register (struct regcache *regcache, int regno)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  int addr[MAX_REGISTER_SIZE];
+  struct gdbarch *gdbarch = regcache->arch ();
+  int addr[PPC_MAX_REGISTER_SIZE];
   int nr, isfloat;
+  pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
 
   /* Fetch the register's value from the register cache.  */
   regcache_raw_collect (regcache, regno, addr);
@@ -237,7 +235,7 @@ store_register (struct regcache *regcache, int regno)
 
   /* Floating-point registers.  */
   if (isfloat)
-    rs6000_ptrace32 (PT_WRITE_FPR, ptid_get_pid (inferior_ptid), addr, nr, 0);
+    rs6000_ptrace32 (PT_WRITE_FPR, pid, addr, nr, 0);
 
   /* Bogus register number.  */
   else if (nr < 0)
@@ -255,8 +253,7 @@ store_register (struct regcache *regcache, int regno)
          the register's value is passed by value, but for 64-bit inferiors,
         the address of a buffer containing the value is passed.  */
       if (!ARCH64 ())
-       rs6000_ptrace32 (PT_WRITE_GPR, ptid_get_pid (inferior_ptid),
-                        (int *) nr, *addr, 0);
+       rs6000_ptrace32 (PT_WRITE_GPR, pid, (int *) nr, *addr, 0);
       else
        {
          /* PT_WRITE_GPR requires the buffer parameter to point to an 8-byte
@@ -266,8 +263,7 @@ store_register (struct regcache *regcache, int regno)
            memcpy (&buf, addr, 8);
          else
            buf = *addr;
-         rs6000_ptrace64 (PT_WRITE_GPR, ptid_get_pid (inferior_ptid),
-                          nr, 0, &buf);
+         rs6000_ptrace64 (PT_WRITE_GPR, pid, nr, 0, &buf);
        }
     }
 
@@ -285,7 +281,7 @@ static void
 rs6000_fetch_inferior_registers (struct target_ops *ops,
                                 struct regcache *regcache, int regno)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   if (regno != -1)
     fetch_register (regcache, regno);
 
@@ -328,7 +324,7 @@ static void
 rs6000_store_inferior_registers (struct target_ops *ops,
                                 struct regcache *regcache, int regno)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   if (regno != -1)
     store_register (regcache, regno);
 
@@ -528,11 +524,13 @@ rs6000_wait (struct target_ops *ops,
 /* Set the current architecture from the host running GDB.  Called when
    starting a child process.  */
 
-static void (*super_create_inferior) (struct target_ops *,char *exec_file, 
-                                     char *allargs, char **env, int from_tty);
+static void (*super_create_inferior) (struct target_ops *,
+                                     const char *exec_file,
+                                     const std::string &allargs,
+                                     char **env, int from_tty);
 static void
-rs6000_create_inferior (struct target_ops * ops, char *exec_file,
-                       char *allargs, char **env, int from_tty)
+rs6000_create_inferior (struct target_ops * ops, const char *exec_file,
+                       const std::string &allargs, char **env, int from_tty)
 {
   enum bfd_architecture arch;
   unsigned long mach;
@@ -594,7 +592,7 @@ rs6000_ptrace_ldinfo (ptid_t ptid)
 {
   const int pid = ptid_get_pid (ptid);
   int ldi_size = 1024;
-  gdb_byte *ldi = xmalloc (ldi_size);
+  void *ldi = xmalloc (ldi_size);
   int rc = -1;
 
   while (1)
@@ -616,7 +614,7 @@ rs6000_ptrace_ldinfo (ptid_t ptid)
       ldi = xrealloc (ldi, ldi_size);
     }
 
-  return ldi;
+  return (gdb_byte *) ldi;
 }
 
 /* Implement the to_xfer_partial target_ops method for
@@ -657,8 +655,6 @@ rs6000_xfer_shared_libraries
     }
 }
 
-void _initialize_rs6000_nat (void);
-
 void
 _initialize_rs6000_nat (void)
 {
This page took 0.027596 seconds and 4 git commands to generate.