From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13080 invoked by alias); 2 Jul 2010 23:07:13 -0000 Received: (qmail 13072 invoked by uid 22791); 2 Jul 2010 23:07:13 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 02 Jul 2010 23:07:03 +0000 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o62N72cu012506 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 2 Jul 2010 19:07:02 -0400 Received: from mesquite.lan (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o62N71le011025 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Fri, 2 Jul 2010 19:07:01 -0400 Date: Fri, 02 Jul 2010 23:07:00 -0000 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [RFC] remote-sim.c: Make sim memory accessible after a "load" Message-ID: <20100702160701.4527de98@mesquite.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-07/txt/msg00060.txt.bz2 The patch below depends upon: http://sourceware.org/ml/gdb-patches/2010-07/msg00059.html It makes sim memory accessible immediately after a "load". For more discussion of this matter, see: http://sourceware.org/ml/gdb-patches/2010-06/msg00656.html I've tested it (along with its dependency) against the following simulators: arm, frv, mips, powerpc, and v850. No regressions found for any of these simulators. Comments? Kevin * remote-sim.c (gdbsim_xfer_inferior_memory): Replace `target_has_execution' check with `to_has_memory' check. (gdbsim_has_all_memory, gdbsim_has_memory): New functions. (init_gdbsym_ops): Initialize relevant fields of `gdbsim_ops' with `gdbsim_has_all_memory' and `gdbsim_has_memory'. --- ../../../sourceware-multi-1/src/gdb/remote-sim.c 2010-07-02 13:00:24.000000000 -0700 +++ remote-sim.c 2010-07-01 17:15:30.000000000 -0700 @@ -903,10 +903,10 @@ gdbsim_xfer_inferior_memory (CORE_ADDR m struct sim_inferior_data *sim_data = get_sim_inferior_data (SIM_INSTANCE_NOT_NEEDED); - /* If no program is running yet, then ignore the simulator for - memory. Pass the request down to the next target, hopefully - an exec file. */ - if (!target_has_execution) + /* If this target doesn't have memory yet, return 0 causing the + request to be passed to a lower target, hopefully an exec + file. */ + if (!target->to_has_memory (target)) return 0; if (!sim_data->program_loaded) @@ -1047,6 +1047,32 @@ gdbsim_pid_to_str (struct target_ops *op return normal_pid_to_str (ptid); } +/* Simulator memory may be accessed after the program has been loaded. */ + +int +gdbsim_has_all_memory (struct target_ops *ops) +{ + struct sim_inferior_data *sim_data + = get_sim_inferior_data (SIM_INSTANCE_NOT_NEEDED); + + if (!sim_data->program_loaded) + return 0; + + return 1; +} + +int +gdbsim_has_memory (struct target_ops *ops) +{ + struct sim_inferior_data *sim_data + = get_sim_inferior_data (SIM_INSTANCE_NOT_NEEDED); + + if (!sim_data->program_loaded) + return 0; + + return 1; +} + /* Define the target subroutine names */ struct target_ops gdbsim_ops; @@ -1077,8 +1103,8 @@ init_gdbsim_ops (void) gdbsim_ops.to_thread_alive = gdbsim_thread_alive; gdbsim_ops.to_pid_to_str = gdbsim_pid_to_str; gdbsim_ops.to_stratum = process_stratum; - gdbsim_ops.to_has_all_memory = default_child_has_all_memory; - gdbsim_ops.to_has_memory = default_child_has_memory; + gdbsim_ops.to_has_all_memory = gdbsim_has_all_memory; + gdbsim_ops.to_has_memory = gdbsim_has_memory; gdbsim_ops.to_has_stack = default_child_has_stack; gdbsim_ops.to_has_registers = default_child_has_registers; gdbsim_ops.to_has_execution = default_child_has_execution;