]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - sim/m32c/gdb-if.c
sim: switch config.h usage to defs.h
[thirdparty/binutils-gdb.git] / sim / m32c / gdb-if.c
index 863fcf405fc68061b56f3e1cb46c7f6a3c8a2053..b00d878f0bea2e34e0e812b504ba10100540b608 100644 (file)
@@ -1,6 +1,6 @@
 /* gdb.c --- sim interface to GDB.
 
 /* gdb.c --- sim interface to GDB.
 
-Copyright (C) 2005, 2007-2012 Free Software Foundation, Inc.
+Copyright (C) 2005-2021 Free Software Foundation, Inc.
 Contributed by Red Hat, Inc.
 
 This file is part of the GNU simulators.
 Contributed by Red Hat, Inc.
 
 This file is part of the GNU simulators.
@@ -18,16 +18,20 @@ 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, see <http://www.gnu.org/licenses/>.  */
 
 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"
+/* This must come before any other includes.  */
+#include "defs.h"
+
 #include <stdio.h>
 #include <assert.h>
 #include <signal.h>
 #include <stdio.h>
 #include <assert.h>
 #include <signal.h>
+#include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 
 #include "ansidecl.h"
 #include <string.h>
 #include <ctype.h>
 
 #include "ansidecl.h"
-#include "gdb/callback.h"
-#include "gdb/remote-sim.h"
+#include "libiberty.h"
+#include "sim/callback.h"
+#include "sim/sim.h"
 #include "gdb/signals.h"
 #include "gdb/sim-m32c.h"
 
 #include "gdb/signals.h"
 #include "gdb/sim-m32c.h"
 
