From patchwork Sat Dec 26 13:32:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 10138 X-Patchwork-Delegate: vapier@gentoo.org Received: (qmail 128979 invoked by alias); 26 Dec 2015 13:32: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 128965 invoked by uid 89); 26 Dec 2015 13:32:42 -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=strlen, 8458, epp, csp 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 13:32:41 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 0EF4334082B for ; Sat, 26 Dec 2015 13:32:38 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH] sim: cris: do not pass cpu when writing memory during init [committed] Date: Sat, 26 Dec 2015 08:32:36 -0500 Message-Id: <1451136756-30986-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes The point of passing down the cpu to core reads/writes is to signal which cpu is making the access. For system accesses (such as internal memory initialization), passing the cpu down doesn't make sense, and in the case of early init like cris, can cause crashes. Since the cpu isn't fully set up at this point, if the core code tries to access some fields (like the PC reg), it'll crash. While cris shouldn't be doing this setup here (it should be in the inferior stage), we'll deal with that later. --- sim/cris/ChangeLog | 5 +++++ sim/cris/sim-if.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/sim/cris/ChangeLog b/sim/cris/ChangeLog index e7f4cc6..82cffd3 100644 --- a/sim/cris/ChangeLog +++ b/sim/cris/ChangeLog @@ -1,5 +1,10 @@ 2015-12-26 Mike Frysinger + * sim-if.c (sim_open): Delete cpu variable. Pass NULL/NULL_CIA to + sim_core_write_buffer. + +2015-12-26 Mike Frysinger + * sim-if.c (sim_create_inferior): Delete old comment and set up STATE_PROG_ARGV. diff --git a/sim/cris/sim-if.c b/sim/cris/sim-if.c index 97307f8..72c0540 100644 --- a/sim/cris/sim-if.c +++ b/sim/cris/sim-if.c @@ -845,8 +845,6 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, int i; char **prog_argv = STATE_PROG_ARGV (sd); int my_argc = 0; - /* All CPU:s have the same memory map, apparently. */ - SIM_CPU *cpu = STATE_CPU (sd, 0); USI csp; bfd_byte buf[4]; @@ -910,7 +908,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, USI data_ = data; \ USI addr_ = addr; \ bfd_putl32 (data_, buf); \ - if (sim_core_write_buffer (sd, cpu, 0, buf, addr_, 4) != 4) \ + if (sim_core_write_buffer (sd, NULL, NULL_CIA, buf, addr_, 4) != 4)\ goto abandon_chip; \ } \ while (0) @@ -922,7 +920,8 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, { size_t strln = strlen (prog_argv[i]) + 1; - if (sim_core_write_buffer (sd, cpu, 0, prog_argv[i], epp, strln) + if (sim_core_write_buffer (sd, NULL, NULL_CIA, prog_argv[i], epp, + strln) != strln) goto abandon_chip; @@ -937,7 +936,8 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, { unsigned int strln = strlen (my_environ[i]) + 1; - if (sim_core_write_buffer (sd, cpu, 0, my_environ[i], epp, strln) + if (sim_core_write_buffer (sd, NULL, NULL_CIA, my_environ[i], epp, + strln) != strln) goto abandon_chip;