From patchwork Mon Jan 4 05:34:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 10206 X-Patchwork-Delegate: vapier@gentoo.org Received: (qmail 113914 invoked by alias); 4 Jan 2016 05:34:40 -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 113895 invoked by uid 89); 4 Jan 2016 05:34:39 -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=Allow, 1916, Hx-languages-length:2851, cio 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; Mon, 04 Jan 2016 05:34:37 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id B6A653405C3; Mon, 4 Jan 2016 05:34:34 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Cc: nickc@redhat.com Subject: [PATCH/RFC] sim: msp430: drop duplicate sim_load_file call Date: Mon, 4 Jan 2016 00:34:29 -0500 Message-Id: <1451885669-18746-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes There's no need, or desire, to call sim_load_file from sim_open. The higher levels (gdb/run) take care of calling sim_load for us already. Nick: Was there a reason for this logic that I'm missing ? --- sim/msp430/ChangeLog | 7 +++++++ sim/msp430/msp430-sim.c | 33 +++++++-------------------------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/sim/msp430/ChangeLog b/sim/msp430/ChangeLog index 73d89c3..93d04af 100644 --- a/sim/msp430/ChangeLog +++ b/sim/msp430/ChangeLog @@ -1,3 +1,10 @@ +2016-01-04 Mike Frysinger + + * msp430-sim.c (loader_write_mem): Delete. + (lookup_symbol): Return -1 when abfd is NULL. + (sim_open): Delete prog_bfd variable. Delete call to sim_load_file. + Delete prog_bfd check. + 2016-01-03 Mike Frysinger * config.in, configure: Regenerate. diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c index 0a76cd9..5e77de4 100644 --- a/sim/msp430/msp430-sim.c +++ b/sim/msp430/msp430-sim.c @@ -33,16 +33,6 @@ #include "dis-asm.h" #include "targ-vals.h" -static int -loader_write_mem (SIM_DESC sd, - SIM_ADDR taddr, - const unsigned char *buf, - int bytes) -{ - SIM_CPU *cpu = MSP430_CPU (sd); - return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes); -} - static sim_cia msp430_pc_fetch (SIM_CPU *cpu) { @@ -63,6 +53,9 @@ lookup_symbol (SIM_DESC sd, const char *name) long number_of_symbols = STATE_NUM_SYMBOLS (sd); long i; + if (abfd == NULL) + return -1; + if (symbol_table == NULL) { long storage_needed; @@ -149,7 +142,6 @@ sim_open (SIM_OPEN_KIND kind, { SIM_DESC sd = sim_state_alloc (kind, callback); char c; - struct bfd *prog_bfd; /* Initialise the simulator. */ @@ -199,14 +191,6 @@ sim_open (SIM_OPEN_KIND kind, return 0; } - prog_bfd = sim_load_file (sd, argv[0], callback, - "the program", - STATE_PROG_BFD (sd), - 0 /* verbose */, - 1 /* use LMA instead of VMA */, - loader_write_mem); - /* Allow prog_bfd to be NULL - this is needed by the GDB testsuite. */ - /* Establish any remaining configuration options. */ if (sim_config (sd) != SIM_RC_OK) { @@ -224,13 +208,10 @@ sim_open (SIM_OPEN_KIND kind, assert (MAX_NR_PROCESSORS == 1); msp430_initialize_cpu (sd, MSP430_CPU (sd)); - if (prog_bfd != NULL) - { - MSP430_CPU (sd)->state.cio_breakpoint = lookup_symbol (sd, "C$$IO$$"); - MSP430_CPU (sd)->state.cio_buffer = lookup_symbol (sd, "__CIOBUF__"); - if (MSP430_CPU (sd)->state.cio_buffer == -1) - MSP430_CPU (sd)->state.cio_buffer = lookup_symbol (sd, "_CIOBUF_"); - } + MSP430_CPU (sd)->state.cio_breakpoint = lookup_symbol (sd, "C$$IO$$"); + MSP430_CPU (sd)->state.cio_buffer = lookup_symbol (sd, "__CIOBUF__"); + if (MSP430_CPU (sd)->state.cio_buffer == -1) + MSP430_CPU (sd)->state.cio_buffer = lookup_symbol (sd, "_CIOBUF_"); return sd; }