@@ -59,7 +63,7 @@ static int open;
 SIM_DESC
 sim_open (SIM_OPEN_KIND kind,
          struct host_callback_struct *callback,
 SIM_DESC
 sim_open (SIM_OPEN_KIND kind,
          struct host_callback_struct *callback,
-         struct bfd *abfd, char **argv)
+         struct bfd *abfd, char * const *argv)
 {
   setbuf (stdout, 0);
   if (open)
 {
   setbuf (stdout, 0);
   if (open)
@@ -128,7 +132,7 @@ open_objfile (const char *filename)
 
 
 SIM_RC
 
 
 SIM_RC
-sim_load (SIM_DESC sd, char *prog, struct bfd * abfd, int from_tty)
+sim_load (SIM_DESC sd, const char *prog, struct bfd * abfd, int from_tty)
 {
   check_desc (sd);
 
 {
   check_desc (sd);
 
@@ -143,7 +147,8 @@ sim_load (SIM_DESC sd, char *prog, struct bfd * abfd, int from_tty)
 }
 
 SIM_RC
 }
 
 SIM_RC
-sim_create_inferior (SIM_DESC sd, struct bfd * abfd, char **argv, char **env)
+sim_create_inferior (SIM_DESC sd, struct bfd * abfd,
+                    char * const *argv, char * const *env)
 {
   check_desc (sd);
 
 {
   check_desc (sd);
 
@@ -509,49 +514,41 @@ sim_store_register (SIM_DESC sd, int regno, unsigned char *buf, int length)
   return size;
 }
 
   return size;
 }
 
-void
-sim_info (SIM_DESC sd, int verbose)
-{
-  check_desc (sd);
-
-  printf ("The m32c minisim doesn't collect any statistics.\n");
-}
-
 static volatile int stop;
 static enum sim_stop reason;
 static volatile int stop;
 static enum sim_stop reason;
-int siggnal;
+static int siggnal;
 
 
 /* Given a signal number used by the M32C bsp (that is, newlib),
    return a target signal number used by GDB.  */
 
 
 /* Given a signal number used by the M32C bsp (that is, newlib),
    return a target signal number used by GDB.  */
-int
+static int
 m32c_signal_to_target (int m32c)
 {
   switch (m32c)
     {
     case 4:
 m32c_signal_to_target (int m32c)
 {
   switch (m32c)
     {
     case 4:
-      return TARGET_SIGNAL_ILL;
+      return GDB_SIGNAL_ILL;
 
     case 5:
 
     case 5:
-      return TARGET_SIGNAL_TRAP;
+      return GDB_SIGNAL_TRAP;
 
     case 10:
 
     case 10:
-      return TARGET_SIGNAL_BUS;
+      return GDB_SIGNAL_BUS;
 
     case 11:
 
     case 11:
-      return TARGET_SIGNAL_SEGV;
+      return GDB_SIGNAL_SEGV;
 
     case 24:
 
     case 24:
-      return TARGET_SIGNAL_XCPU;
+      return GDB_SIGNAL_XCPU;
 
     case 2:
 
     case 2:
-      return TARGET_SIGNAL_INT;
+      return GDB_SIGNAL_INT;
 
     case 8:
 
     case 8:
-      return TARGET_SIGNAL_FPE;
+      return GDB_SIGNAL_FPE;
 
     case 6:
 
     case 6:
-      return TARGET_SIGNAL_ABRT;
+      return GDB_SIGNAL_ABRT;
     }
 
   return 0;
     }
 
   return 0;
@@ -560,13 +557,13 @@ m32c_signal_to_target (int m32c)
 
 /* Take a step return code RC and set up the variables consulted by
    sim_stop_reason appropriately.  */
 
 /* Take a step return code RC and set up the variables consulted by
    sim_stop_reason appropriately.  */
-void
+static void
 handle_step (int rc)
 {
   if (M32C_STEPPED (rc) || M32C_HIT_BREAK (rc))
     {
       reason = sim_stopped;
 handle_step (int rc)
 {
   if (M32C_STEPPED (rc) || M32C_HIT_BREAK (rc))
     {
       reason = sim_stopped;
-      siggnal = TARGET_SIGNAL_TRAP;
+      siggnal = GDB_SIGNAL_TRAP;
     }
   else if (M32C_STOPPED (rc))
     {
     }
   else if (M32C_STOPPED (rc))
     {
@@ -609,15 +606,17 @@ sim_resume (SIM_DESC sd, int step, int sig_to_deliver)
          interrupt signal handler.  */
       for (;;)
        {
          interrupt signal handler.  */
       for (;;)
        {
+         int rc;
+
          if (stop)
            {
              stop = 0;
              reason = sim_stopped;
          if (stop)
            {
              stop = 0;
              reason = sim_stopped;
-             siggnal = TARGET_SIGNAL_INT;
+             siggnal = GDB_SIGNAL_INT;
              break;
            }
 
              break;
            }
 
-         int rc = decode_opcode ();
+         rc = decode_opcode ();
 #ifdef TIMER_A
          update_timer_a ();
 #endif
 #ifdef TIMER_A
          update_timer_a ();
 #endif
@@ -650,39 +649,27 @@ sim_stop_reason (SIM_DESC sd, enum sim_stop *reason_p, int *sigrc_p)
 }
 
 void
 }
 
 void
-sim_do_command (SIM_DESC sd, char *cmd)
+sim_do_command (SIM_DESC sd, const char *cmd)
 {
 {
-  check_desc (sd);
+  const char *arg;
+  char **argv = buildargv (cmd);
 
 
-  char *p = cmd;
-
-  /* Skip leading whitespace.  */
-  while (isspace (*p))
-    p++;
-
-  /* Find the extent of the command word.  */
-  for (p = cmd; *p; p++)
-    if (isspace (*p))
-      break;
+  check_desc (sd);
 
 
-  /* Null-terminate the command word, and record the start of any
-     further arguments.  */
-  char *args;
-  if (*p)
+  cmd = arg = "";
+  if (argv != NULL)
     {
     {
-      *p = '\0';
-      args = p + 1;
-      while (isspace (*args))
-       args++;
+      if (argv[0] != NULL)
+       cmd = argv[0];
+      if (argv[1] != NULL)
+       arg = argv[1];
     }
     }
-  else
-    args = p;
 
   if (strcmp (cmd, "trace") == 0)
     {
 
   if (strcmp (cmd, "trace") == 0)
     {
-      if (strcmp (args, "on") == 0)
+      if (strcmp (arg, "on") == 0)
        trace = 1;
        trace = 1;
-      else if (strcmp (args, "off") == 0)
+      else if (strcmp (arg, "off") == 0)
        trace = 0;
       else
        printf ("The 'sim trace' command expects 'on' or 'off' "
        trace = 0;
       else
        printf ("The 'sim trace' command expects 'on' or 'off' "
@@ -690,9 +677,9 @@ sim_do_command (SIM_DESC sd, char *cmd)
     }
   else if (strcmp (cmd, "verbose") == 0)
     {
     }
   else if (strcmp (cmd, "verbose") == 0)
     {
-      if (strcmp (args, "on") == 0)
+      if (strcmp (arg, "on") == 0)
        verbose = 1;
        verbose = 1;
-      else if (strcmp (args, "off") == 0)
+      else if (strcmp (arg, "off") == 0)
        verbose = 0;
       else
        printf ("The 'sim verbose' command expects 'on' or 'off'"
        verbose = 0;
       else
        printf ("The 'sim verbose' command expects 'on' or 'off'"
@@ -701,10 +688,24 @@ sim_do_command (SIM_DESC sd, char *cmd)
   else
     printf ("The 'sim' command expects either 'trace' or 'verbose'"
            " as a subcommand.\n");
   else
     printf ("The 'sim' command expects either 'trace' or 'verbose'"
            " as a subcommand.\n");
+
+  freeargv (argv);
 }
 
 char **
 }
 
 char **
-sim_complete_command (SIM_DESC sd, char *text, char *word)
+sim_complete_command (SIM_DESC sd, const char *text, const char *word)
 {
   return NULL;
 }
 {
   return NULL;
 }
+
+char *
+sim_memory_map (SIM_DESC sd)
+{
+  return NULL;
+}
+
+void
+sim_info (SIM_DESC sd, int verbose)
+{
+  printf ("The m32c minisim doesn't collect any statistics.\n");
+}