Don't write to inferior_ptid in go32-nat.c
[deliverable/binutils-gdb.git] / sim / rx / gdb-if.c
index 95884f03eb0896b5723f5673b0139d56c21a5e70..8d265f1324cd668e8b68dbd61eaf0d2cbb63dfe9 100644 (file)
@@ -1,6 +1,6 @@
 /* gdb-if.c -- sim interface to GDB.
 
 /* gdb-if.c -- sim interface to GDB.
 
-Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+Copyright (C) 2008-2020 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.
@@ -54,14 +54,14 @@ static struct sim_state the_minisim = {
   "This is the sole rx minisim instance.  See libsim.a's global variables."
 };
 
   "This is the sole rx minisim instance.  See libsim.a's global variables."
 };
 
-static int open;
+static int rx_sim_is_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)
 {
 {
-  if (open)
+  if (rx_sim_is_open)
     fprintf (stderr, "rx minisim: re-opened sim\n");
 
   /* The 'run' interface doesn't use this function, so we don't care
     fprintf (stderr, "rx minisim: re-opened sim\n");
 
   /* The 'run' interface doesn't use this function, so we don't care
@@ -79,7 +79,7 @@ sim_open (SIM_OPEN_KIND kind,
   execution_error_init_debugger ();
 
   sim_disasm_init (abfd);
   execution_error_init_debugger ();
 
   sim_disasm_init (abfd);
-  open = 1;
+  rx_sim_is_open = 1;
   return &the_minisim;
 }
 
   return &the_minisim;
 }
 
@@ -98,7 +98,7 @@ sim_close (SIM_DESC sd, int quitting)
   /* Not much to do.  At least free up our memory.  */
   init_mem ();
 
   /* Not much to do.  At least free up our memory.  */
   init_mem ();
 
-  open = 0;
+  rx_sim_is_open = 0;
 }
 
 static bfd *
 }
 
 static bfd *
@@ -164,14 +164,14 @@ build_swap_list (struct bfd *abfd)
          struct swap_list *sl;
          bfd_size_type size;
 
          struct swap_list *sl;
          bfd_size_type size;
 
-         size = bfd_get_section_size (s);
+         size = bfd_section_size (s);
          if (size <= 0)
            continue;
          
          sl = malloc (sizeof (struct swap_list));
          assert (sl != NULL);
          sl->next = swap_list;
          if (size <= 0)
            continue;
          
          sl = malloc (sizeof (struct swap_list));
          assert (sl != NULL);
          sl->next = swap_list;
-         sl->start = bfd_section_lma (abfd, s);
+         sl->start = bfd_section_lma (s);
          sl->end = sl->start + size;
          swap_list = sl;
        }
          sl->end = sl->start + size;
          swap_list = sl;
        }
@@ -192,7 +192,7 @@ addr_in_swap_list (bfd_vma addr)
 }
 
 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);
 
@@ -201,20 +201,21 @@ sim_load (SIM_DESC sd, char *prog, struct bfd *abfd, int from_tty)
   if (!abfd)
     return SIM_RC_FAIL;
 
   if (!abfd)
     return SIM_RC_FAIL;
 
