*** empty log message ***
[binutils-gdb.git] / gdb / arc-tdep.c
index e76aa93770b347fcddc25bc6296cfaaa252809c3..825e55bd4fc2a507dcb4166972b66007f7a3afe8 100644 (file)
@@ -1,21 +1,22 @@
 /* ARC target-dependent stuff.
-   Copyright (C) 1995 Free Software Foundation, Inc.
+   Copyright 1995, 1996, 1999, 2000, 2001 Free Software Foundation, Inc.
 
-This file is part of GDB.
+   This file is part of GDB.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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.  */
+   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., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
 #include "frame.h"
@@ -25,21 +26,30 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "floatformat.h"
 #include "symtab.h"
 #include "gdbcmd.h"
+#include "regcache.h"
+
+/* Local functions */
+
+static int arc_set_cpu_type (char *str);
 
 /* Current CPU, set with the "set cpu" command.  */
+static int arc_bfd_mach_type;
 char *arc_cpu_type;
 char *tmp_arc_cpu_type;
 
 /* Table of cpu names.  */
-struct {
-  char *name;
-  int value;
-} arc_cpu_type_table[] = {
-  { "base", bfd_mach_arc_base },
-  { "host", bfd_mach_arc_host },
-  { "graphics", bfd_mach_arc_graphics },
-  { "audio", bfd_mach_arc_audio },
-  { NULL, 0 }
+struct
+  {
+    char *name;
+    int value;
+  }
+arc_cpu_type_table[] =
+{
+  { "arc5", bfd_mach_arc_5 },
+  { "arc6", bfd_mach_arc_6 },
+  { "arc7", bfd_mach_arc_7 },
+  { "arc8", bfd_mach_arc_8 },
+  {  NULL,  0 }
 };
 
 /* Used by simulator.  */
@@ -53,7 +63,8 @@ int debug_pipeline_p;
 
 #define OPMASK 0xf8000000
 
-/* Instruction field accessor macros.  */
+/* Instruction field accessor macros.
+   See the Programmer's Reference Manual.  */
 #define X_OP(i) (((i) >> 27) & 0x1f)
 #define X_A(i) (((i) >> 21) & 0x3f)
 #define X_B(i) (((i) >> 15) & 0x3f)
@@ -78,13 +89,14 @@ int debug_pipeline_p;
    | ((d) & 511))
 \f
 /* Codestream stuff.  */
-static void codestream_read PARAMS ((unsigned int *, int));
-static void codestream_seek PARAMS ((CORE_ADDR));
-static unsigned int codestream_fill PARAMS ((int));
+static void codestream_read (unsigned int *, int);
+static void codestream_seek (CORE_ADDR);
+static unsigned int codestream_fill (int);
 
-#define CODESTREAM_BUFSIZ 16 
+#define CODESTREAM_BUFSIZ 16
 static CORE_ADDR codestream_next_addr;
 static CORE_ADDR codestream_addr;
+/* FIXME assumes sizeof (int) == 32? */
 static unsigned int codestream_buf[CODESTREAM_BUFSIZ];
 static int codestream_off;
 static int codestream_cnt;
@@ -100,40 +112,48 @@ static int codestream_cnt;
    ? codestream_fill (0) \
    : codestream_buf[codestream_off++])
 
-static unsigned int 
-codestream_fill (peek_flag)
-    int peek_flag;
+static unsigned int
+codestream_fill (int peek_flag)
 {
   codestream_addr = codestream_next_addr;
   codestream_next_addr += CODESTREAM_BUFSIZ * sizeof (codestream_buf[0]);
   codestream_off = 0;
   codestream_cnt = CODESTREAM_BUFSIZ;
-  /* FIXME: need to handle byte order differences.  */
   read_memory (codestream_addr, (char *) codestream_buf,
               CODESTREAM_BUFSIZ * sizeof (codestream_buf[0]));
-  
+  /* FIXME: check return code?  */
+
+
+  /* Handle byte order differences -> convert to host byte ordering.  */
+  {
+    int i;
+    for (i = 0; i < CODESTREAM_BUFSIZ; i++)
+      codestream_buf[i] =
+       extract_unsigned_integer (&codestream_buf[i],
+                                 sizeof (codestream_buf[i]));
+  }
+
   if (peek_flag)
-    return (codestream_peek());
+    return codestream_peek ();
   else
-    return (codestream_get());
+    return codestream_get ();
 }
 
 static void
