Require always-non-stop for multi-target resumptions
[deliverable/binutils-gdb.git] / sim / rl78 / gdb-if.c
index e7c127797d9f3404e25755f589e01e2355f7b3e5..ba07038c009d581f1c54fe874cb65c04647be29d 100644 (file)
@@ -1,6 +1,6 @@
 /* gdb-if.c -- sim interface to GDB.
 
-Copyright (C) 2011-2012 Free Software Foundation, Inc.
+Copyright (C) 2011-2020 Free Software Foundation, Inc.
 Contributed by Red Hat, Inc.
 
 This file is part of the GNU simulators.
@@ -55,8 +55,6 @@ static struct sim_state the_minisim = {
 
 static int open;
 
-static unsigned char hw_breakpoints[MEM_SIZE/8];
-
 static struct host_callback_struct *host_callbacks;
 
 /* Open an instance of the sim.  For this sim, only one instance
@@ -66,7 +64,7 @@ static struct host_callback_struct *host_callbacks;
 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)
     fprintf (stderr, "rl78 minisim: re-opened sim\n");
@@ -88,6 +86,37 @@ sim_open (SIM_OPEN_KIND kind,
 
   sim_disasm_init (abfd);
   open = 1;
+
+  while (argv != NULL && *argv != NULL)
+    {
+      if (strcmp (*argv, "g10") == 0 || strcmp (*argv, "-Mg10") == 0)
+       {
+         fprintf (stderr, "rl78 g10 support enabled.\n");
+         rl78_g10_mode = 1;
+         g13_multiply = 0;
+         g14_multiply = 0;
+         mem_set_mirror (0, 0xf8000, 4096);
+         break;
+       }
+      if (strcmp (*argv, "g13") == 0 || strcmp (*argv, "-Mg13") == 0)
+       {
+         fprintf (stderr, "rl78 g13 support enabled.\n");
+         rl78_g10_mode = 0;
+         g13_multiply = 1;
+         g14_multiply = 0;
+         break;
+       }
+      if (strcmp (*argv, "g14") == 0 || strcmp (*argv, "-Mg14") == 0)
+       {
+         fprintf (stderr, "rl78 g14 support enabled.\n");
+         rl78_g10_mode = 0;
+         g13_multiply = 0;
+         g14_multiply = 1;
+         break;
+       }
+      argv++;
+    }
+
   return &the_minisim;
 }
 
@@ -142,7 +171,7 @@ open_objfile (const char *filename)
 /* Load a program.  */
 
 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);
 
@@ -159,7 +188,8 @@ sim_load (SIM_DESC sd, char *prog, struct bfd *abfd, int from_tty)
 /* Create inferior.  */
 
 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);
 
@@ -341,7 +371,15 @@ sim_store_register (SIM_DESC sd, int regno, unsigned char *buf, int length)
   val = get_le (buf, length);
 
   if (regno == sim_rl78_pc_regnum)
-    pc = val;
+    {
+      pc = val;
+
+      /* The rl78 program counter is 20 bits wide.  Ensure that GDB
+         hasn't picked up any stray bits.  This has occurred when performing
+        a GDB "return" command in which the return address is obtained
+        from a 32-bit container on the stack.  */
+      assert ((pc & ~0x0fffff) == 0);
+    }
   else
     memory[reg_addr (regno)] = val;
   return size;
@@ -371,30 +409,30 @@ rl78_signal_to_target (int sig)
   switch (sig)
     {
     case 4:
-      return TARGET_SIGNAL_ILL;
+      return GDB_SIGNAL_ILL;
 
     case 5:
-      return TARGET_SIGNAL_TRAP;
+      return GDB_SIGNAL_TRAP;
 
     case 10:
-      return TARGET_SIGNAL_BUS;
+      return GDB_SIGNAL_BUS;
 
     case 11:
-      return TARGET_SIGNAL_SEGV;
+      return GDB_SIGNAL_SEGV;
 
     case 24:
-      return TARGET_SIGNAL_XCPU;
+      return GDB_SIGNAL_XCPU;
       break;
 
     case 2:
-      return TARGET_SIGNAL_INT;
+      return GDB_SIGNAL_INT;
 
     case 8:
-      return TARGET_SIGNAL_FPE;
+      return GDB_SIGNAL_FPE;
       break;
 
     case 6:
-      return TARGET_SIGNAL_ABRT;
+      return GDB_SIGNAL_ABRT;
     }
 
   return 0;
@@ -410,7 +448,7 @@ handle_step (int rc)
   if (RL78_STEPPED (rc) || RL78_HIT_BREAK (rc))
     {
       reason = sim_stopped;
-      siggnal = TARGET_SIGNAL_TRAP;
+      siggnal = GDB_SIGNAL_TRAP;
     }
   else if (RL78_STOPPED (rc))
     {
@@ -452,17 +490,10 @@ sim_resume (SIM_DESC sd, int step, int sig_to_deliver)
        {
          stop = 0;
          reason = sim_stopped;
-         siggnal = TARGET_SIGNAL_INT;
+         siggnal = GDB_SIGNAL_INT;
          break;
        }
 
-      if (hw_breakpoints[pc >> 3]
-          && (hw_breakpoints[pc >> 3] & (1 << (pc & 0x7))))
-       {
-         reason = sim_stopped;
-         siggnal = TARGET_SIGNAL_TRAP;
-         break;
-       }
       rc = setjmp (decode_jmp_buf);
       if (rc == 0)
        rc = decode_opcode ();
@@ -500,9 +531,10 @@ sim_stop_reason (SIM_DESC sd, enum sim_stop *reason_p, int *sigrc_p)
    command.  */
 
 void
-sim_do_command (SIM_DESC sd, char *cmd)
+sim_do_command (SIM_DESC sd, const char *cmd)
 {
-  char *args;
+  const char *args;
+  char *p = strdup (cmd);
 
   check_desc (sd);
 
@@ -513,8 +545,6 @@ sim_do_command (SIM_DESC sd, char *cmd)
     }
   else
     {
-      char *p = cmd;
-
       /* Skip leading whitespace.  */
       while (isspace (*p))
        p++;
@@ -562,12 +592,14 @@ sim_do_command (SIM_DESC sd, char *cmd)
   else
     printf ("The 'sim' command expects either 'trace' or 'verbose'"
            " as a subcommand.\n");
+
+  free (p);
 }
 
 /* Stub for command completion.  */
 
 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;
 }
This page took 0.026425 seconds and 4 git commands to generate.