gdb/
[deliverable/binutils-gdb.git] / gdb / i386-darwin-nat.c
index 328372357a926e9b9659255fb34f825e823b76a0..23f6a6dfe2172544c285ab4050809bb6251cdd6b 100644 (file)
@@ -1,5 +1,5 @@
 /* Darwin support for GDB, the GNU debugger.
-   Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2008, 2009
+   Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
    Contributed by Apple Computer, Inc.
@@ -40,6 +40,7 @@
 
 #ifdef BFD64
 #include "amd64-nat.h"
+#include "amd64-tdep.h"
 #include "amd64-darwin-tdep.h"
 #endif
 
@@ -68,7 +69,9 @@ i386_darwin_fetch_inferior_registers (struct target_ops *ops,
              &gp_count);
          if (ret != KERN_SUCCESS)
            {
-             printf_unfiltered (_("Error calling thread_get_state for GP registers for thread 0x%ulx"), current_thread);
+             printf_unfiltered (_("Error calling thread_get_state for "
+                                  "GP registers for thread 0x%ulx"),
+                                current_thread);
              MACH_CHECK_ERROR (ret);
            }
          amd64_supply_native_gregset (regcache, &gp_regs.uts, -1);
@@ -86,10 +89,12 @@ i386_darwin_fetch_inferior_registers (struct target_ops *ops,
              &fp_count);
          if (ret != KERN_SUCCESS)
            {
-             printf_unfiltered (_("Error calling thread_get_state for float registers for thread 0x%ulx"), current_thread);
+             printf_unfiltered (_("Error calling thread_get_state for "
+                                  "float registers for thread 0x%ulx"),
+                                current_thread);
              MACH_CHECK_ERROR (ret);
            }
-          i387_supply_fxsave (regcache, -1, &fp_regs.ufs.fs64);
+          amd64_supply_fxsave (regcache, -1, &fp_regs.ufs.fs64.__fpu_fcw);
           fetched++;
         }
     }
@@ -108,7 +113,9 @@ i386_darwin_fetch_inferior_registers (struct target_ops *ops,
              &gp_count);
          if (ret != KERN_SUCCESS)
            {
-             printf_unfiltered (_("Error calling thread_get_state for GP registers for thread 0x%ulx"), current_thread);
+             printf_unfiltered (_("Error calling thread_get_state for "
+                                  "GP registers for thread 0x%ulx"),
+                                current_thread);
              MACH_CHECK_ERROR (ret);
            }
          for (i = 0; i < I386_NUM_GREGS; i++)
@@ -131,7 +138,9 @@ i386_darwin_fetch_inferior_registers (struct target_ops *ops,
              &fp_count);
          if (ret != KERN_SUCCESS)
            {
-             printf_unfiltered (_("Error calling thread_get_state for float registers for thread 0x%ulx"), current_thread);
+             printf_unfiltered (_("Error calling thread_get_state for "
+                                  "float registers for thread 0x%ulx"),
+                                current_thread);
              MACH_CHECK_ERROR (ret);
            }
           i387_supply_fxsave (regcache, -1, &fp_regs.__fpu_fcw);
@@ -194,7 +203,7 @@ i386_darwin_store_inferior_registers (struct target_ops *ops,
           gdb_assert (fp_regs.fsh.flavor == x86_FLOAT_STATE64);
           gdb_assert (fp_regs.fsh.count == x86_FLOAT_STATE64_COUNT);
 
-         i387_collect_fxsave (regcache, regno, &fp_regs.ufs.fs64.__fpu_fcw);
+         amd64_collect_fxsave (regcache, regno, &fp_regs.ufs.fs64.__fpu_fcw);
 
          ret = thread_set_state (current_thread, x86_FLOAT_STATE,
                                  (thread_state_t) & fp_regs,
@@ -254,23 +263,6 @@ i386_darwin_store_inferior_registers (struct target_ops *ops,
 
 /* Support for debug registers, boosted mostly from i386-linux-nat.c.  */
 