-codestream_seek (place)
-    CORE_ADDR place;
+codestream_seek (CORE_ADDR place)
 {
   codestream_next_addr = place / CODESTREAM_BUFSIZ;
   codestream_next_addr *= CODESTREAM_BUFSIZ;
   codestream_cnt = 0;
   codestream_fill (1);
-  while (codestream_tell() != place)
+  while (codestream_tell () != place)
     codestream_get ();
 }
 
+/* This function is currently unused but leave in for now.  */
+
 static void
-codestream_read (buf, count)
-     unsigned int *buf;
-     int count;
+codestream_read (unsigned int *buf, int count)
 {
   unsigned int *p;
   int i;
@@ -142,24 +162,16 @@ codestream_read (buf, count)
     *p++ = codestream_get ();
 }
 \f
-/* Set up prologue scanning and return the first insn,
-   not including the "sub sp,sp,32" of a stdarg function.  */
+/* Set up prologue scanning and return the first insn.  */
 
 static unsigned int
-setup_prologue_scan (pc)
-     CORE_ADDR pc;
+setup_prologue_scan (CORE_ADDR pc)
 {
   unsigned int insn;
 
   codestream_seek (pc);
   insn = codestream_get ();
 
-  /* The authority for what appears here is the home-grown ABI.  */
-
-  /* First insn may be "sub sp,sp,32" if stdarg fn.  */
-  if (insn == BUILD_INSN (10, SP_REGNUM, SP_REGNUM, SHIMM_REGNUM, 32))
-    insn = codestream_get ();
-
   return insn;
 }
 
@@ -171,62 +183,83 @@ setup_prologue_scan (pc)
  */
 
 static long
-arc_get_frame_setup (pc)
-     CORE_ADDR pc;
+arc_get_frame_setup (CORE_ADDR pc)
 {
   unsigned int insn;
   /* Size of frame or -1 if unrecognizable prologue.  */
-  int n = -1;
+  int frame_size = -1;
+  /* An initial "sub sp,sp,N" may or may not be for a stdarg fn.  */
+  int maybe_stdarg_decr = -1;
 
   insn = setup_prologue_scan (pc);
 
+  /* The authority for what appears here is the home-grown ABI.
+     The most recent version is 1.2.  */
+
+  /* First insn may be "sub sp,sp,N" if stdarg fn.  */
+  if ((insn & BUILD_INSN (-1, -1, -1, -1, 0))
+      == BUILD_INSN (10, SP_REGNUM, SP_REGNUM, SHIMM_REGNUM, 0))
+    {
+      maybe_stdarg_decr = X_D (insn);
+      insn = codestream_get ();
+    }
+
   if ((insn & BUILD_INSN (-1, 0, -1, -1, -1))  /* st blink,[sp,4] */
       == BUILD_INSN (2, 0, SP_REGNUM, BLINK_REGNUM, 4))
     {
       insn = codestream_get ();
       /* Frame may not be necessary, even though blink is saved.
-        At least this is something we recognize.  */
-      n = 0;
+         At least this is something we recognize.  */
+      frame_size = 0;
     }
 
-  if ((insn & BUILD_INSN (-1, 0, -1, -1, -1))          /* st fp,[sp] */
+  if ((insn & BUILD_INSN (-1, 0, -1, -1, -1))  /* st fp,[sp] */
       == BUILD_INSN (2, 0, SP_REGNUM, FP_REGNUM, 0))
-    {  
+    {
       insn = codestream_get ();
       if ((insn & BUILD_INSN (-1, -1, -1, -1, 0))
-              != BUILD_INSN (12, FP_REGNUM, SP_REGNUM, SP_REGNUM, 0))
+         != BUILD_INSN (12, FP_REGNUM, SP_REGNUM, SP_REGNUM, 0))
        return -1;
 
-      /* Check for stack adjustment sub sp,sp,nnn.  */
+      /* Check for stack adjustment sub sp,sp,N.  */
       insn = codestream_peek ();
       if ((insn & BUILD_INSN (-1, -1, -1, 0, 0))
          == BUILD_INSN (10, SP_REGNUM, SP_REGNUM, 0, 0))
        {
          if (LIMM_P (X_C (insn)))
-           n = codestream_get ();
+           frame_size = codestream_get ();
          else if (SHIMM_P (X_C (insn)))
-           n = X_D (insn);
+           frame_size = X_D (insn);
          else
            return -1;
-         if (n < 0)
+         if (frame_size < 0)
            return -1;
 
-          codestream_get ();
+         codestream_get ();
 
          /* This sequence is used to get the address of the return
             buffer for a function that returns a structure.  */
          insn = codestream_peek ();
-         if (insn & OPMASK == 0x60000000)
+         if ((insn & OPMASK) == 0x60000000)
            codestream_get ();
        }
       /* Frameless fn.  */
       else
        {
-         n = 0;
+         frame_size = 0;
        }
     }
 
-  return n;
+  /* If we found a "sub sp,sp,N" and nothing else, it may or may not be a
+     stdarg fn.  The stdarg decrement is not treated as part of the frame size,
+     so we have a dilemma: what do we return?  For now, if we get a
+     "sub sp,sp,N" and nothing else assume this isn't a stdarg fn.  One way
+     to fix this completely would be to add a bit to the function descriptor
+     that says the function is a stdarg function.  */
+
+  if (frame_size < 0 && maybe_stdarg_decr > 0)
+    return maybe_stdarg_decr;
+  return frame_size;
 }
 
 /* Given a pc value, skip it forward past the function prologue by
@@ -237,9 +270,7 @@ arc_get_frame_setup (pc)
    This allows a quicker answer.  */
 
 CORE_ADDR
-skip_prologue (pc, frameless_p)
-     CORE_ADDR pc;
-     int frameless_p;
+arc_skip_prologue (CORE_ADDR pc, int frameless_p)
 {
   unsigned int insn;
   int i, frame_size;
@@ -256,8 +287,8 @@ skip_prologue (pc, frameless_p)
       insn = codestream_peek ();
       if ((insn & BUILD_INSN (-1, 0, -1, 0, 0))
          != BUILD_INSN (2, 0, SP_REGNUM, 0, 0))
-       break; /* not st insn */
-      if (! ARC_CALL_SAVED_REG (X_C (insn)))
+       break;                  /* not st insn */
+      if (!ARC_CALL_SAVED_REG (X_C (insn)))
        break;
       codestream_get ();
     }
@@ -270,8 +301,7 @@ skip_prologue (pc, frameless_p)
    This is taken from frameless_look_for_prologue.  */
 
 CORE_ADDR
-arc_frame_saved_pc (frame)
-     struct frame_info *frame;
+arc_frame_saved_pc (struct frame_info *frame)
 {
   CORE_ADDR func_start;
   unsigned int insn;
@@ -283,13 +313,21 @@ arc_frame_saved_pc (frame)
       return ARC_PC_TO_REAL_ADDRESS (read_memory_integer (FRAME_FP (frame) + 4, 4));
     }
 
-  /* If the first insn is "st blink,[sp,4]" we can get blink from there.
+  /* The authority for what appears here is the home-grown ABI.
+     The most recent version is 1.2.  */
+
+  insn = setup_prologue_scan (func_start);
+
+  /* First insn may be "sub sp,sp,N" if stdarg fn.  */
+  if ((insn & BUILD_INSN (-1, -1, -1, -1, 0))
+      == BUILD_INSN (10, SP_REGNUM, SP_REGNUM, SHIMM_REGNUM, 0))
+    insn = codestream_get ();
+
+  /* If the next insn is "st blink,[sp,4]" we can get blink from there.
      Otherwise this is a leaf function and we can use blink.  Note that
      this still allows for the case where a leaf function saves/clobbers/
      restores blink.  */
 
-  insn = setup_prologue_scan (func_start);
-
   if ((insn & BUILD_INSN (-1, 0, -1, -1, -1))  /* st blink,[sp,4] */
       != BUILD_INSN (2, 0, SP_REGNUM, BLINK_REGNUM, 4))
     return ARC_PC_TO_REAL_ADDRESS (read_register (BLINK_REGNUM));
@@ -309,9 +347,7 @@ arc_frame_saved_pc (frame)
  */
 
 void
-frame_find_saved_regs (fip, fsrp)
-     struct frame_info *fip;
-     struct frame_saved_regs *fsrp;
+frame_find_saved_regs (struct frame_info *fip, struct frame_saved_regs *fsrp)
 {
   long locals;
   unsigned int insn;
@@ -325,11 +361,11 @@ frame_find_saved_regs (fip, fsrp)
   dummy_bottom = fip->frame - 4 - REGISTER_BYTES - CALL_DUMMY_LENGTH;
 
   /* Check if the PC is in the stack, in a dummy frame.  */
-  if (dummy_bottom <= fip->pc && fip->pc <= fip->frame) 
+  if (dummy_bottom <= fip->pc && fip->pc <= fip->frame)
     {
       /* all regs were saved by push_call_dummy () */
       adr = fip->frame;
-      for (i = 0; i < NUM_REGS; i++) 
+      for (i = 0; i < NUM_REGS; i++)
        {
          adr -= REGISTER_RAW_SIZE (i);
          fsrp->regs[i] = adr;
@@ -339,7 +375,7 @@ frame_find_saved_regs (fip, fsrp)
 
   locals = arc_get_frame_setup (get_pc_function_start (fip->pc));
 
-  if (locals >= 0) 
+  if (locals >= 0)
     {
       /* Set `adr' to the value of `sp'.  */
       adr = fip->frame - locals;
@@ -347,9 +383,9 @@ frame_find_saved_regs (fip, fsrp)
        {
          insn = codestream_get ();
          if ((insn & BUILD_INSN (-1, 0, -1, 0, 0))
-              != BUILD_INSN (2, 0, SP_REGNUM, 0, 0))
+             != BUILD_INSN (2, 0, SP_REGNUM, 0, 0))
            break;
-          regnum = X_C (insn);
+         regnum = X_C (insn);
          offset = X_D (insn);
          fsrp->regs[regnum] = adr + offset;
        }
@@ -360,14 +396,14 @@ frame_find_saved_regs (fip, fsrp)
 }
 
 void
-push_dummy_frame ()
+arc_push_dummy_frame (void)
 {
   CORE_ADDR sp = read_register (SP_REGNUM);
   int regnum;
   char regbuf[MAX_REGISTER_RAW_SIZE];
 
   read_register_gen (PC_REGNUM, regbuf);
-  write_memory (sp+4, regbuf, REGISTER_SIZE);
+  write_memory (sp + 4, regbuf, REGISTER_SIZE);
   read_register_gen (FP_REGNUM, regbuf);
   write_memory (sp, regbuf, REGISTER_SIZE);
   write_register (FP_REGNUM, sp);
@@ -376,22 +412,22 @@ push_dummy_frame ()
       read_register_gen (regnum, regbuf);
       sp = push_bytes (sp, regbuf, REGISTER_RAW_SIZE (regnum));
     }
-  sp += (2*REGISTER_SIZE);
+  sp += (2 * REGISTER_SIZE);
   write_register (SP_REGNUM, sp);
 }
 
 void
-pop_frame ()
+arc_pop_frame (void)
 {
   struct frame_info *frame = get_current_frame ();
   CORE_ADDR fp;
   int regnum;
   struct frame_saved_regs fsr;
   char regbuf[MAX_REGISTER_RAW_SIZE];
-  
+
   fp = FRAME_FP (frame);
   get_frame_saved_regs (frame, &fsr);
-  for (regnum = 0; regnum < NUM_REGS; regnum++) 
+  for (regnum = 0; regnum < NUM_REGS; regnum++)
     {
       CORE_ADDR adr;
       adr = fsr.regs[regnum];
@@ -412,45 +448,48 @@ pop_frame ()
 
 typedef enum
 {
-  NORMAL4, /* a normal 4 byte insn */
-  NORMAL8, /* a normal 8 byte insn */
-  BRANCH4, /* a 4 byte branch insn, including ones without delay slots */
-  BRANCH8, /* an 8 byte branch insn, including ones with delay slots */
-} insn_type;
+  NORMAL4,                     /* a normal 4 byte insn */
+  NORMAL8,                     /* a normal 8 byte insn */
+  BRANCH4,                     /* a 4 byte branch insn, including ones without delay slots */
+  BRANCH8,                     /* an 8 byte branch insn, including ones with delay slots */
+}
+insn_type;
 
 /* Return the type of INSN and store in TARGET the destination address of a
    branch if this is one.  */
 /* ??? Need to verify all cases are properly handled.  */
 
 static insn_type
-get_insn_type (insn, pc, target)
-     unsigned long insn;
-     CORE_ADDR pc, *target;
+get_insn_type (unsigned long insn, CORE_ADDR pc, CORE_ADDR *target)
 {
   unsigned long limm;
 
   switch (insn >> 27)
     {
-    case 0 : case 1 : case 2 : /* load/store insns */
+    case 0:
+    case 1:
+    case 2:                    /* load/store insns */
       if (LIMM_P (X_A (insn))
          || LIMM_P (X_B (insn))
          || LIMM_P (X_C (insn)))
        return NORMAL8;
       return NORMAL4;
-    case 4 : case 5 : case 6 : /* branch insns */
+    case 4:
+    case 5:
+    case 6:                    /* branch insns */
       *target = pc + 4 + X_L (insn);
       /* ??? It isn't clear that this is always the right answer.
-        The problem occurs when the next insn is an 8 byte insn.  If the
-        branch is conditional there's no worry as there shouldn't be an 8
-        byte insn following.  The programmer may be cheating if s/he knows
-        the branch will never be taken, but we don't deal with that.
-        Note that the programmer is also allowed to play games by putting
-        an insn with long immediate data in the delay slot and then duplicate
-        the long immediate data at the branch target.  Ugh!  */
+         The problem occurs when the next insn is an 8 byte insn.  If the
+         branch is conditional there's no worry as there shouldn't be an 8
+         byte insn following.  The programmer may be cheating if s/he knows
+         the branch will never be taken, but we don't deal with that.
+         Note that the programmer is also allowed to play games by putting
+         an insn with long immediate data in the delay slot and then duplicate
+         the long immediate data at the branch target.  Ugh!  */
       if (X_N (insn) == 0)
        return BRANCH4;
       return BRANCH8;
-    case 7 : /* jump insns */
+    case 7:                    /* jump insns */
       if (LIMM_P (X_B (insn)))
        {
          limm = read_memory_integer (pc + 4, 4);
@@ -464,7 +503,7 @@ get_insn_type (insn, pc, target)
       if (X_Q (insn) == 0 && X_N (insn) == 0)
        return BRANCH4;
       return BRANCH8;
-    default : /* arithmetic insns, etc. */
+    default:                   /* arithmetic insns, etc. */
       if (LIMM_P (X_A (insn))
          || LIMM_P (X_B (insn))
          || LIMM_P (X_C (insn)))
@@ -473,12 +512,6 @@ get_insn_type (insn, pc, target)
     }
 }
 
-/* Non-zero if we just simulated a single-step.  This is needed because we
-   cannot remove the breakpoints in the inferior process until after the
-   `wait' in `wait_for_inferior'.  */
-
-int one_stepped;
-
 /* single_step() is called just before we want to resume the inferior, if we
    want to single-step it but there is no hardware or kernel single-step
    support.  We find all the possible targets of the coming instruction and
@@ -488,15 +521,15 @@ int one_stepped;
    set up a simulated single-step, we undo our damage.  */
 
 void
-single_step (ignore)
-     int ignore; /* sig, but we don't need it */
+arc_software_single_step (enum target_signal ignore,   /* sig but we don't need it */
+                         int insert_breakpoints_p)
 {
   static CORE_ADDR next_pc, target;
   static int brktrg_p;
   typedef char binsn_quantum[BREAKPOINT_MAX];
   static binsn_quantum break_mem[2];
 
-  if (!one_stepped)
+  if (insert_breakpoints_p)
     {
       insn_type type;
       CORE_ADDR pc;
@@ -513,18 +546,16 @@ single_step (ignore)
       brktrg_p = 0;
 
       if ((type == BRANCH4 || type == BRANCH8)
-         /* Watch out for branches to the following location.
-            We just stored a breakpoint there and another call to
-            target_insert_breakpoint will think the real insn is the
-            breakpoint we just stored there.  */
+      /* Watch out for branches to the following location.
+         We just stored a breakpoint there and another call to
+         target_insert_breakpoint will think the real insn is the
+         breakpoint we just stored there.  */
          && target != next_pc)
        {
          brktrg_p = 1;
          target_insert_breakpoint (target, break_mem[1]);
        }
 
-      /* We are ready to let it go.  */
-      one_stepped = 1;
     }
   else
     {
@@ -537,8 +568,6 @@ single_step (ignore)
       /* Fix the pc.  */
       stop_pc -= DECR_PC_AFTER_BREAK;
       write_pc (stop_pc);
-
-      one_stepped = 0;
     }
 }
 \f
@@ -549,15 +578,14 @@ single_step (ignore)
    This routine returns true on success. */
 
 int
-get_longjmp_target(pc)
-     CORE_ADDR *pc;
+get_longjmp_target (CORE_ADDR *pc)
 {
   char buf[TARGET_PTR_BIT / TARGET_CHAR_BIT];
   CORE_ADDR sp, jb_addr;
 
   sp = read_register (SP_REGNUM);
 
-  if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack */
+  if (target_read_memory (sp + SP_ARG0,                /* Offset of first arg on stack */
                          buf,
                          TARGET_PTR_BIT / TARGET_CHAR_BIT))
     return 0;
@@ -574,12 +602,31 @@ get_longjmp_target(pc)
 }
 #endif /* GET_LONGJMP_TARGET */
 \f
+/* Disassemble one instruction.  */
+
+static int
+arc_print_insn (bfd_vma vma, disassemble_info *info)
+{
+  static int current_mach;
+  static int current_endian;
+  static disassembler_ftype current_disasm;
+
+  if (current_disasm == NULL
+      || arc_bfd_mach_type != current_mach
+      || TARGET_BYTE_ORDER != current_endian)
+    {
+      current_mach = arc_bfd_mach_type;
+      current_endian = TARGET_BYTE_ORDER;
+      current_disasm = arc_get_disassembler (NULL);
+    }
+
+  return (*current_disasm) (vma, info);
+}
+\f
 /* Command to set cpu type.  */
 
 void
-arc_set_cpu_type_command (args, from_tty)
-     char *args;
-     int from_tty;
+arc_set_cpu_type_command (char *args, int from_tty)
 {
   int i;
 
@@ -590,32 +637,29 @@ arc_set_cpu_type_command (args, from_tty)
        printf_unfiltered ("%s\n", arc_cpu_type_table[i].name);
 
       /* Restore the value.  */
-      tmp_arc_cpu_type = strsave (arc_cpu_type);
+      tmp_arc_cpu_type = xstrdup (arc_cpu_type);
 
       return;
     }
-  
+
   if (!arc_set_cpu_type (tmp_arc_cpu_type))
     {
       error ("Unknown cpu type `%s'.", tmp_arc_cpu_type);
       /* Restore its value.  */
-      tmp_arc_cpu_type = strsave (arc_cpu_type);
+      tmp_arc_cpu_type = xstrdup (arc_cpu_type);
     }
 }
 
 static void
-arc_show_cpu_type_command (args, from_tty)
-     char *args;
-     int from_tty;
+arc_show_cpu_type_command (char *args, int from_tty)
 {
 }
 
 /* Modify the actual cpu type.
    Result is a boolean indicating success.  */
 
-int
-arc_set_cpu_type (str)
-     char *str;
+static int
+arc_set_cpu_type (char *str)
 {
   int i, j;
 
@@ -627,8 +671,7 @@ arc_set_cpu_type (str)
       if (strcasecmp (str, arc_cpu_type_table[i].name) == 0)
        {
          arc_cpu_type = str;
-         tm_print_insn = arc_get_disassembler (arc_cpu_type_table[i].value,
-                                               TARGET_BYTE_ORDER == BIG_ENDIAN);
+         arc_bfd_mach_type = arc_cpu_type_table[i].value;
          return 1;
        }
     }
@@ -637,7 +680,7 @@ arc_set_cpu_type (str)
 }
 \f
 void
-_initialize_arc_tdep ()
+_initialize_arc_tdep (void)
 {
   struct cmd_list_element *c;
 
@@ -653,9 +696,9 @@ cpu-type-specific registers and recognize cpu-type-specific instructions.\
   c = add_show_from_set (c, &showlist);
   c->function.cfunc = arc_show_cpu_type_command;
 
-  /* We have to use strsave here because the `set' command frees it before
-     setting a new value.  */
-  tmp_arc_cpu_type = strsave (DEFAULT_ARC_CPU_TYPE);
+  /* We have to use xstrdup() here because the `set' command frees it
+     before setting a new value.  */
+  tmp_arc_cpu_type = xstrdup (DEFAULT_ARC_CPU_TYPE);
   arc_set_cpu_type (tmp_arc_cpu_type);
 
   c = add_set_cmd ("displaypipeline", class_support, var_zinteger,
@@ -680,6 +723,5 @@ A negative value disables the timer.",
                   &setlist);
   c = add_show_from_set (c, &showlist);
 
-  /* FIXME: must be done after for now.  */
-  tm_print_insn = arc_get_disassembler (bfd_mach_arc_base, 1 /*FIXME*/);
+  tm_print_insn = arc_print_insn;
 }