* stabsread.c (get_substring): Declare second arg as int.
[deliverable/binutils-gdb.git] / gdb / remote-arc.c
index 98e7a57dbed2dca935aca46ec483af376545f56d..60ed914473046f0ba49019116e13eab843a26689 100644 (file)
@@ -15,10 +15,10 @@ GNU General Public License for more details.
 
 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
-#include <string.h>
+#include "gdb_string.h"
 #include <fcntl.h>
 #include "frame.h"
 #include "inferior.h"
@@ -101,7 +101,7 @@ interrupt_query PARAMS ((void));
 
 extern struct target_ops arc_ops;      /* Forward decl */
 
-static int aux_reg_map[3][30] = AUX_REG_MAP;
+static int aux_reg_map[3][31] = AUX_REG_MAP;
 
 /* This was 5 seconds, which is a long time to sit and wait.
    Unless this is going though some terminal server or multiplexer or
@@ -450,6 +450,8 @@ arc_wait (pid, status)
 {
   unsigned char buf[PBUFSIZ];
   int thread_num = -1;
+  unsigned char cmd;
+  int proc;
 
   status->kind = TARGET_WAITKIND_EXITED;
   status->value.integer = 0;
@@ -465,8 +467,33 @@ arc_wait (pid, status)
        break;
       status->kind = TARGET_WAITKIND_STOPPED;
     }
-  arc_xfer_reg (curr_processor, 1, 1, 0, &status_reg);
 
+  if ((curr_processor != HOST_PROCESSOR) && 
+      !(cntl_reg & cntl_reg_halt_bit[HOST_PROCESSOR]))
+    {
+      cmd = cntl_reg | cntl_reg_halt_bit[HOST_PROCESSOR];
+      arc_xfer_cntlreg (0, &cmd);
+      while (1)
+       {
+         unsigned char *p;
+         
+         ofunc = (void (*)()) signal (SIGINT, arc_interrupt);
+         arc_xfer_cntlreg (1, &cntl_reg);
+         signal (SIGINT, ofunc);
+         if (cntl_reg & cntl_reg_halt_bit[HOST_PROCESSOR])
+           break;
+       }
+    }
+
+  for (proc = AUDIO_PROCESSOR ; proc <= GRAPHIC_PROCESSOR; proc++)
+    {
+      if ((cntl_reg & cntl_reg_halt_bit[proc]))
+       continue;
+      cmd = cntl_reg | cntl_reg_halt_bit[proc];
+      arc_xfer_cntlreg (0, &cmd);
+    }
+
+  arc_xfer_reg (curr_processor, 1, 1, 0, &status_reg);
   return inferior_pid;
 }
 
@@ -867,20 +894,10 @@ arc_mourn ()
 }
 
 \f
-#ifdef REMOTE_BREAKPOINT
-
-/* On some machines, e.g. 68k, we may use a different breakpoint instruction
-   than other targets.  */
-static unsigned char break_insn[] = REMOTE_BREAKPOINT;
-
-/* Check that it fits in BREAKPOINT_MAX bytes.  */
-static unsigned char check_break_insn_size[BREAKPOINT_MAX] = REMOTE_BREAKPOINT;
 
-#else /* No REMOTE_BREAKPOINT.  */
-
-static unsigned char break_insn[] = BREAKPOINT;
-
-#endif /* No REMOTE_BREAKPOINT.  */
+static unsigned char big_break_insn[] = BIG_BREAKPOINT;
+static unsigned char little_break_insn[] = LITTLE_BREAKPOINT;
+#define BREAKPOINT_LEN (sizeof little_break_insn)
 
 /* Insert a breakpoint on targets that don't have any better breakpoint
    support.  We read the contents of the target location and stash it,
@@ -897,9 +914,16 @@ arc_insert_breakpoint (addr, contents_cache)
 {
   int val;
 
-  val = target_read_memory (addr, contents_cache, sizeof break_insn);
+  val = target_read_memory (addr, contents_cache, BREAKPOINT_LEN);
   if (val == 0)
-    val = target_write_memory (addr, (char *)break_insn, sizeof break_insn);
+    {
+      if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+       val = target_write_memory (addr, (char *) big_break_insn,
+                                  BREAKPOINT_LEN);
+      else
+       val = target_write_memory (addr, (char *) little_break_insn,
+                                  BREAKPOINT_LEN);
+    }
   return val;
 }
 
@@ -908,7 +932,7 @@ arc_remove_breakpoint (addr, contents_cache)
      CORE_ADDR addr;
      char *contents_cache;
 {
-  return target_write_memory (addr, contents_cache, sizeof break_insn);
+  return target_write_memory (addr, contents_cache, BREAKPOINT_LEN);
 }
 
 /* switch_command
@@ -919,9 +943,8 @@ switch_command (args, fromtty)
      char *args;
      int fromtty;
 {
-  unsigned char cmd;
-  int proc;
   struct target_waitstatus status;
+  int proc;
 
   if (strncmp (args, "audio", 3) == 0)
     proc = 0;
@@ -930,28 +953,25 @@ switch_command (args, fromtty)
   else if (strncmp (args, "host", 4) == 0)
     proc = 2;
 
-  if (cntl_reg & cntl_reg_halt_bit[proc])
+  curr_processor = proc;
+  
+  switch (proc)
     {
-      curr_processor = proc;
-      return;
+    case 0:
+      tm_print_insn = arc_get_disassembler (bfd_mach_arc_audio,
+                                           TARGET_BYTE_ORDER == BIG_ENDIAN);
+      break;
+    case 1:
+      tm_print_insn = arc_get_disassembler (bfd_mach_arc_graphics,
+                                           TARGET_BYTE_ORDER == BIG_ENDIAN);
+      break;
+    case 2:
+      tm_print_insn = arc_get_disassembler (bfd_mach_arc_host,
+                                           TARGET_BYTE_ORDER == BIG_ENDIAN);
+      break;
     }
 
-  if ((proc != HOST_PROCESSOR) && 
-      !(cntl_reg & cntl_reg_halt_bit[HOST_PROCESSOR]))
-    {
-      cmd = cntl_reg | cntl_reg_halt_bit[HOST_PROCESSOR];
-      arc_xfer_cntlreg (0, &cmd);
-      curr_processor = HOST_PROCESSOR;
-      arc_wait (inferior_pid, &status);
-    }
-  if (!(cntl_reg & cntl_reg_halt_bit[proc]))
-    {
-      cmd = cntl_reg | cntl_reg_halt_bit[proc];
-      arc_xfer_cntlreg (0, &cmd);
-      curr_processor = proc;
-      arc_wait (inferior_pid, &status);
-      arc_fetch_registers (-1);
-    }
+  return;
 }
 
 \f
@@ -989,6 +1009,7 @@ Specify the device it is connected to.",  /* to_doc */
   arc_mourn,                   /* to_mourn_inferior */
   0,                           /* to_can_run */
   0,                           /* to_notice_signals */
+  0,                           /* to_thread_alive */
   0,                           /* to_stop */
   process_stratum,             /* to_stratum */
   NULL,                                /* to_next */
@@ -1006,7 +1027,4 @@ void
 _initialize_remote_arc ()
 {
   add_target (&arc_ops);
-  add_com ("switch <processor>", class_obscure, switch_command,
-          "Switch to debug a different processor, can be one of 'host', \
-'graphic' and 'audio'.");
 }
This page took 0.026483 seconds and 4 git commands to generate.