Imported Upstream version 7.9
[platform/upstream/gdb.git] / gdb / spu-multiarch.c
index bd6c836..459cb2f 100644 (file)
@@ -1,5 +1,5 @@
 /* Cell SPU GNU/Linux multi-architecture debugging support.
-   Copyright (C) 2009-2014 Free Software Foundation, Inc.
+   Copyright (C) 2009-2015 Free Software Foundation, Inc.
 
    Contributed by Ulrich Weigand <uweigand@de.ibm.com>.
 
@@ -21,8 +21,6 @@
 #include "defs.h"
 #include "gdbcore.h"
 #include "gdbcmd.h"
-#include <string.h>
-#include "gdb_assert.h"
 #include "arch-utils.h"
 #include "observer.h"
 #include "inferior.h"
@@ -121,19 +119,13 @@ static int
 spu_region_ok_for_hw_watchpoint (struct target_ops *self,
                                 CORE_ADDR addr, int len)
 {
-  struct target_ops *ops_beneath = find_target_beneath (&spu_ops);
-  while (ops_beneath && !ops_beneath->to_region_ok_for_hw_watchpoint)
-    ops_beneath = find_target_beneath (ops_beneath);
+  struct target_ops *ops_beneath = find_target_beneath (self);
 
   /* We cannot watch SPU local store.  */
   if (SPUADDR_SPU (addr) != -1)
     return 0;
 
-  if (ops_beneath)
-    return ops_beneath->to_region_ok_for_hw_watchpoint (ops_beneath,
-                                                       addr, len);
-
-  return 0;
+  return ops_beneath->to_region_ok_for_hw_watchpoint (ops_beneath, addr, len);
 }
 
 /* Override the to_fetch_registers routine.  */
@@ -150,10 +142,6 @@ spu_fetch_registers (struct target_ops *ops,
   /* This version applies only if we're currently in spu_run.  */
   if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu)
     {
-      while (ops_beneath && !ops_beneath->to_fetch_registers)
-       ops_beneath = find_target_beneath (ops_beneath);
-
-      gdb_assert (ops_beneath);
       ops_beneath->to_fetch_registers (ops_beneath, regcache, regno);
       return;
     }
@@ -208,10 +196,6 @@ spu_store_registers (struct target_ops *ops,
   /* This version applies only if we're currently in spu_run.  */
   if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu)
     {
-      while (ops_beneath && !ops_beneath->to_fetch_registers)
-       ops_beneath = find_target_beneath (ops_beneath);
-
-      gdb_assert (ops_beneath);
       ops_beneath->to_store_registers (ops_beneath, regcache, regno);
       return;
     }
@@ -254,9 +238,6 @@ spu_xfer_partial (struct target_ops *ops, enum target_object object,
                  ULONGEST *xfered_len)
 {
   struct target_ops *ops_beneath = find_target_beneath (ops);
-  while (ops_beneath && !ops_beneath->to_xfer_partial)
-    ops_beneath = find_target_beneath (ops_beneath);
-  gdb_assert (ops_beneath);
 
   /* Use the "mem" spufs file to access SPU local store.  */
   if (object == TARGET_OBJECT_MEMORY)
@@ -308,12 +289,9 @@ spu_search_memory (struct target_ops* ops,
                   CORE_ADDR *found_addrp)
 {
   struct target_ops *ops_beneath = find_target_beneath (ops);
-  while (ops_beneath && !ops_beneath->to_search_memory)
-    ops_beneath = find_target_beneath (ops_beneath);
 
-  /* For SPU local store, always fall back to the simple method.  Likewise
-     if we do not have any target-specific special implementation.  */
-  if (!ops_beneath || SPUADDR_SPU (start_addr) >= 0)
+  /* For SPU local store, always fall back to the simple method.  */
+  if (SPUADDR_SPU (start_addr) >= 0)
     return simple_search_memory (ops,
                                 start_addr, search_space_len,
                                 pattern, pattern_len, found_addrp);
@@ -378,10 +356,7 @@ static void
 spu_mourn_inferior (struct target_ops *ops)
 {
   struct target_ops *ops_beneath = find_target_beneath (ops);
-  while (ops_beneath && !ops_beneath->to_mourn_inferior)
-    ops_beneath = find_target_beneath (ops_beneath);
 
-  gdb_assert (ops_beneath);
   ops_beneath->to_mourn_inferior (ops_beneath);
   spu_multiarch_deactivate ();
 }