From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6952 invoked by alias); 12 May 2005 22:55:21 -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 6926 invoked from network); 12 May 2005 22:55:12 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 12 May 2005 22:55:12 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j4CMtC5a006417 for ; Thu, 12 May 2005 18:55:12 -0400 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j4CMtCO01673 for ; Thu, 12 May 2005 18:55:12 -0400 Received: from msnyder8600 (vpn26-4.sfbay.redhat.com [172.16.26.4]) by potter.sfbay.redhat.com (8.12.8/8.12.8) with SMTP id j4CMt9a8001980 for ; Thu, 12 May 2005 18:55:10 -0400 Message-ID: <00c201c55745$a651dd30$aaa56b80@msnyder8600> From: "Michael Snyder" To: "GDB Patches" Subject: [rfa] Restore "trust-readonly-section" Date: Fri, 13 May 2005 06:29:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-SW-Source: 2005-05/txt/msg00318.txt.bz2 This seems to have succumbed to bit-rot -- there are new target-read functions in target.c that don't pay any attention to this user-settable mode bit. The purpose of "trust-readonly-sections" is to improve speed on targets where reading memory is expensive (mostly remote). It checks to see if a read is from a read-only section, and if so, reads it from the exec file. It defaults to "off" for safety, but if users choose to use it, it really speeds up prologue analysis (and therefore stepping). This patch just makes it work again. 2005-05-12 Michael Snyder * target.c (target_read_trusted): New function. Implements "trust-readonly-section". (target_xfer_partial): Honor trust-readonly-section. (do_xfer_memory): Ditto. (target_xfer_memory_partial): Ditto. (default_xfer_partial): Ditto. Index: target.c =================================================================== RCS file: /cvs/src/src/gdb/target.c,v retrieving revision 1.106 diff -p -r1.106 target.c *** target.c 9 May 2005 21:20:35 -0000 1.106 --- target.c 12 May 2005 22:23:32 -0000 *************** target_section_by_addr (struct target_op *** 849,854 **** --- 849,880 ---- return NULL; } + static int trust_readonly = 0; + static void + show_trust_readonly (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) + { + fprintf_filtered (file, _("\ + Mode for reading from readonly sections is %s.\n"), + value); + } + + static int + target_read_trusted (CORE_ADDR memaddr, char *myaddr, int len) + { + struct section_table *secp; + /* User-settable option, "trust-readonly-sections". If true, + then memory from any SEC_READONLY bfd section may be read + directly from the bfd file. */ + secp = target_section_by_addr (¤t_target, memaddr); + if (secp != NULL + && (bfd_get_section_flags (secp->bfd, secp->the_bfd_section) + & SEC_READONLY)) + return xfer_memory (memaddr, myaddr, len, 0, NULL, ¤t_target); + + return 0; + } + /* Return non-zero when the target vector has supplied an xfer_partial method and it, rather than xfer_memory, should be used. */ static int *************** target_xfer_partial (struct target_ops * *** 864,870 **** void *readbuf, const void *writebuf, ULONGEST offset, LONGEST len) { ! LONGEST retval; gdb_assert (ops->to_xfer_partial != NULL); retval = ops->to_xfer_partial (ops, object, annex, readbuf, writebuf, --- 890,904 ---- void *readbuf, const void *writebuf, ULONGEST offset, LONGEST len) { ! LONGEST retval = -1; ! ! /* No need to use target method if trusted readonly section can be ! used (by user's wish). */ ! if (trust_readonly ! && object == TARGET_OBJECT_MEMORY ! && readbuf != NULL) ! if ((retval = target_read_trusted (offset, readbuf, len)) > 0) ! return retval; gdb_assert (ops->to_xfer_partial != NULL); retval = ops->to_xfer_partial (ops, object, annex, readbuf, writebuf, *************** target_stopped_data_address_p (struct ta *** 1037,1052 **** } #endif - static int trust_readonly = 0; - static void - show_trust_readonly (struct ui_file *file, int from_tty, - struct cmd_list_element *c, const char *value) - { - fprintf_filtered (file, _("\ - Mode for reading from readonly sections is %s.\n"), - value); - } - /* 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. --- 1071,1076 ---- *************** do_xfer_memory (CORE_ADDR memaddr, char *** 1069,1085 **** errno = 0; if (!write && trust_readonly) ! { ! struct section_table *secp; ! /* User-settable option, "trust-readonly-sections". If true, ! then memory from any SEC_READONLY bfd section may be read ! directly from the bfd file. */ ! secp = target_section_by_addr (¤t_target, memaddr); ! if (secp != NULL ! && (bfd_get_section_flags (secp->bfd, secp->the_bfd_section) ! & SEC_READONLY)) ! 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.deprecated_xfer_memory --- 1093,1100 ---- errno = 0; if (!write && trust_readonly) ! if ((res = target_read_trusted (memaddr, myaddr, len)) > 0) ! return res; /* The quick case is that the top target can handle the transfer. */ res = current_target.deprecated_xfer_memory *************** target_xfer_memory_partial (CORE_ADDR me *** 1199,1204 **** --- 1214,1224 ---- return 0; } + /* No need to use dcache if trusted readonly section can be used. */ + if (!write_p && trust_readonly) + if ((res = target_read_trusted (memaddr, myaddr, reg_len)) > 0) + return res; + region = lookup_mem_region(memaddr); if (memaddr + len < region->hi) reg_len = len; *************** default_xfer_partial (struct target_ops *** 1308,1313 **** --- 1328,1343 ---- const char *annex, void *readbuf, const void *writebuf, ULONGEST offset, LONGEST len) { + LONGEST retval = -1; + + /* No need to use target method if trusted readonly section can be + used (by user's wish). */ + if (trust_readonly + && object == TARGET_OBJECT_MEMORY + && readbuf != NULL) + if ((retval = target_read_trusted (offset, readbuf, len)) > 0) + return retval; + if (object == TARGET_OBJECT_MEMORY && ops->deprecated_xfer_memory != NULL) /* If available, fall back to the target's