sim: overhaul alignment settings management
[deliverable/binutils-gdb.git] / sim / avr / interp.c
index deaf711e1040b7db2178847c11216b13627a1f69..1626fadaa973cedf5a6e1cda2ec2d5c3a9f3ce2a 100644 (file)
    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"
 
-#ifdef HAVE_STRING_H
 #include <string.h>
-#endif
+
 #include "bfd.h"
 #include "libiberty.h"
-#include "gdb/remote-sim.h"
+#include "sim/sim.h"
 
 #include "sim-main.h"
 #include "sim-base.h"
@@ -727,13 +727,13 @@ decode (unsigned int pc)
 static void
 do_call (SIM_CPU *cpu, unsigned int npc)
 {
-  SIM_DESC sd = CPU_STATE (cpu);
+  const struct avr_sim_state *state = AVR_SIM_STATE (CPU_STATE (cpu));
   unsigned int sp = read_word (REG_SP);
 
   /* Big endian!  */
   sram[sp--] = cpu->pc;
   sram[sp--] = cpu->pc >> 8;
-  if (sd->avr_pc22)
+  if (state->avr_pc22)
     {
       sram[sp--] = cpu->pc >> 16;
       cpu->cycles++;
@@ -893,9 +893,9 @@ step_once (SIM_CPU *cpu)
        /* Fall through */
       case OP_ret:
        {
-         SIM_DESC sd = CPU_STATE (cpu);
+         const struct avr_sim_state *state = AVR_SIM_STATE (CPU_STATE (cpu));
          unsigned int sp = read_word (REG_SP);
-         if (sd->avr_pc22)
+         if (state->avr_pc22)
            {
              cpu->pc = sram[++sp] << 16;
              cpu->cycles++;
@@ -1681,23 +1681,19 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
          struct bfd *abfd, char * const *argv)
 {
   int i;
-  SIM_DESC sd = sim_state_alloc (kind, cb);
+  SIM_DESC sd = sim_state_alloc_extra (kind, cb, sizeof (struct avr_sim_state));
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
+  /* Set default options before parsing user options.  */
+  current_alignment = STRICT_ALIGNMENT;
+
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
+  if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     {
       free_state (sd);
       return 0;
     }
 
-  {
-    /* XXX: Only first core gets profiled ?  */
-    SIM_CPU *cpu = STATE_CPU (sd, 0);
-    STATE_WATCHPOINTS (sd)->pc = &cpu->pc;
-    STATE_WATCHPOINTS (sd)->sizeof_pc = sizeof (cpu->pc);
-  }
-
   if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
     {
       free_state (sd);
@@ -1759,6 +1755,7 @@ SIM_RC
 sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
                     char * const *argv, char * const *env)
 {
+  struct avr_sim_state *state = AVR_SIM_STATE (sd);
   SIM_CPU *cpu = STATE_CPU (sd, 0);
   SIM_ADDR addr;
 
@@ -1770,7 +1767,7 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
   sim_pc_set (cpu, addr);
 
   if (abfd != NULL)
-    sd->avr_pc22 = (bfd_get_mach (abfd) >= bfd_mach_avr6);
+    state->avr_pc22 = (bfd_get_mach (abfd) >= bfd_mach_avr6);
 
   return SIM_RC_OK;
 }
This page took 0.032292 seconds and 4 git commands to generate.