From patchwork Sat Dec 26 12:23:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 10137 X-Patchwork-Delegate: vapier@gentoo.org Received: (qmail 48296 invoked by alias); 26 Dec 2015 12:23:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 48281 invoked by uid 89); 26 Dec 2015 12:23:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=877, 7, 8777, 21315, 2015-12-26 X-HELO: smtp.gentoo.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 26 Dec 2015 12:23:38 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id B40C63405BB for ; Sat, 26 Dec 2015 12:23:36 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH] sim: standardize sim_create_inferior handling of argv a bit more [committed] Date: Sat, 26 Dec 2015 07:23:35 -0500 Message-Id: <1451132615-17271-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes 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. --- sim/aarch64/ChangeLog | 4 ++++ sim/aarch64/interp.c | 9 +++++---- sim/bfin/ChangeLog | 4 ++++ sim/bfin/interp.c | 9 +++++---- sim/cris/ChangeLog | 5 +++++ sim/cris/sim-if.c | 14 +++++++++----- sim/frv/ChangeLog | 4 ++++ sim/frv/sim-if.c | 13 +++++++++---- sim/ft32/ChangeLog | 4 ++++ sim/ft32/interp.c | 6 +++++- sim/iq2000/ChangeLog | 4 ++++ sim/iq2000/sim-if.c | 13 +++++++++---- sim/lm32/ChangeLog | 4 ++++ sim/lm32/sim-if.c | 13 +++++++++---- sim/m32r/ChangeLog | 4 ++++ sim/m32r/sim-if.c | 13 +++++++++---- sim/sh64/ChangeLog | 4 ++++ sim/sh64/sim-if.c | 13 +++++++++---- 18 files changed, 106 insertions(+), 34 deletions(-) diff --git a/sim/aarch64/ChangeLog b/sim/aarch64/ChangeLog index 608a056..cd0cd41 100644 --- a/sim/aarch64/ChangeLog +++ b/sim/aarch64/ChangeLog @@ -1,3 +1,7 @@ +2015-12-26 Mike Frysinger + + * interp.c (sim_create_inferior): Update comment and argv check. + 2015-12-14 Nick Clifton * simulator.c (system_get): New function. Provides read diff --git a/sim/aarch64/interp.c b/sim/aarch64/interp.c index 46ff994..d971039 100644 --- a/sim/aarch64/interp.c +++ b/sim/aarch64/interp.c @@ -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); diff --git a/sim/bfin/ChangeLog b/sim/bfin/ChangeLog index 744f5eb..6717fcc 100644 --- a/sim/bfin/ChangeLog +++ b/sim/bfin/ChangeLog @@ -1,3 +1,7 @@ +2015-12-26 Mike Frysinger + + * interp.c (sim_create_inferior): Update comment and argv check. + 2015-12-25 Mike Frysinger * Makefile.in (SIM_OBJS): Delete sim-model.o. diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c index 5ba204b..2da70b5 100644 --- a/sim/bfin/interp.c +++ b/sim/bfin/interp.c @@ -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); diff --git a/sim/cris/ChangeLog b/sim/cris/ChangeLog index 3768768..e7f4cc6 100644 --- a/sim/cris/ChangeLog +++ b/sim/cris/ChangeLog @@ -1,3 +1,8 @@ +2015-12-26 Mike Frysinger + + * sim-if.c (sim_create_inferior): Delete old comment and set up + STATE_PROG_ARGV. + 2015-12-25 Mike Frysinger * configure.ac (SIM_AC_OPTION_HARDWARE): Change default to yes and diff --git a/sim/cris/sim-if.c b/sim/cris/sim-if.c index 3e04655..97307f8 100644 --- a/sim/cris/sim-if.c +++ b/sim/cris/sim-if.c @@ -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; } diff --git a/sim/frv/ChangeLog b/sim/frv/ChangeLog index 549ff72..936bbf2 100644 --- a/sim/frv/ChangeLog +++ b/sim/frv/ChangeLog @@ -1,3 +1,7 @@ +2015-12-26 Mike Frysinger + + * sim-if.c (sim_create_inferior): Replace old #if 0 code with dupargv. + 2015-12-25 Mike Frysinger * devices.c: Delete file. diff --git a/sim/frv/sim-if.c b/sim/frv/sim-if.c index f908778..f530763 100644 --- a/sim/frv/sim-if.c +++ b/sim/frv/sim-if.c @@ -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; } diff --git a/sim/ft32/ChangeLog b/sim/ft32/ChangeLog index a306ffe..b246467 100644 --- a/sim/ft32/ChangeLog +++ b/sim/ft32/ChangeLog @@ -1,3 +1,7 @@ +2015-12-26 Mike Frysinger + + * interp.c (sim_create_inferior): Update comment and argv check. + 2015-11-15 Mike Frysinger * Makefile.in (SIM_OBJS): Delete sim-reason.o, sim-reg.o, and diff --git a/sim/ft32/interp.c b/sim/ft32/interp.c index e2762b8..63ce77b 100644 --- a/sim/ft32/interp.c +++ b/sim/ft32/interp.c @@ -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); diff --git a/sim/iq2000/ChangeLog b/sim/iq2000/ChangeLog index 4ee5839..67529e4 100644 --- a/sim/iq2000/ChangeLog +++ b/sim/iq2000/ChangeLog @@ -1,3 +1,7 @@ +2015-12-26 Mike Frysinger + + * sim-if.c (sim_create_inferior): Replace old #if 0 code with dupargv. + 2015-12-25 Mike Frysinger * Makefile.in (SIM_OBJS): Delete sim-model.o. diff --git a/sim/iq2000/sim-if.c b/sim/iq2000/sim-if.c index a72f5c0..fd0e3ba 100644 --- a/sim/iq2000/sim-if.c +++ b/sim/iq2000/sim-if.c @@ -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; } diff --git a/sim/lm32/ChangeLog b/sim/lm32/ChangeLog index b94ef40..a3da560 100644 --- a/sim/lm32/ChangeLog +++ b/sim/lm32/ChangeLog @@ -1,3 +1,7 @@ +2015-12-26 Mike Frysinger + + * sim-if.c (sim_create_inferior): Replace old #if 0 code with dupargv. + 2015-12-25 Mike Frysinger * Makefile.in (SIM_OBJS): Delete sim-model.o. diff --git a/sim/lm32/sim-if.c b/sim/lm32/sim-if.c index 3b0575a..eb13363 100644 --- a/sim/lm32/sim-if.c +++ b/sim/lm32/sim-if.c @@ -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; } diff --git a/sim/m32r/ChangeLog b/sim/m32r/ChangeLog index 09d2c05..c492bd6 100644 --- a/sim/m32r/ChangeLog +++ b/sim/m32r/ChangeLog @@ -1,3 +1,7 @@ +2015-12-26 Mike Frysinger + + * sim-if.c (sim_create_inferior): Replace old #if 0 code with dupargv. + 2015-12-25 Mike Frysinger * configure.ac (SIM_AC_OPTION_HARDWARE): Add m32r_cache & m32r_uart. diff --git a/sim/m32r/sim-if.c b/sim/m32r/sim-if.c index 639976d..043c618 100644 --- a/sim/m32r/sim-if.c +++ b/sim/m32r/sim-if.c @@ -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; } diff --git a/sim/sh64/ChangeLog b/sim/sh64/ChangeLog index 9a4d1f5..8a2b58b 100644 --- a/sim/sh64/ChangeLog +++ b/sim/sh64/ChangeLog @@ -1,3 +1,7 @@ +2015-12-26 Mike Frysinger + + * sim-if.c (sim_create_inferior): Replace old #if 0 code with dupargv. + 2015-12-25 Mike Frysinger * Makefile.in (SIM_OBJS): Delete sim-model.o. diff --git a/sim/sh64/sim-if.c b/sim/sh64/sim-if.c index 29e0936..9cd6df8 100644 --- a/sim/sh64/sim-if.c +++ b/sim/sh64/sim-if.c @@ -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; }