From: Michael Snyder <msnyder@cygnus.com>
To: gdb-patches@sources.redhat.com
Subject: [RFA] New option "trust-readonly-sections"
Date: Wed, 23 Jan 2002 19:29:00 -0000 [thread overview]
Message-ID: <200201240323.g0O3NI905339@reddwarf.cygnus.com> (raw)
This is an optimization mainly for remote debugging, or any
context where reading from the child's memory is expensive.
In a nutshell, if you trust that read-only sections will really
not be modified, you can advise GDB of this fact, and GDB will
then satisfy all memory reads from read-only sections by reading
from the object file, instead of from the child/target.
Naturally it defaults to 'off'.
On targets that do a lot of prologue analysis (which
involves lots of reads from the text section), this can
be a huge speed win.
2002-01-15 Michael Snyder <msnyder@redhat.com>
* target.c: New command, "set trust-readonly on".
(do_xfer_memory): Honor the suggestion to trust readonly sections
by reading them from the object file instead of from the target.
Index: target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.30
diff -c -3 -p -r1.30 target.c
*** target.c 2002/01/09 00:36:58 1.30
--- target.c 2002/01/24 03:23:44
*************** 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,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);
+ }
+ }
+
/* 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).");
--- 2275,2295 ----
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_cmd ("trust-readonly", class_support,
+ var_boolean, (char *) &trust_readonly,
+ "Set memory reads to trust SEC_READONLY section attribute.\n\
+ When active, memory from readonly sections (such as .text)\n\
+ will be read from the executable file instead of from target memory.",
+ &setlist),
+ &showlist);
add_com ("monitor", class_obscure, do_monitor_command,
"Send a command to the remote monitor (remote targets only).");
next reply other threads:[~2002-01-24 3:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-23 19:29 Michael Snyder [this message]
2002-01-23 20:15 ` Andrew Cagney
2002-01-23 21:45 ` Daniel Jacobowitz
2002-01-23 23:23 ` Eli Zaretskii
2002-01-24 8:35 ` Daniel Jacobowitz
2002-01-24 8:51 ` Andrew Cagney
2002-01-24 9:14 ` Andrew Cagney
2002-01-24 9:25 ` Daniel Jacobowitz
2002-01-23 23:29 ` Stan Shebs
2002-01-24 10:40 ` Michael Snyder
2002-01-24 10:52 ` Andrew Cagney
2002-01-30 18:25 ` Michael Snyder
2002-01-31 1:03 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200201240323.g0O3NI905339@reddwarf.cygnus.com \
--to=msnyder@cygnus.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox