sim: drop duplicate header checks
[binutils-gdb.git] / sim / mcore / interp.c
index c1a39e7b83d2626222dde9f0ebebd3cbe72f17e0..1b8d2a367826c2c13be0b23b19556cefbbf6951e 100644 (file)
@@ -1,32 +1,33 @@
 /* Simulator for Motorola's MCore processor
-   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1999-2015 Free Software Foundation, Inc.
    Contributed by Cygnus Solutions.
 
 This file is part of GDB, the GNU debugger.
 
 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, or (at your option)
-any later version.
+the Free Software Foundation; either version 3 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.
 
-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.  */
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include "config.h"
 #include <signal.h>
-#include "sysdep.h"
+#include <stdlib.h>
+#include <string.h>
 #include <sys/times.h>
 #include <sys/param.h>
-#include <netinet/in.h>        /* for byte ordering macros */
+#include <unistd.h>
 #include "bfd.h"
-#include "callback.h"
+#include "gdb/callback.h"
 #include "libiberty.h"
-#include "remote-sim.h"
+#include "gdb/remote-sim.h"
 
 #ifndef NUM_ELEM
 #define NUM_ELEM(A) (sizeof (A) / sizeof (A)[0])
@@ -287,7 +288,7 @@ what (x, v)
     }
 }
 
-/* Read functions */
+/* Read functions */
 static int INLINE 
 rbat (x)
      word x;
@@ -389,7 +390,7 @@ IOMEM (addr, write, value)
 {
 }
 
-/* default to a 8 Mbyte (== 2^23) memory space */
+/* Default to a 8 Mbyte (== 2^23) memory space.  */
 static int sim_memory_size = 23;
 
 #define        MEM_SIZE_FLOOR  64
@@ -403,9 +404,9 @@ sim_size (power)
   if (cpu.mem)
     free (cpu.mem);
 
-  /* watch out for the '0 count' problem. There's probably a better
-     way.. e.g., why do we use 64 here? */
-  if (cpu.asregs.msize < 64)   /* ensure a boundary */
+  /* Watch out for the '0 count' problem. There's probably a better
+     way.. e.g., why do we use 64 here?  */
+  if (cpu.asregs.msize < 64)   /* Ensure a boundary.  */
     cpu.mem = (unsigned char *) calloc (64, (64 + cpu.asregs.msize) / 64);
   else
     cpu.mem = (unsigned char *) calloc (64, cpu.asregs.msize / 64);
@@ -472,12 +473,6 @@ set_initial_gprs ()
   cpu.gr[PARM4] = cpu.gr[0];
 }
 
-static void
-interrupt ()
-{
-  cpu.asregs.exception = SIGINT;
-}
-
 /* Functions so that trapped open/close don't interfere with the
    parent's functions.  We say that we can't close the descriptors
    that we didn't open.  exit() and cleanup() get in trouble here,
@@ -762,7 +757,6 @@ sim_resume (sd, step, siggnal)
   word ibuf;
   word pc;
   unsigned short inst;
-  void (* sigsave)();
   int memops;
   int bonus_cycles;
   int insts;
@@ -770,7 +764,6 @@ sim_resume (sd, step, siggnal)
   int cycs;
   word WLhash;
 
-  sigsave = signal (SIGINT, interrupt);
   cpu.asregs.exception = step ? SIGTRAP: 0;
   pc = cpu.asregs.pc;
 
@@ -1709,8 +1702,6 @@ sim_resume (sd, step, siggnal)
   cpu.asregs.cycles += insts;          /* and each takes a cycle */
   cpu.asregs.cycles += bonus_cycles;   /* and extra cycles for branches */
   cpu.asregs.cycles += memops * memcycles;     /* and memop cycle delays */
-  
-  signal (SIGINT, sigsave);
 }
 
 
@@ -1718,7 +1709,7 @@ int
 sim_write (sd, addr, buffer, size)
      SIM_DESC sd;
      SIM_ADDR addr;
-     unsigned char * buffer;
+     const unsigned char * buffer;
      int size;
 {
   int i;
@@ -1901,7 +1892,7 @@ SIM_DESC
 sim_open (kind, cb, abfd, argv)
      SIM_OPEN_KIND kind;
      host_callback * cb;
-     struct _bfd * abfd;
+     struct bfd * abfd;
      char ** argv;
 {
   int osize = sim_memory_size;
@@ -1932,7 +1923,7 @@ sim_close (sd, quitting)
 SIM_RC
 sim_load (sd, prog, abfd, from_tty)
      SIM_DESC sd;
-     char * prog;
+     const char * prog;
      bfd * abfd;
      int from_tty;
 {
@@ -1981,9 +1972,11 @@ sim_load (sd, prog, abfd, from_tty)
     /* figure the end of the bss section */
 #if 0
     printf ("bss section at 0x%08x for 0x%08x bytes\n",
-       (unsigned long) s_bss->vma , (unsigned long) s_bss->_cooked_size);
+           (unsigned long) bfd_get_section_vma (handle, s_bss),
+           (unsigned long) bfd_section_size (handle, s_bss));
 #endif
-    heap_ptr = (unsigned long) s_bss->vma + (unsigned long) s_bss->_cooked_size;
+    heap_ptr = ((unsigned long) bfd_get_section_vma (handle, s_bss)
+               + (unsigned long) bfd_section_size (handle, s_bss));
 
     /* Clean up after ourselves.  */
     bfd_close (handle);
@@ -2009,7 +2002,7 @@ sim_load (sd, prog, abfd, from_tty)
 SIM_RC
 sim_create_inferior (sd, prog_bfd, argv, env)
      SIM_DESC sd;
-     struct _bfd * prog_bfd;
+     struct bfd * prog_bfd;
      char ** argv;
      char ** env;
 {
@@ -2128,17 +2121,10 @@ sim_create_inferior (sd, prog_bfd, argv, env)
   return SIM_RC_OK;
 }
 
-void
-sim_kill (sd)
-     SIM_DESC sd;
-{
-  /* nothing to do */
-}
-
 void
 sim_do_command (sd, cmd)
      SIM_DESC sd;
-     char * cmd;
+     const char *cmd;
 {
   /* Nothing there yet; it's all an error.  */
   
@@ -2151,6 +2137,7 @@ sim_do_command (sd, cmd)
          if ((simargv[1] == NULL) || (simargv[2] == NULL))
            {
              fprintf (stderr, "Error: missing argument to watch cmd.\n");
+             freeargv (simargv);
              return;
            }
          
@@ -2195,6 +2182,8 @@ sim_do_command (sd, cmd)
          fprintf (stderr,"Error: \"%s\" is not a valid M.CORE simulator command.\n",
                   cmd);
        }
+
+      freeargv (simargv);
     }
   else
     {