Move some ppc macros to nat/ppc-linux.h
[deliverable/binutils-gdb.git] / gdb / gdbserver / linux-mips-low.c
index 112448c44eb9777e309e06bf4fa2a57b846e1421..478bb6ed9aa22538e45689ccb7ea151173848329 100644 (file)
@@ -1,5 +1,5 @@
 /* GNU/Linux/MIPS specific low level interface, for the remote server for GDB.
-   Copyright (C) 1995-2014 Free Software Foundation, Inc.
+   Copyright (C) 1995-2015 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -22,7 +22,7 @@
 #include <sys/ptrace.h>
 #include <endian.h>
 
-#include "mips-linux-watch.h"
+#include "nat/mips-linux-watch.h"
 #include "gdb_proc_service.h"
 
 /* Defined in auto-generated file mips-linux.c.  */
@@ -126,8 +126,9 @@ mips_read_description (void)
 {
   if (have_dsp < 0)
     {
-      int pid = lwpid_of (current_inferior);
+      int pid = lwpid_of (current_thread);
 
+      errno = 0;
       ptrace (PTRACE_PEEKUSER, pid, DSP_CONTROL, 0);
       switch (errno)
        {
@@ -271,7 +272,7 @@ static const unsigned int mips_breakpoint = 0x0005000d;
 static CORE_ADDR
 mips_reinsert_addr (void)
 {
-  struct regcache *regcache = get_thread_regcache (current_inferior, 1);
+  struct regcache *regcache = get_thread_regcache (current_thread, 1);
   union mips_register ra;
   collect_register_by_name (regcache, "r31", ra.buf);
   return register_size (regcache->tdesc, 0) == 4 ? ra.reg32 : ra.reg64;
@@ -372,11 +373,26 @@ mips_linux_prepare_to_resume (struct lwp_info *lwp)
     }
 }
 
+static int
+mips_supports_z_point_type (char z_type)
+{
+  switch (z_type)
+    {
+    case Z_PACKET_WRITE_WP:
+    case Z_PACKET_READ_WP:
+    case Z_PACKET_ACCESS_WP:
+      return 1;
+    default:
+      return 0;
+    }
+}
+
 /* This is the implementation of linux_target_ops method
    insert_point.  */
 
 static int
-mips_insert_point (char type, CORE_ADDR addr, int len)
+mips_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
+                  int len, struct raw_breakpoint *bp)
 {
   struct process_info *proc = current_process ();
   struct arch_process_info *private = proc->private->arch_private;
@@ -388,20 +404,7 @@ mips_insert_point (char type, CORE_ADDR addr, int len)
   enum target_hw_bp_type watch_type;
   uint32_t irw;
 
-  /* Breakpoint/watchpoint types:
-       '0' - software-breakpoint (not supported)
-       '1' - hardware-breakpoint (not supported)
-       '2' - write watchpoint (supported)
-       '3' - read watchpoint (supported)
-       '4' - access watchpoint (supported).  */
-
-  if (type < '2' || type > '4')
-    {
-      /* Unsupported.  */
-      return 1;
-    }
-
-  lwpid = lwpid_of (current_inferior);
+  lwpid = lwpid_of (current_thread);
   if (!mips_linux_read_watch_registers (lwpid,
                                        &private->watch_readback,
                                        &private->watch_readback_valid,
@@ -416,7 +419,7 @@ mips_insert_point (char type, CORE_ADDR addr, int len)
   mips_linux_watch_populate_regs (private->current_watches, &regs);
 
   /* Now try to add the new watch.  */
-  watch_type = Z_packet_to_target_hw_bp_type (type);
+  watch_type = raw_bkpt_type_to_target_hw_bp_type (type);
   irw = mips_linux_watch_type_to_irw (watch_type);
   if (!mips_linux_watch_try_one_watch (&regs, addr, len, irw))
     return -1;
@@ -446,7 +449,8 @@ mips_insert_point (char type, CORE_ADDR addr, int len)
    remove_point.  */
 
 static int
-mips_remove_point (char type, CORE_ADDR addr, int len)
+mips_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
+                  int len, struct raw_breakpoint *bp)
 {
   struct process_info *proc = current_process ();
   struct arch_process_info *private = proc->private->arch_private;
@@ -458,21 +462,8 @@ mips_remove_point (char type, CORE_ADDR addr, int len)
   struct mips_watchpoint **pw;
   struct mips_watchpoint *w;
 
-  /* Breakpoint/watchpoint types:
-       '0' - software-breakpoint (not supported)
-       '1' - hardware-breakpoint (not supported)
-       '2' - write watchpoint (supported)
-       '3' - read watchpoint (supported)
-       '4' - access watchpoint (supported).  */
-
-  if (type < '2' || type > '4')
-    {
-      /* Unsupported.  */
-      return 1;
-    }
-
   /* Search for a known watch that matches.  Then unlink and free it.  */
-  watch_type = Z_packet_to_target_hw_bp_type (type);
+  watch_type = raw_bkpt_type_to_target_hw_bp_type (type);
   deleted_one = 0;
   pw = &private->current_watches;
   while ((w = *pw))
@@ -515,7 +506,7 @@ mips_stopped_by_watchpoint (void)
   struct arch_process_info *private = proc->private->arch_private;
   int n;
   int num_valid;
-  long lwpid = lwpid_of (current_inferior);
+  long lwpid = lwpid_of (current_thread);
 
   if (!mips_linux_read_watch_registers (lwpid,
                                        &private->watch_readback,
@@ -543,7 +534,7 @@ mips_stopped_data_address (void)
   struct arch_process_info *private = proc->private->arch_private;
   int n;
   int num_valid;
-  long lwpid = lwpid_of (current_inferior);
+  long lwpid = lwpid_of (current_thread);
 
   /* On MIPS we don't know the low order 3 bits of the data address.
      GDB does not support remote targets that can't report the
@@ -844,6 +835,7 @@ struct linux_target_ops the_low_target = {
   mips_reinsert_addr,
   0,
   mips_breakpoint_at,
+  mips_supports_z_point_type,
   mips_insert_point,
   mips_remove_point,
   mips_stopped_by_watchpoint,
This page took 0.025716 seconds and 4 git commands to generate.