merge from gcc
[deliverable/binutils-gdb.git] / gdb / rs6000-nat.c
index 8e24bed0b06dd5bf68f23bf7ff670905ec9eff20..07147a19347ba3dc58948ce705a38635787425ee 100644 (file)
@@ -1,8 +1,8 @@
 /* IBM RS/6000 native-dependent code for GDB, the GNU debugger.
 
-   Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
-   1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
-   Foundation, Inc.
+   Copyright (C) 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
+   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -18,8 +18,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 #include "defs.h"
 #include "inferior.h"
 #include "xcoffsolib.h"
 #include "symfile.h"
 #include "objfiles.h"
-#include "libbfd.h"            /* For bfd_cache_lookup (FIXME) */
+#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"
-#include "language.h"          /* for local_hex_string().  */
 #include "ppc-tdep.h"
 #include "exec.h"
 
@@ -73,7 +73,7 @@
 #ifndef ARCH3264
 # define ARCH64() 0
 #else
-# define ARCH64() (DEPRECATED_REGISTER_RAW_SIZE (0) == 8)
+# define ARCH64() (register_size (current_gdbarch, 0) == 8)
 #endif
 
 /* Union of 32-bit and 64-bit ".reg" core file sections. */
@@ -255,7 +255,7 @@ fetch_register (int regno)
             even if the register is really only 32 bits. */
          long long buf;
          rs6000_ptrace64 (PT_READ_GPR, PIDGET (inferior_ptid), nr, 0, (int *)&buf);
-         if (DEPRECATED_REGISTER_RAW_SIZE (regno) == 8)
+         if (register_size (current_gdbarch, regno) == 8)
            memcpy (addr, &buf, 8);
          else
            *addr = buf;
@@ -263,7 +263,7 @@ fetch_register (int regno)
     }
 
   if (!errno)
