asintl.h/bucomm.h/ld.h: Prevent the inclusion of <libintl.h> from the Solaris
[binutils-gdb.git] / gdb / arm-linux-nat.c
index b5311f4c2c061484d5321a381fcb420e1cbf8876..84aaaf6b4e897fea8bc6dc539afa73df9357a6b7 100644 (file)
@@ -1,5 +1,6 @@
 /* GNU/Linux on ARM native support.
-   Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2004, 2005
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -23,6 +24,8 @@
 #include "gdbcore.h"
 #include "gdb_string.h"
 #include "regcache.h"
+#include "target.h"
+#include "linux-nat.h"
 
 #include "arm-tdep.h"
 
@@ -492,6 +495,12 @@ store_register (int regno)
 
   if (regno >= ARM_A1_REGNUM && regno <= ARM_PC_REGNUM)
     regcache_raw_collect (current_regcache, regno, (char *) &regs[regno]);
+  else if (arm_apcs_32 && regno == ARM_PS_REGNUM)
+    regcache_raw_collect (current_regcache, regno,
+                        (char *) &regs[ARM_CPSR_REGNUM]);
+  else if (!arm_apcs_32 && regno == ARM_PS_REGNUM)
+    regcache_raw_collect (current_regcache, ARM_PC_REGNUM,
+                        (char *) &regs[ARM_PC_REGNUM]);
 
   ret = ptrace (PTRACE_SETREGS, tid, 0, &regs);
   if (ret < 0)
@@ -524,6 +533,10 @@ store_regs (void)
        regcache_raw_collect (current_regcache, regno, (char *) &regs[regno]);
     }
 
+  if (arm_apcs_32 && register_cached (ARM_PS_REGNUM))
+    regcache_raw_collect (current_regcache, ARM_PS_REGNUM,
+                        (char *) &regs[ARM_CPSR_REGNUM]);
+
   ret = ptrace (PTRACE_SETREGS, tid, 0, &regs);
 
   if (ret < 0)
@@ -537,8 +550,8 @@ store_regs (void)
    regno == -1, otherwise fetch all general registers or all floating
    point registers depending upon the value of regno.  */
 
-void
-fetch_inferior_registers (int regno)
+static void
+arm_linux_fetch_inferior_registers (int regno)
 {
   if (-1 == regno)
     {
@@ -559,8 +572,8 @@ fetch_inferior_registers (int regno)
    regno == -1, otherwise store all general registers or all floating
    point registers depending upon the value of regno.  */
 
-void
-store_inferior_registers (int regno)
+static void
+arm_linux_store_inferior_registers (int regno)
 {
   if (-1 == regno)
     {
@@ -706,8 +719,22 @@ get_linux_version (unsigned int *vmajor,
   return ((*vmajor << 16) | (*vminor << 8) | *vrelease);
 }
 
+void _initialize_arm_linux_nat (void);
+
 void
 _initialize_arm_linux_nat (void)
 {
+  struct target_ops *t;
+
   os_version = get_linux_version (&os_major, &os_minor, &os_release);
+
+  /* Fill in the generic GNU/Linux methods.  */
+  t = linux_target ();
+
+  /* Add our register access methods.  */
+  t->to_fetch_registers = arm_linux_fetch_inferior_registers;
+  t->to_store_registers = arm_linux_store_inferior_registers;
+
+  /* Register the target.  */
+  add_target (t);
 }