From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 1/7] Emit a warning when writing to a readonly section and trust_readonly is true
Date: Sun, 08 Sep 2013 12:04:00 -0000 [thread overview]
Message-ID: <1378641807-24256-2-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1378641807-24256-1-git-send-email-yao@codesourcery.com>
If users write a readonly section, such as .text, the contents of the inferior
and of the executable become out of sync. It is better to emit a warning
to ask users to "set trust-readonly-sections off".
(gdb) set trust-readonly-sections on
(gdb) p /x* (char *) 0x080484c1 = 0xcc
warning: Writing to a readonly section so that the contents in the
inferior and in the executable are out of sync. Please 'set
trust-readonly-sections off'.
$1 = 0xcc
gdb:
2013-09-08 Yao Qi <yao@codesourcery.com>
* target.c (memory_xfer_partial_1): Emit a warning if GDB
writes to a readonly section and 'trust_readonly' is true.
---
gdb/target.c | 31 ++++++++++++++++++++++---------
1 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/gdb/target.c b/gdb/target.c
index d55712d..f6a58ff 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1471,11 +1471,13 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
}
}
- /* Try the executable files, if "trust-readonly-sections" is set. */
- if (readbuf != NULL && trust_readonly)
+ /* If "trust-readonly-sections" is set, read from the executable
+ files. When GDB writes to a readonly section of the inferior,
+ emit a warning that option 'trust-readonly-sections' should be
+ turned off. */
+ if (trust_readonly)
{
struct target_section *secp;
- struct target_section_table *table;
secp = target_section_by_addr (ops, memaddr);
if (secp != NULL
@@ -1483,12 +1485,23 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
secp->the_bfd_section)
& SEC_READONLY))
{
- table = target_get_section_table (ops);
- return section_table_xfer_memory_partial (readbuf, writebuf,
- memaddr, len,
- table->sections,
- table->sections_end,
- NULL);
+
+ if (readbuf != NULL)
+ {
+ struct target_section_table *table;
+
+ table = target_get_section_table (ops);
+ return section_table_xfer_memory_partial (readbuf, writebuf,
+ memaddr, len,
+ table->sections,
+ table->sections_end,
+ NULL);
+ }
+
+ if (writebuf != NULL)
+ warning (_("Writing to a readonly section so that the contents"
+ " in the inferior and in the executable are out of"
+ " sync. Please 'set trust-readonly-sections off'."));
}
}
--
1.7.7.6
next prev parent reply other threads:[~2013-09-08 12:04 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-06 2:03 [PATCH 0/3] Trust readonly sections if target has memory protection Yao Qi
2013-09-06 2:03 ` [PATCH 1/3] set trust-readonly-sections off in test cases Yao Qi
2013-09-06 5:56 ` Eli Zaretskii
2013-09-06 17:23 ` Pedro Alves
2013-09-06 2:03 ` [PATCH 2/3] Trust readonly sections if target has memory protection Yao Qi
2013-09-06 6:05 ` Eli Zaretskii
2013-09-06 9:07 ` Yao Qi
2013-09-06 9:24 ` Eli Zaretskii
2013-09-06 2:03 ` [PATCH 3/3] Linux " Yao Qi
2013-09-06 5:57 ` [PATCH 0/3] Trust readonly sections if target " Eli Zaretskii
2013-09-06 8:24 ` Yao Qi
2013-09-06 8:45 ` Eli Zaretskii
2013-09-06 13:03 ` Joel Brobecker
2013-09-06 13:27 ` Yao Qi
2013-09-06 13:32 ` Eli Zaretskii
2013-09-06 14:17 ` Pierre Muller
[not found] ` <"000d01ceab0b$d53ae600$7fb0b200$@muller"@ics-cnrs.unistra.fr>
2013-09-06 14:38 ` Eli Zaretskii
2013-09-06 14:52 ` Joel Brobecker
2013-09-06 15:56 ` Eli Zaretskii
2013-09-06 18:10 ` Joel Brobecker
2013-09-06 18:36 ` Eli Zaretskii
2013-09-06 13:00 ` Joel Brobecker
2013-09-08 12:04 ` [PATCH 0/7 V2] " Yao Qi
2013-09-08 12:04 ` Yao Qi [this message]
2013-09-08 15:10 ` [PATCH 1/7] Emit a warning when writing to a readonly section and trust_readonly is true Eli Zaretskii
2013-09-08 12:05 ` [PATCH 3/7] New function windows_init_abi Yao Qi
2013-09-08 12:05 ` [PATCH 4/7] Trust readonly sections if target has memory protection Yao Qi
2013-09-08 15:13 ` Eli Zaretskii
2013-09-09 7:49 ` Yao Qi
2013-09-09 16:25 ` Eli Zaretskii
2013-09-08 12:05 ` [PATCH 7/7] Windows " Yao Qi
2013-09-08 12:05 ` [PATCH 2/7] set trust-readonly-sections off in test cases Yao Qi
2013-09-08 12:05 ` [PATCH 5/7] DOC and NEWS Yao Qi
2013-09-08 12:05 ` [PATCH 6/7] Linux has memory protection Yao Qi
2013-09-09 19:16 ` [PATCH 0/7 V2] Trust readonly sections if target " Mark Kettenis
2013-09-10 4:06 ` Yao Qi
2013-09-12 8:30 ` Yao Qi
2013-09-12 9:49 ` Mark Kettenis
2013-09-13 8:17 ` Yao Qi
2013-09-30 17:50 ` Pedro Alves
2013-09-30 18:08 ` Pedro Alves
2013-10-07 22:29 ` Stan Shebs
2013-10-08 12:18 ` Pedro Alves
2013-10-08 12:47 ` Abid, Hafiz
2013-10-08 13:36 ` tmirza
2013-10-09 2:24 ` Doug Evans
2013-10-23 10:16 ` Yao Qi
2013-10-15 0:44 ` Yao Qi
2013-09-20 2:47 ` [PATCH 0/7 V3] " Yao Qi
2013-09-20 2:47 ` [PATCH 3/7] New function windows_init_abi Yao Qi
2013-09-30 18:23 ` Pedro Alves
2013-10-01 6:47 ` Yao Qi
2013-10-01 9:35 ` Pedro Alves
2013-10-01 13:23 ` Yao Qi
2013-09-20 2:47 ` [PATCH 5/7] DOC and NEWS Yao Qi
2013-09-20 8:21 ` Eli Zaretskii
2013-09-20 2:47 ` [PATCH 6/7] Linux has memory protection Yao Qi
2013-09-20 2:47 ` [PATCH 2/7] set trust-readonly-sections off in test cases Yao Qi
2013-09-20 2:47 ` [PATCH 4/7] Trust readonly sections if target has memory protection and in remote debugging Yao Qi
2013-09-20 2:47 ` [PATCH 7/7] Windows has memory protection Yao Qi
2013-09-20 2:47 ` [PATCH 1/7] Emit a query when writing to a readonly section and trust_readonly is true Yao Qi
2013-09-29 13:51 ` [PATCH 0/7 V3] Trust readonly sections if target has memory protection Yao Qi
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=1378641807-24256-2-git-send-email-yao@codesourcery.com \
--to=yao@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/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