-    supply_register (regno, (char *) addr);
+    regcache_raw_supply (current_regcache, regno, (char *) addr);
   else
     {
 #if 0
@@ -283,7 +283,7 @@ store_register (int regno)
   int nr, isfloat;
 
   /* Fetch the register's value from the register cache.  */
-  regcache_collect (regno, addr);
+  regcache_raw_collect (current_regcache, regno, addr);
 
   /* -1 can be a successful return value, so infer errors from errno. */
   errno = 0;
@@ -324,7 +324,7 @@ store_register (int regno)
          /* PT_WRITE_GPR requires the buffer parameter to point to an 8-byte
             area, even if the register is really only 32 bits. */
          long long buf;
-         if (DEPRECATED_REGISTER_RAW_SIZE (regno) == 8)
+         if (register_size (current_gdbarch, regno) == 8)
            memcpy (&buf, addr, 8);
          else
            buf = *addr;
@@ -443,13 +443,13 @@ read_word (CORE_ADDR from, int *to, int arch64)
    to debugger memory starting at MYADDR.  Copy to inferior if
    WRITE is nonzero.
 
-   Returns the length copied, which is either the LEN argument or zero.
-   This xfer function does not do partial moves, since child_ops
-   doesn't allow memory operations to cross below us in the target stack
-   anyway.  */
+   Returns the length copied, which is either the LEN argument or
+   zero.  This xfer function does not do partial moves, since
+   deprecated_child_ops doesn't allow memory operations to cross below
+   us in the target stack anyway.  */
 
 int
-child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len,
+child_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
                   int write, struct mem_attrib *attrib,
                   struct target_ops *target)
 {
@@ -527,15 +527,15 @@ exec_one_dummy_insn (void)
 {
 #define        DUMMY_INSN_ADDR (TEXT_SEGMENT_BASE)+0x200
 
-  char shadow_contents[BREAKPOINT_MAX];                /* Stash old bkpt addr contents */
   int ret, status, pid;
   CORE_ADDR prev_pc;
+  void *bp;
 
   /* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We
      assume that this address will never be executed again by the real
      code. */
 
-  target_insert_breakpoint (DUMMY_INSN_ADDR, shadow_contents);
+  bp = deprecated_insert_raw_breakpoint (DUMMY_INSN_ADDR);
 
   /* You might think this could be done with a single ptrace call, and
      you'd be correct for just about every platform I've ever worked
@@ -559,7 +559,7 @@ exec_one_dummy_insn (void)
   while (pid != PIDGET (inferior_ptid));
 
   write_pc (prev_pc);
-  target_remove_breakpoint (DUMMY_INSN_ADDR, shadow_contents);
+  deprecated_remove_raw_breakpoint (bp);
 }
 
 /* Fetch registers from the register section in core bfd. */
@@ -586,45 +586,60 @@ fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
 
   if (ARCH64 ())
     {
-      for (regi = 0; regi < 32; regi++)
-        supply_register (tdep->ppc_gp0_regnum + regi,
-                         (char *) &regs->r64.gpr[regi]);
+      for (regi = 0; regi < ppc_num_gprs; regi++)
+        regcache_raw_supply (current_regcache, tdep->ppc_gp0_regnum + regi,
+                            (char *) &regs->r64.gpr[regi]);
 
       if (tdep->ppc_fp0_regnum >= 0)
-        for (regi = 0; regi < 32; regi++)
-          supply_register (tdep->ppc_fp0_regnum + regi,
-                           (char *) &regs->r64.fpr[regi]);
-
-      supply_register (PC_REGNUM, (char *) &regs->r64.iar);
-      supply_register (tdep->ppc_ps_regnum, (char *) &regs->r64.msr);
-      supply_register (tdep->ppc_cr_regnum, (char *) &regs->r64.cr);
-      supply_register (tdep->ppc_lr_regnum, (char *) &regs->r64.lr);
-      supply_register (tdep->ppc_ctr_regnum, (char *) &regs->r64.ctr);
-      supply_register (tdep->ppc_xer_regnum, (char *) &regs->r64.xer);
+        for (regi = 0; regi < ppc_num_fprs; regi++)
+          regcache_raw_supply (current_regcache, tdep->ppc_fp0_regnum + regi,
+                              (char *) &regs->r64.fpr[regi]);
+
+      regcache_raw_supply (current_regcache, PC_REGNUM,
+                          (char *) &regs->r64.iar);
+      regcache_raw_supply (current_regcache, tdep->ppc_ps_regnum,
+                          (char *) &regs->r64.msr);
+      regcache_raw_supply (current_regcache, tdep->ppc_cr_regnum,
+                          (char *) &regs->r64.cr);
+      regcache_raw_supply (current_regcache, tdep->ppc_lr_regnum,
+                          (char *) &regs->r64.lr);
+      regcache_raw_supply (current_regcache, tdep->ppc_ctr_regnum,
+                          (char *) &regs->r64.ctr);
+      regcache_raw_supply (current_regcache, tdep->ppc_xer_regnum,
+                          (char *) &regs->r64.xer);
       if (tdep->ppc_fpscr_regnum >= 0)
-        supply_register (tdep->ppc_fpscr_regnum, (char *) &regs->r64.fpscr);
+        regcache_raw_supply (current_regcache, tdep->ppc_fpscr_regnum,
+                            (char *) &regs->r64.fpscr);
     }
   else
     {
-      for (regi = 0; regi < 32; regi++)
-        supply_register (tdep->ppc_gp0_regnum + regi,
-                         (char *) &regs->r32.gpr[regi]);
+      for (regi = 0; regi < ppc_num_gprs; regi++)
+        regcache_raw_supply (current_regcache, tdep->ppc_gp0_regnum + regi,
+                            (char *) &regs->r32.gpr[regi]);
 
       if (tdep->ppc_fp0_regnum >= 0)
-        for (regi = 0; regi < 32; regi++)
-          supply_register (tdep->ppc_fp0_regnum + regi,
-                           (char *) &regs->r32.fpr[regi]);
-
-      supply_register (PC_REGNUM, (char *) &regs->r32.iar);
-      supply_register (tdep->ppc_ps_regnum, (char *) &regs->r32.msr);
-      supply_register (tdep->ppc_cr_regnum, (char *) &regs->r32.cr);
-      supply_register (tdep->ppc_lr_regnum, (char *) &regs->r32.lr);
-      supply_register (tdep->ppc_ctr_regnum, (char *) &regs->r32.ctr);
-      supply_register (tdep->ppc_xer_regnum, (char *) &regs->r32.xer);
+        for (regi = 0; regi < ppc_num_fprs; regi++)
+          regcache_raw_supply (current_regcache, tdep->ppc_fp0_regnum + regi,
+                              (char *) &regs->r32.fpr[regi]);
+
+      regcache_raw_supply (current_regcache, PC_REGNUM,
+                          (char *) &regs->r32.iar);
+      regcache_raw_supply (current_regcache, tdep->ppc_ps_regnum,
+                          (char *) &regs->r32.msr);
+      regcache_raw_supply (current_regcache, tdep->ppc_cr_regnum,
+                          (char *) &regs->r32.cr);
+      regcache_raw_supply (current_regcache, tdep->ppc_lr_regnum,
+                          (char *) &regs->r32.lr);
+      regcache_raw_supply (current_regcache, tdep->ppc_ctr_regnum,
+                          (char *) &regs->r32.ctr);
+      regcache_raw_supply (current_regcache, tdep->ppc_xer_regnum,
+                          (char *) &regs->r32.xer);
       if (tdep->ppc_fpscr_regnum >= 0)
-        supply_register (tdep->ppc_fpscr_regnum, (char *) &regs->r32.fpscr);
+        regcache_raw_supply (current_regcache, tdep->ppc_fpscr_regnum,
+                            (char *) &regs->r32.fpscr);
       if (tdep->ppc_mq_regnum >= 0)
-       supply_register (tdep->ppc_mq_regnum, (char *) &regs->r32.mq);
+       regcache_raw_supply (current_regcache, tdep->ppc_mq_regnum,
+                            (char *) &regs->r32.mq);
     }
 }
 \f
@@ -760,7 +775,7 @@ add_vmap (LdInfo *ldi)
     abfd = bfd_fdopenr (objname, gnutarget, fd);
   if (!abfd)
     {
-      warning ("Could not open `%s' as an executable file: %s",
+      warning (_("Could not open `%s' as an executable file: %s"),
               objname, bfd_errmsg (bfd_get_error ()));
       return NULL;
     }
@@ -780,14 +795,14 @@ add_vmap (LdInfo *ldi)
 
       if (!last)
        {
-         warning ("\"%s\": member \"%s\" missing.", objname, mem);
+         warning (_("\"%s\": member \"%s\" missing."), objname, mem);
          bfd_close (abfd);
          return NULL;
        }
 
       if (!bfd_check_format (last, bfd_object))
        {
-         warning ("\"%s\": member \"%s\" not in executable format: %s.",
+         warning (_("\"%s\": member \"%s\" not in executable format: %s."),
                   objname, mem, bfd_errmsg (bfd_get_error ()));
          bfd_close (last);
          bfd_close (abfd);
@@ -798,7 +813,7 @@ add_vmap (LdInfo *ldi)
     }
   else
     {
-      warning ("\"%s\": not in executable format: %s.",
+      warning (_("\"%s\": not in executable format: %s."),
               objname, bfd_errmsg (bfd_get_error ()));
       bfd_close (abfd);
       return NULL;
@@ -842,7 +857,7 @@ vmap_ldinfo (LdInfo *ldi)
          /* The kernel sets ld_info to -1, if the process is still using the
             object, and the object is removed. Keep the symbol info for the
             removed object and issue a warning.  */
-         warning ("%s (fd=%d) has disappeared, keeping its symbols",
+         warning (_("%s (fd=%d) has disappeared, keeping its symbols"),
                   name, fd);
          continue;
        }
@@ -871,7 +886,7 @@ vmap_ldinfo (LdInfo *ldi)
              || objfile->obfd == NULL
              || bfd_stat (objfile->obfd, &vi) < 0)
            {
-             warning ("Unable to stat %s, keeping its symbols", name);
+             warning (_("Unable to stat %s, keeping its symbols"), name);
              continue;
            }
 
@@ -895,7 +910,7 @@ vmap_ldinfo (LdInfo *ldi)
          vmap_symtab (vp);
 
          /* Announce new object files.  Doing this after symbol relocation
-            makes aix-thread.c's job easier. */
+            makes aix-thread.c's job easier.  */
          if (deprecated_target_new_objfile_hook && vp->objfile)
            deprecated_target_new_objfile_hook (vp->objfile);
 
@@ -919,11 +934,11 @@ vmap_ldinfo (LdInfo *ldi)
      running a different copy of the same executable.  */
   if (symfile_objfile != NULL && !got_exec_file)
     {
-      warning ("Symbol file %s\nis not mapped; discarding it.\n\
+      warning (_("Symbol file %s\nis not mapped; discarding it.\n\
 If in fact that file has symbols which the mapped files listed by\n\
 \"info files\" lack, you can load symbols with the \"symbol-file\" or\n\
 \"add-symbol-file\" commands (note that you must take care of relocating\n\
-symbols to the proper address).",
+symbols to the proper address)."),
               symfile_objfile->name);
       free_objfile (symfile_objfile);
       symfile_objfile = NULL;
@@ -953,7 +968,7 @@ vmap_exec (void)
   execbfd = exec_bfd;
 
   if (!vmap || !exec_ops.to_sections)
-    error ("vmap_exec: vmap or exec_ops.to_sections == 0\n");
+    error (_("vmap_exec: vmap or exec_ops.to_sections == 0."));
 
   for (i = 0; &exec_ops.to_sections[i] < exec_ops.to_sections_end; i++)
     {
@@ -1021,15 +1036,13 @@ set_host_arch (int pid)
   info.abfd = exec_bfd;
 
   if (!gdbarch_update_p (info))
-    {
-      internal_error (__FILE__, __LINE__,
-                     "set_host_arch: failed to select architecture");
-    }
+    internal_error (__FILE__, __LINE__,
+                   _("set_host_arch: failed to select architecture"));
 }
 
 \f
 /* xcoff_relocate_symtab -      hook for symbol table relocation.
-   also reads shared libraries.. */
+   also reads shared libraries.  */
 
 void
 xcoff_relocate_symtab (unsigned int pid)
@@ -1064,7 +1077,7 @@ xcoff_relocate_symtab (unsigned int pid)
           if (errno == ENOMEM)
             load_segs *= 2;
           else
-            perror_with_name ("ptrace ldinfo");
+            perror_with_name (_("ptrace ldinfo"));
         }
       else
        {
@@ -1214,7 +1227,7 @@ find_toc_address (CORE_ADDR pc)
                                              : vp->objfile);
        }
     }
-  error ("Unable to find TOC entry for pc %s\n", local_hex_string (pc));
+  error (_("Unable to find TOC entry for pc %s."), hex_string (pc));
 }
 \f
 /* Register that we are able to handle rs6000 core file formats. */
@@ -1231,12 +1244,12 @@ static struct core_fns rs6000_core_fns =
 void
 _initialize_core_rs6000 (void)
 {
-  /* Initialize hook in rs6000-tdep.c for determining the TOC address when
-     calling functions in the inferior.  */
+  /* Initialize hook in rs6000-tdep.c for determining the TOC address
+     when calling functions in the inferior.  */
   rs6000_find_toc_address_hook = find_toc_address;
 
-  /* Initialize hook in rs6000-tdep.c to set the current architecture when
-     starting a child process. */
+  /* Initialize hook in rs6000-tdep.c to set the current architecture
+     when starting a child process.  */
   rs6000_set_host_arch_hook = set_host_arch;
 
   deprecated_add_core_fns (&rs6000_core_fns);
This page took 0.028581 seconds and 4 git commands to generate.