From: Markus Metzger <markus.t.metzger@intel.com>
To: palves@redhat.com, jan.kratochvil@redhat.com
Cc: gdb-patches@sourceware.org, Eli Zaretskii <eliz@gnu.org>
Subject: [rfc] btrace: control memory access during replay
Date: Fri, 04 Apr 2014 08:56:00 -0000 [thread overview]
Message-ID: <1396601781-25010-1-git-send-email-markus.t.metzger@intel.com> (raw)
The btrace record target does not trace data. We therefore do not allow
accessing read-write memory during replay.
In some cases, this might be useful to advanced users, though, who we assume
to know what they are doing.
Add a set|show command pair to turn this memory access restriction off.
CC: Eli Zaretskii <eliz@gnu.org>
2014-04-04 Markus Metzger <markus.t.metzger@intel.com>
* record-btrace.c (set_record_btrace_cmdlist)
(show_record_btrace_cmdlist, cmd_set_record_btrace)
(cmd_show_record_btrace): New.
(_initialize_record_btrace): Add commands.
* NEWS: Announce it.
testsuite/
* gdb.btrace/data.exp: Test it.
doc/
* gdb.texinfo: Document it.
---
gdb/NEWS | 4 ++++
gdb/doc/gdb.texinfo | 13 ++++++++++++
gdb/record-btrace.c | 43 +++++++++++++++++++++++++++++++++++++++
gdb/testsuite/gdb.btrace/data.exp | 8 ++++++++
4 files changed, 68 insertions(+)
diff --git a/gdb/NEWS b/gdb/NEWS
index df233fc..dbd6889 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -50,6 +50,10 @@ maint ada show ignore-descriptive-types
the user manual for more details on descriptive types and the intended
usage of this option.
+set record btrace allow-memory-access (on|off)
+show record btrace allow-memory-access
+ Control access to read-write memory during replay.
+
* New features in the GDB remote stub, GDBserver
** New option --debug-format=option1[,option2,...] allows one to add
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index b218769..08ebb74 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -6398,6 +6398,19 @@ results.
@item show record full memory-query
Show the current setting of @code{memory-query}.
+@kindex set record btrace
+@item set record btrace allow-memory-access
+Control the behavior of the @code{btrace} recording method when
+accessing memory during replay. If ON, @value{GDBN} will allow
+arbitrary memory accesses. The accessed memory corresponds to the end
+of the recorded execution trace. It does not necessarily correspond
+to the current replay position. If OFF (the default), @value{GDBN}
+will only allow accesses to read-only memory.
+
+@kindex show record btrace
+@item show record btrace allow-memory-access
+Show the current setting of @code{allow-memory-access}.
+
@kindex info record
@item info record
Show various statistics about the recording depending on the recording
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index bcac165..9cf1ff8 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -45,6 +45,10 @@ static struct observer *record_btrace_thread_observer;
/* Temporarily allow memory accesses. */
static int record_btrace_allow_memory_access;
+/* Command lists for "set/show record btrace". */
+static struct cmd_list_element *set_record_btrace_cmdlist;
+static struct cmd_list_element *show_record_btrace_cmdlist;
+
/* Print a record-btrace debug message. Use do ... while (0) to avoid
ambiguities when used in if statements. */
@@ -1934,6 +1938,22 @@ cmd_record_btrace_start (char *args, int from_tty)
execute_command ("target record-btrace", from_tty);
}
+/* The "set record btrace" command. */
+
+static void
+cmd_set_record_btrace (char *args, int from_tty)
+{
+ cmd_show_list (set_record_btrace_cmdlist, from_tty, "");
+}
+
+/* The "show record btrace" command. */
+
+static void
+cmd_show_record_btrace (char *args, int from_tty)
+{
+ cmd_show_list (show_record_btrace_cmdlist, from_tty, "");
+}
+
void _initialize_record_btrace (void);
/* Initialize btrace commands. */
@@ -1946,6 +1966,29 @@ _initialize_record_btrace (void)
&record_cmdlist);
add_alias_cmd ("b", "btrace", class_obscure, 1, &record_cmdlist);
+ add_prefix_cmd ("btrace", class_support, cmd_set_record_btrace,
+ _("Set record options"), &set_record_btrace_cmdlist,
+ "set record btrace ", 0, &set_record_cmdlist);
+
+ add_prefix_cmd ("btrace", class_support, cmd_show_record_btrace,
+ _("Show record options"), &show_record_btrace_cmdlist,
+ "show record btrace ", 0, &show_record_cmdlist);
+
+ /* Record instructions number limit command. */
+ add_setshow_boolean_cmd ("allow-memory-access", no_class,
+ &record_btrace_allow_memory_access, _("\
+Set whether memory accesses are allowed during replay."), _("\
+Show whether memory accesses are allowed during replay."),
+ _("Default is OFF.\n\n\
+The btrace record target does not trace data.\n\
+The memory therefore corresponds to the end of the trace and not \
+to the current replay position.\n\n\
+When ON, allow accesses to arbitrary memory during replay.\n\
+When OFF, only allow accesses to read-only memory during replay."),
+ NULL, NULL,
+ &set_record_btrace_cmdlist,
+ &show_record_btrace_cmdlist);
+
init_record_btrace_ops ();
add_target (&record_btrace_ops);
diff --git a/gdb/testsuite/gdb.btrace/data.exp b/gdb/testsuite/gdb.btrace/data.exp
index 64c5443..cfb1395 100644
--- a/gdb/testsuite/gdb.btrace/data.exp
+++ b/gdb/testsuite/gdb.btrace/data.exp
@@ -40,6 +40,14 @@ gdb_test "reverse-step" ".*test\.4.*"
gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
gdb_test "print loc" "unavailable\[^\\\r\\\n\]*"
+# we can read memory if we explicitly allow it.
+gdb_test_no_output "set record btrace allow-memory-access on"
+gdb_test "print glob" "1"
+
+# we can't if we don't explicitly allow it.
+gdb_test_no_output "set record btrace allow-memory-access off"
+gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
+
# stop replaying and try again
gdb_test "record goto end"
gdb_test "print glob" "1"
--
1.8.3.1
next reply other threads:[~2014-04-04 8:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-04 8:56 Markus Metzger [this message]
2014-04-04 9:16 ` Eli Zaretskii
2014-04-04 9:44 ` Metzger, Markus T
2014-04-04 9:48 ` Eli Zaretskii
2014-05-14 15:35 ` Pedro Alves
2014-05-19 7:51 ` Metzger, Markus T
2014-05-19 17:44 ` Pedro Alves
2014-05-20 7:01 ` Metzger, Markus T
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=1396601781-25010-1-git-send-email-markus.t.metzger@intel.com \
--to=markus.t.metzger@intel.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=palves@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