From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19206 invoked by alias); 31 Jan 2002 02:25:37 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 19151 invoked from network); 31 Jan 2002 02:25:32 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 31 Jan 2002 02:25:32 -0000 Received: from redhat.com (reddwarf.sfbay.redhat.com [205.180.231.12]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id SAA03438; Wed, 30 Jan 2002 18:25:28 -0800 (PST) Message-ID: <3C58A987.E4F85674@redhat.com> Date: Wed, 30 Jan 2002 18:25:00 -0000 From: Michael Snyder Organization: Red Hat, Inc. X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.2-2smp i686) X-Accept-Language: en MIME-Version: 1.0 To: Andrew Cagney CC: Michael Snyder , gdb-patches@sources.redhat.com Subject: Re: [RFA] New option "trust-readonly-sections" References: <200201240323.g0O3NI905339@reddwarf.cygnus.com> <3C5057E6.6070401@cygnus.com> Content-Type: multipart/mixed; boundary="------------3D1F5E9DE839129B615AAABE" X-SW-Source: 2002-01/txt/msg00792.txt.bz2 This is a multi-part message in MIME format. --------------3D1F5E9DE839129B615AAABE Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-length: 1308 Andrew Cagney wrote: > > > *************** do_xfer_memory (CORE_ADDR memaddr, char > > *** 857,862 **** > > --- 859,883 ---- > > 0. */ > > errno = 0; > > > > + if (!write && trust_readonly) > > + { > > + /* User-settable option, "trust-readonly". If true, then > > + memory from any SEC_READONLY bfd section may be read > > + directly from the bfd file. */ > > + > > + struct section_table *secp; > > + > > + for (secp = current_target.to_sections; > > + secp < current_target.to_sections_end; > > + secp++) > > + { > > + /* FIXME: take it only if it's entirely within the section. */ > > + if (memaddr >= secp->addr && memaddr + len <= secp->endaddr) > > + return xfer_memory (memaddr, myaddr, len, 0, > > + attrib, ¤t_target); > > My understanding of do_xfer_memory() is that it is allowed to do partial > transfers. Hence, here, if the data doesn't all lie in the section, it > is safe to truncate the transfer and return the number of bytes transfered. Thanks. Implementing both this suggestion and your other one about using "add_set_boolean_cmd", I have committed the patch in the new form attached below: Eli may now nag me for doco, and you may nag me for a NEWS entry. ;-) --------------3D1F5E9DE839129B615AAABE Content-Type: text/plain; charset=us-ascii; name="trust.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="trust.patch" Content-length: 3185 2002-01-15 Michael Snyder * target.c: New command, "set trust-readonly-sections on". (do_xfer_memory): Honor the suggestion to trust readonly sections by reading them from the object file instead of from the target. (initialize_targets): Register command "set trust-readonly-sections". Index: target.c =================================================================== RCS file: /cvs/src/src/gdb/target.c,v retrieving revision 1.30 diff -p -r1.30 target.c *** target.c 2002/01/09 00:36:58 1.30 --- target.c 2002/01/31 02:20:53 *************** target_write_memory (CORE_ADDR memaddr, *** 835,840 **** --- 835,842 ---- return target_xfer_memory (memaddr, myaddr, len, 1); } + static int trust_readonly = 0; + /* Move memory to or from the targets. The top target gets priority; if it cannot handle it, it is offered to the next one down, etc. *************** do_xfer_memory (CORE_ADDR memaddr, char *** 857,862 **** --- 859,882 ---- 0. */ errno = 0; + if (!write && trust_readonly) + { + /* User-settable option, "trust-readonly". If true, then + memory from any SEC_READONLY bfd section may be read + directly from the bfd file. */ + + struct section_table *secp; + + for (secp = current_target.to_sections; + secp < current_target.to_sections_end; + secp++) + { + if (memaddr >= secp->addr && memaddr < secp->endaddr) + return xfer_memory (memaddr, myaddr, len, 0, + attrib, ¤t_target); + } + } + /* The quick case is that the top target can handle the transfer. */ res = current_target.to_xfer_memory (memaddr, myaddr, len, write, attrib, ¤t_target); *************** initialize_targets (void) *** 2254,2266 **** add_info ("target", target_info, targ_desc); add_info ("files", target_info, targ_desc); ! add_show_from_set ( ! add_set_cmd ("target", class_maintenance, var_zinteger, ! (char *) &targetdebug, ! "Set target debugging.\n\ When non-zero, target debugging is enabled.", &setdebuglist), ! &showdebuglist); add_com ("monitor", class_obscure, do_monitor_command, "Send a command to the remote monitor (remote targets only)."); --- 2274,2296 ---- add_info ("target", target_info, targ_desc); add_info ("files", target_info, targ_desc); ! add_show_from_set ! (add_set_cmd ("target", class_maintenance, var_zinteger, ! (char *) &targetdebug, ! "Set target debugging.\n\ When non-zero, target debugging is enabled.", &setdebuglist), ! &showdebuglist); + add_show_from_set + (add_set_boolean_cmd + ("trust-readonly-sections", class_support, + &trust_readonly, + "Set mode for reading from readonly sections.\n\ + When this mode is on, memory reads from readonly sections (such as .text)\n\ + will be read from the object file instead of from the target. This will\n\ + result in significant performance improvement for remote targets.", + &setlist), + &showlist); add_com ("monitor", class_obscure, do_monitor_command, "Send a command to the remote monitor (remote targets only)."); --------------3D1F5E9DE839129B615AAABE--