-#ifndef DR_FIRSTADDR
-#define DR_FIRSTADDR 0
-#endif
-
-#ifndef DR_LASTADDR
-#define DR_LASTADDR 3
-#endif
-
-#ifndef DR_STATUS
-#define DR_STATUS 6
-#endif
-
-#ifndef DR_CONTROL
-#define DR_CONTROL 7
-#endif
-
-
 static void
 i386_darwin_dr_set (int regnum, uint32_t value)
 {
@@ -292,7 +284,9 @@ i386_darwin_dr_set (int regnum, uint32_t value)
 
   if (ret != KERN_SUCCESS)
     {
-      printf_unfiltered (_("Error reading debug registers thread 0x%x via thread_get_state\n"), (int) current_thread);
+      printf_unfiltered (_("Error reading debug registers "
+                          "thread 0x%x via thread_get_state\n"),
+                        (int) current_thread);
       MACH_CHECK_ERROR (ret);
     }
 
@@ -329,7 +323,9 @@ i386_darwin_dr_set (int regnum, uint32_t value)
 
   if (ret != KERN_SUCCESS)
     {
-      printf_unfiltered (_("Error writing debug registers thread 0x%x via thread_get_state\n"), (int) current_thread);
+      printf_unfiltered (_("Error writing debug registers "
+                          "thread 0x%x via thread_get_state\n"),
+                        (int) current_thread);
       MACH_CHECK_ERROR (ret);
     }
 }
@@ -354,7 +350,9 @@ i386_darwin_dr_get (int regnum)
 
   if (ret != KERN_SUCCESS)
     {
-      printf_unfiltered (_("Error reading debug registers thread 0x%x via thread_get_state\n"), (int) current_thread);
+      printf_unfiltered (_("Error reading debug registers "
+                          "thread 0x%x via thread_get_state\n"),
+                        (int) current_thread);
       MACH_CHECK_ERROR (ret);
     }
 
@@ -395,12 +393,10 @@ i386_darwin_dr_set_addr (int regnum, CORE_ADDR addr)
   i386_darwin_dr_set (DR_FIRSTADDR + regnum, addr);
 }
 
-void
-i386_darwin_dr_reset_addr (int regnum)
+CORE_ADDR
+i386_darwin_dr_get_addr (int regnum)
 {
-  gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR);
-
-  i386_darwin_dr_set (DR_FIRSTADDR + regnum, 0L);
+  return i386_darwin_dr_get (regnum);
 }
 
 unsigned long
@@ -409,6 +405,12 @@ i386_darwin_dr_get_status (void)
   return i386_darwin_dr_get (DR_STATUS);
 }
 
+unsigned long
+i386_darwin_dr_get_control (void)
+{
+  return i386_darwin_dr_get (DR_CONTROL);
+}
+
 void
 darwin_check_osabi (darwin_inferior *inf, thread_t thread)
 {
@@ -541,7 +543,8 @@ darwin_set_sstep (thread_t thread, int enable)
          return;
        if ((regs.uts.ts32.__eflags & X86_EFLAGS_T) == bit)
          return;
-       regs.uts.ts32.__eflags = (regs.uts.ts32.__eflags & ~X86_EFLAGS_T) | bit;
+       regs.uts.ts32.__eflags
+         = (regs.uts.ts32.__eflags & ~X86_EFLAGS_T) | bit;
        kret = thread_set_state (thread, x86_THREAD_STATE, 
                                 (thread_state_t) &regs, count);
        MACH_CHECK_ERROR (kret);
@@ -556,7 +559,8 @@ darwin_set_sstep (thread_t thread, int enable)
          return;
        if ((regs.uts.ts64.__rflags & X86_EFLAGS_T) == bit)
          return;
-       regs.uts.ts64.__rflags = (regs.uts.ts64.__rflags & ~X86_EFLAGS_T) | bit;
+       regs.uts.ts64.__rflags
+         = (regs.uts.ts64.__rflags & ~X86_EFLAGS_T) | bit;
        kret = thread_set_state (thread, x86_THREAD_STATE, 
                                 (thread_state_t) &regs, count);
        MACH_CHECK_ERROR (kret);
@@ -564,7 +568,7 @@ darwin_set_sstep (thread_t thread, int enable)
       break;
 #endif
     default:
-      error (_("darwin_set_sstep: unknown flavour: %d\n"), regs.tsh.flavor);
+      error (_("darwin_set_sstep: unknown flavour: %d"), regs.tsh.flavor);
     }
 }
 
This page took 0.027001 seconds and 4 git commands to generate.