+2015-12-26  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sim_create_inferior): Update comment and argv check.
+
 2015-12-14  Nick Clifton  <nickc@redhat.com>
 
        * simulator.c (system_get): New function.  Provides read
 
   aarch64_set_next_PC (cpu, addr);
   aarch64_update_PC (cpu);
 
-  /* Standalone mode (ie aarch64-elf-run) will take care of the argv
-     for us in sim_open() -> sim_parse_args().  But in debug mode (i.e.
-     'target sim' with `aarch64-...-gdb`), we need to handle it.  */
-  if (STATE_OPEN_KIND (sd) == SIM_OPEN_DEBUG)
+  /* Standalone mode (i.e. `run`) will take care of the argv for us in
+     sim_open() -> sim_parse_args().  But in debug mode (i.e. 'target sim'
+     with `gdb`), we need to handle it because the user can change the
+     argv on the fly via gdb's 'run'.  */
+  if (STATE_PROG_ARGV (sd) != argv)
     {
       freeargv (STATE_PROG_ARGV (sd));
       STATE_PROG_ARGV (sd) = dupargv (argv);
 
+2015-12-26  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sim_create_inferior): Update comment and argv check.
+
 2015-12-25  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in (SIM_OBJS): Delete sim-model.o.
 
     addr = 0;
   sim_pc_set (cpu, addr);
 
-  /* Standalone mode (i.e. `bfin-...-run`) will take care of the argv
-     for us in sim_open() -> sim_parse_args().  But in debug mode (i.e.
-     'target sim' with `bfin-...-gdb`), we need to handle it.  */
-  if (STATE_OPEN_KIND (sd) == SIM_OPEN_DEBUG)
+  /* Standalone mode (i.e. `run`) will take care of the argv for us in
+     sim_open() -> sim_parse_args().  But in debug mode (i.e. 'target sim'
+     with `gdb`), we need to handle it because the user can change the
+     argv on the fly via gdb's 'run'.  */
+  if (STATE_PROG_ARGV (sd) != argv)
     {
       freeargv (STATE_PROG_ARGV (sd));
       STATE_PROG_ARGV (sd) = dupargv (argv);
 
+2015-12-26  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-if.c (sim_create_inferior): Delete old comment and set up
+       STATE_PROG_ARGV.
+
 2015-12-25  Mike Frysinger  <vapier@gentoo.org>
 
        * configure.ac (SIM_AC_OPTION_HARDWARE): Change default to yes and
 
     addr = 0;
   sim_pc_set (current_cpu, addr);
 
-  /* Other simulators have #if 0:d code that says
-      STATE_ARGV (sd) = sim_copy_argv (argv);
-      STATE_ENVP (sd) = sim_copy_argv (envp);
-     Enabling that gives you not-found link-errors for sim_copy_argv.
-     FIXME: Do archaeology to find out more.  */
+  /* Standalone mode (i.e. `run`) will take care of the argv for us in
+     sim_open() -> sim_parse_args().  But in debug mode (i.e. 'target sim'
+     with `gdb`), we need to handle it because the user can change the
+     argv on the fly via gdb's 'run'.  */
+  if (STATE_PROG_ARGV (sd) != argv)
+    {
+      freeargv (STATE_PROG_ARGV (sd));
+      STATE_PROG_ARGV (sd) = dupargv (argv);
+    }
 
   return SIM_RC_OK;
 }
 
+2015-12-26  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-if.c (sim_create_inferior): Replace old #if 0 code with dupargv.
+
 2015-12-25  Mike Frysinger  <vapier@gentoo.org>
 
        * devices.c: Delete file.
 
     addr = 0;
   sim_pc_set (current_cpu, addr);
 
-#if 0
-  STATE_ARGV (sd) = sim_copy_argv (argv);
-  STATE_ENVP (sd) = sim_copy_argv (envp);
-#endif
+  /* Standalone mode (i.e. `run`) will take care of the argv for us in
+     sim_open() -> sim_parse_args().  But in debug mode (i.e. 'target sim'
+     with `gdb`), we need to handle it because the user can change the
+     argv on the fly via gdb's 'run'.  */
+  if (STATE_PROG_ARGV (sd) != argv)
+    {
+      freeargv (STATE_PROG_ARGV (sd));
+      STATE_PROG_ARGV (sd) = dupargv (argv);
+    }
 
   return SIM_RC_OK;
 }
 
+2015-12-26  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sim_create_inferior): Update comment and argv check.
+
 2015-11-15  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in (SIM_OBJS): Delete sim-reason.o, sim-reg.o, and
 
   else
     addr = 0;
 