-  rx_load (abfd);
+  rx_load (abfd, get_callbacks ());
   build_swap_list (abfd);
 
   return SIM_RC_OK;
 }
 
 SIM_RC
   build_swap_list (abfd);
 
   return SIM_RC_OK;
 }
 
 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);
 
   if (abfd)
     {
 {
   check_desc (sd);
 
   if (abfd)
     {
-      rx_load (abfd);
+      rx_load (abfd, NULL);
       build_swap_list (abfd);
     }
 
       build_swap_list (abfd);
     }
 
@@ -650,52 +651,35 @@ int siggnal;
 
 
 /* Given a signal number used by the RX bsp (that is, newlib),
 
 
 /* Given a signal number used by the RX bsp (that is, newlib),
-   return a host signal number.  (Oddly, the gdb/sim interface uses
-   host signal numbers...)  */
-int
-rx_signal_to_host (int rx)
+   return a target signal number used by GDB.  */
+static int
+rx_signal_to_gdb_signal (int rx)
 {
   switch (rx)
     {
     case 4:
 {
   switch (rx)
     {
     case 4:
-#ifdef SIGILL
-      return SIGILL;
-#else
-      return SIGSEGV;
-#endif
+      return GDB_SIGNAL_ILL;
 
     case 5:
 
     case 5:
-      return SIGTRAP;
+      return GDB_SIGNAL_TRAP;
 
     case 10:
 
     case 10:
-#ifdef SIGBUS
-      return SIGBUS;
-#else
-      return SIGSEGV;
-#endif
+      return GDB_SIGNAL_BUS;
 
     case 11:
 
     case 11:
-      return SIGSEGV;
+      return GDB_SIGNAL_SEGV;
 
     case 24:
 
     case 24:
-#ifdef SIGXCPU
-      return SIGXCPU;
-#else
-      break;
-#endif
+      return GDB_SIGNAL_XCPU;
 
     case 2:
 
     case 2:
-      return SIGINT;
+      return GDB_SIGNAL_INT;
 
     case 8:
 
     case 8:
-#ifdef SIGFPE
-      return SIGFPE;
-#else
-      break;
-#endif
+      return GDB_SIGNAL_FPE;
 
     case 6:
 
     case 6:
-      return SIGABRT;
+      return GDB_SIGNAL_ABRT;
     }
 
   return 0;
     }
 
   return 0;
@@ -710,17 +694,17 @@ handle_step (int rc)
   if (execution_error_get_last_error () != SIM_ERR_NONE)
     {
       reason = sim_stopped;
   if (execution_error_get_last_error () != SIM_ERR_NONE)
     {
       reason = sim_stopped;
-      siggnal = TARGET_SIGNAL_SEGV;
+      siggnal = GDB_SIGNAL_SEGV;
     }
   if (RX_STEPPED (rc) || RX_HIT_BREAK (rc))
     {
       reason = sim_stopped;
     }
   if (RX_STEPPED (rc) || RX_HIT_BREAK (rc))
     {
       reason = sim_stopped;
-      siggnal = TARGET_SIGNAL_TRAP;
+      siggnal = GDB_SIGNAL_TRAP;
     }
   else if (RX_STOPPED (rc))
     {
       reason = sim_stopped;
     }
   else if (RX_STOPPED (rc))
     {
       reason = sim_stopped;
-      siggnal = rx_signal_to_host (RX_STOP_SIG (rc));
+      siggnal = rx_signal_to_gdb_signal (RX_STOP_SIG (rc));
     }
   else
     {
     }
   else
     {
@@ -766,7 +750,7 @@ sim_resume (SIM_DESC sd, int step, int sig_to_deliver)
            {
              stop = 0;
              reason = sim_stopped;
            {
              stop = 0;
              reason = sim_stopped;
-             siggnal = TARGET_SIGNAL_INT;
+             siggnal = GDB_SIGNAL_INT;
              break;
            }
 
              break;
            }
 
@@ -777,7 +761,7 @@ sim_resume (SIM_DESC sd, int step, int sig_to_deliver)
          if (execution_error_get_last_error () != SIM_ERR_NONE)
            {
              reason = sim_stopped;
          if (execution_error_get_last_error () != SIM_ERR_NONE)
            {
              reason = sim_stopped;
-             siggnal = TARGET_SIGNAL_SEGV;
+             siggnal = GDB_SIGNAL_SEGV;
              break;
            }
 
              break;
            }
 
@@ -808,11 +792,12 @@ 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 *args;
+  char *p = strdup (cmd);
 
 
-  char *p = cmd;
+  check_desc (sd);
 
   /* Skip leading whitespace.  */
   while (isspace (*p))
 
   /* Skip leading whitespace.  */
   while (isspace (*p))
@@ -825,7 +810,6 @@ sim_do_command (SIM_DESC sd, char *cmd)
 
   /* Null-terminate the command word, and record the start of any
      further arguments.  */
 
   /* Null-terminate the command word, and record the start of any
      further arguments.  */
-  char *args;
   if (*p)
     {
       *p = '\0';
   if (*p)
     {
       *p = '\0';
@@ -861,10 +845,12 @@ 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");
+
+  free (p);
 }
 
 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;
 }
This page took 0.025968 seconds and 4 git commands to generate.