]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: standardize sim_create_inferior handling of argv a bit more
authorMike Frysinger <vapier@gentoo.org>
Sat, 26 Dec 2015 12:05:41 +0000 (07:05 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 26 Dec 2015 12:19:07 +0000 (07:19 -0500)
For targets that process argv in sim_create_inferior, improve the code:
- provide more details in the comment
- make the check for when to re-init more robust
- clean out legacy sim_copy_argv code

This will be cleaned up more in the future when we have a common inferior
creation function, but at least help new ports get it right until then.

18 files changed:
sim/aarch64/ChangeLog
sim/aarch64/interp.c
sim/bfin/ChangeLog
sim/bfin/interp.c
sim/cris/ChangeLog
sim/cris/sim-if.c
sim/frv/ChangeLog
sim/frv/sim-if.c
sim/ft32/ChangeLog
sim/ft32/interp.c
sim/iq2000/ChangeLog
sim/iq2000/sim-if.c
sim/lm32/ChangeLog
sim/lm32/sim-if.c
sim/m32r/ChangeLog
sim/m32r/sim-if.c
sim/sh64/ChangeLog
sim/sh64/sim-if.c

index 608a056da9e7e21aa99e14e1339258cfa8a46945..cd0cd41189dfad88f6f15603659afa8fac1cea7e 100644 (file)
@@ -1,3 +1,7 @@
+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
index 46ff994679c96d1279479d735a71038f0af9a57c..d9710399581e26725d5b103a610d344a879f9fa8 100644 (file)
@@ -192,10 +192,11 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd, char **argv, char **env)
   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);
index 744f5eb20003d8c87244e7a02b3184e4cab06d83..6717fcc9e09745f1fafc2a238c0dccc9c87147a3 100644 (file)
@@ -1,3 +1,7 @@
+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.
index 5ba204b0e067139df7fe1e28b9fc00ecf9786c0c..2da70b50b62bbb888cdbed268d2e28f4a76643e5 100644 (file)
@@ -1210,10 +1210,11 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
     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);
index 37687686d6ce641503770438d2dbabf66e8a2df8..e7f4cc61d7d3a8b7c27f43f8263a6780fa27f2c1 100644 (file)
@@ -1,3 +1,8 @@
+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
index 3e046559278e3b4b3bf7d5459e15cabb4fe9aa48..97307f811b79cb3ea5494135bbed9a09e507dd50 100644 (file)
@@ -1064,11 +1064,15 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
     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;
 }
index 549ff72800ef01ed4af9d8947e6c5faf6c5740e6..936bbf23203add5ba9ab96e8081f44ebdfdb18b3 100644 (file)
@@ -1,3 +1,7 @@
+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.
index f908778c6c11ce6641676da820964a1aaa52bf3b..f530763ca58dc7aea4e17ea8e1c9661a38fe6e06 100644 (file)
@@ -213,10 +213,15 @@ sim_create_inferior (sd, abfd, argv, envp)
     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;
 }
index a306ffedb0eb42edca3b1cf6db6f20ea282d1470..b24646755c1a4de191a75ef62111d91fe9a47587 100644 (file)
@@ -1,3 +1,7 @@
+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
index e2762b8e156fc732ea84345d5ed463bfe8bcbbab..63ce77b1707fb0395fe103449cb2d32dd5e489b9 100644 (file)
@@ -877,7 +877,11 @@ sim_create_inferior (SIM_DESC sd,
   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);
index 4ee58391d676325e0e45630f454cf98c197a3d87..67529e491d4c81e3f83454c3a8ff167c6e30763f 100644 (file)
@@ -1,3 +1,7 @@
+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.
index a72f5c0cb71181d06caddba768d14f96525ac6a7..fd0e3ba0578b2049de89301a3e0cd98717c20d6b 100644 (file)
@@ -172,10 +172,15 @@ sim_create_inferior (sd, abfd, argv, envp)
     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;
 }
index b94ef40ec29688008f4953e2d1e9e0ff7450e204..a3da5608b86bfb3360b5883bf1be58aa5516ad2a 100644 (file)
@@ -1,3 +1,7 @@
+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.
index 3b0575a7a627bd343a120c9029675ce92d0b736f..eb13363eec24fd514fee5fb753ee94c6999be41f 100644 (file)
@@ -263,10 +263,15 @@ sim_create_inferior (sd, abfd, argv, envp)
     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;
 }
index 09d2c053d6f8d775af70e64bcdaad5d0245a9ee1..c492bd63fd12176770c3cf24986084203fa1df1b 100644 (file)
@@ -1,3 +1,7 @@
+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.
index 639976d5e0f724df339228fa1e7c7ae7e6b4d6b0..043c618561478c9a4420604188e26b991a69b929 100644 (file)
@@ -199,10 +199,15 @@ sim_create_inferior (sd, abfd, argv, envp)
                     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;
 }
index 9a4d1f5094d5039cfde87ad03595523aa117ef34..8a2b58b13ef16d6bded27555730797a580e7803a 100644 (file)
@@ -1,3 +1,7 @@
+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.
index 29e0936ed20aaab5196fec3a4d9389cf7f9db05d..9cd6df8c0abbd2561f423151f798857575666988 100644 (file)
@@ -178,10 +178,15 @@ sim_create_inferior (sd, abfd, argv, envp)
     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;
 }