-  if (STATE_OPEN_KIND (sd) == SIM_OPEN_DEBUG)
+  /* Standalone mode (i.e. `run`) will take care of the argv for us in
+     sim_open() -> sim_parse_args().  But in debug mode (i.e. 'target sim'
+     with `gdb`), we need to handle it because the user can change the
+     argv on the fly via gdb's 'run'.  */
+  if (STATE_PROG_ARGV (sd) != argv)
     {
       freeargv (STATE_PROG_ARGV (sd));
       STATE_PROG_ARGV (sd) = dupargv (argv);
 
+2015-12-26  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-if.c (sim_create_inferior): Replace old #if 0 code with dupargv.
+
 2015-12-25  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in (SIM_OBJS): Delete sim-model.o.
 
     addr = CPU2INSN(0);
   sim_pc_set (current_cpu, addr);
 
-#if 0
-  STATE_ARGV (sd) = sim_copy_argv (argv);
-  STATE_ENVP (sd) = sim_copy_argv (envp);
-#endif
+  /* Standalone mode (i.e. `run`) will take care of the argv for us in
+     sim_open() -> sim_parse_args().  But in debug mode (i.e. 'target sim'
+     with `gdb`), we need to handle it because the user can change the
+     argv on the fly via gdb's 'run'.  */
+  if (STATE_PROG_ARGV (sd) != argv)
+    {
+      freeargv (STATE_PROG_ARGV (sd));
+      STATE_PROG_ARGV (sd) = dupargv (argv);
+    }
 
   return SIM_RC_OK;
 }
 
+2015-12-26  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-if.c (sim_create_inferior): Replace old #if 0 code with dupargv.
+
 2015-12-25  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in (SIM_OBJS): Delete sim-model.o.
 
     addr = 0;
   sim_pc_set (current_cpu, addr);
 
-#if 0
-  STATE_ARGV (sd) = sim_copy_argv (argv);
-  STATE_ENVP (sd) = sim_copy_argv (envp);
-#endif
+  /* Standalone mode (i.e. `run`) will take care of the argv for us in
+     sim_open() -> sim_parse_args().  But in debug mode (i.e. 'target sim'
+     with `gdb`), we need to handle it because the user can change the
+     argv on the fly via gdb's 'run'.  */
+  if (STATE_PROG_ARGV (sd) != argv)
+    {
+      freeargv (STATE_PROG_ARGV (sd));
+      STATE_PROG_ARGV (sd) = dupargv (argv);
+    }
 
   return SIM_RC_OK;
 }
 
+2015-12-26  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-if.c (sim_create_inferior): Replace old #if 0 code with dupargv.
+
 2015-12-25  Mike Frysinger  <vapier@gentoo.org>
 
        * configure.ac (SIM_AC_OPTION_HARDWARE): Add m32r_cache & m32r_uart.
 
                     m32r_decode_gdb_ctrl_regnum(SPU_REGNUM), 0x1f00000);
 #endif
 
-#if 0
-  STATE_ARGV (sd) = sim_copy_argv (argv);
-  STATE_ENVP (sd) = sim_copy_argv (envp);
-#endif
+  /* Standalone mode (i.e. `run`) will take care of the argv for us in
+     sim_open() -> sim_parse_args().  But in debug mode (i.e. 'target sim'
+     with `gdb`), we need to handle it because the user can change the
+     argv on the fly via gdb's 'run'.  */
+  if (STATE_PROG_ARGV (sd) != argv)
+    {
+      freeargv (STATE_PROG_ARGV (sd));
+      STATE_PROG_ARGV (sd) = dupargv (argv);
+    }
 
   return SIM_RC_OK;
 }
 
+2015-12-26  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-if.c (sim_create_inferior): Replace old #if 0 code with dupargv.
+
 2015-12-25  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in (SIM_OBJS): Delete sim-model.o.
 
     addr = 0;
   sim_pc_set (current_cpu, addr);
 
-#if 0
-  STATE_ARGV (sd) = sim_copy_argv (argv);
-  STATE_ENVP (sd) = sim_copy_argv (envp);
-#endif
+  /* Standalone mode (i.e. `run`) will take care of the argv for us in
+     sim_open() -> sim_parse_args().  But in debug mode (i.e. 'target sim'
+     with `gdb`), we need to handle it because the user can change the
+     argv on the fly via gdb's 'run'.  */
+  if (STATE_PROG_ARGV (sd) != argv)
+    {
+      freeargv (STATE_PROG_ARGV (sd));
+      STATE_PROG_ARGV (sd) = dupargv (argv);
+    }
 
   return SIM_RC_OK;
 }