public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 3/3] btrace, vdso: add vdso target sections
  2014-05-20 12:01 [PATCH v2 1/3] btrace: control memory access during replay Markus Metzger
@ 2014-05-20 12:00 ` Markus Metzger
  2014-05-20 13:16   ` Pedro Alves
  2014-05-20 12:00 ` [PATCH v2 2/3] test, gcore: move capture_command_output into lib/gdb.exp Markus Metzger
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Markus Metzger @ 2014-05-20 12:00 UTC (permalink / raw)
  To: palves; +Cc: gdb-patches

When loading symbols for the vdso, also add its sections to target_sections.

This fixes an issue with record btrace where vdso instructions could not be
disassembled during replay.

2014-05-20  Markus Metzger  <markus.t.metzger@intel.com>

	* symfile-mem.c (symbol_file_add_from_memory): Add BFD sections.

testsuite/
	* gdb.btrace/vdso.c: New.
	* gdb.btrace/vdso.exp: New.


---
 gdb/symfile-mem.c                 | 17 +++++++++++++
 gdb/testsuite/gdb.btrace/vdso.c   | 30 +++++++++++++++++++++++
 gdb/testsuite/gdb.btrace/vdso.exp | 51 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 98 insertions(+)
 create mode 100644 gdb/testsuite/gdb.btrace/vdso.c
 create mode 100644 gdb/testsuite/gdb.btrace/vdso.exp

diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c
index 3f09c4d..19ae14a 100644
--- a/gdb/symfile-mem.c
+++ b/gdb/symfile-mem.c
@@ -92,6 +92,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr,
   struct section_addr_info *sai;
   unsigned int i;
   struct cleanup *cleanup;
+  struct target_section *sections, *sections_end, *tsec;
 
   if (bfd_get_flavour (templ) != bfd_target_elf_flavour)
     error (_("add-symbol-file-from-memory not supported for this target"));
@@ -131,6 +132,22 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr,
 				   from_tty ? SYMFILE_VERBOSE : 0,
                                    sai, OBJF_SHARED, NULL);
 
+  sections = NULL;
+  sections_end = NULL;
+  make_cleanup (xfree, sections);
+
+  if (build_section_table (nbfd, &sections, &sections_end) == 0)
+    {
+      /* Adjust the target section addresses by the load address.  */
+      for (tsec = sections; tsec != sections_end; ++tsec)
+	{
+	  tsec->addr += loadbase;
+	  tsec->endaddr += loadbase;
+	}
+
+      add_target_sections (&nbfd, sections, sections_end);
+    }
+
   /* This might change our ideas about frames already looked at.  */
   reinit_frame_cache ();
 
diff --git a/gdb/testsuite/gdb.btrace/vdso.c b/gdb/testsuite/gdb.btrace/vdso.c
new file mode 100644
index 0000000..e16a3c6
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/vdso.c
@@ -0,0 +1,30 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2014 Free Software Foundation, Inc.
+
+   Contributed by Intel Corp. <markus.t.metzger@intel.com>
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <sys/time.h>
+
+int
+main (void)
+{
+  struct timeval tv;
+
+  gettimeofday (&tv, 0); /* main.1.  */
+
+  return 0; /* main.2.  */
+}
diff --git a/gdb/testsuite/gdb.btrace/vdso.exp b/gdb/testsuite/gdb.btrace/vdso.exp
new file mode 100644
index 0000000..a84e198
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/vdso.exp
@@ -0,0 +1,51 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2014 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corp. <markus.t.metzger@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+#
+# Test that we can access the vdso memory during replay for stepping.
+
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+# start inferior
+standard_testfile
+if [prepare_for_testing $testfile.exp $testfile $srcfile] {
+    return -1
+}
+if ![runto_main] {
+    return -1
+}
+
+# capture the disassembly of gettimeofday while live debugging
+set live_gettimeofday [capture_command_output "disassemble gettimeofday" ""]
+
+# trace the test code
+gdb_test_no_output "record btrace"
+gdb_test "next" "main\.2.*"
+
+# capture the disassembly of gettimeofday while replaying
+gdb_test "record goto begin" "main\.1.*"
+set replay_gettimeofday [capture_command_output "disassemble gettimeofday" ""]
+
+# the two disassemblys must be identical
+if ![string compare $live_gettimeofday $replay_gettimeofday]  {
+    pass "disassemble gettimeofday"
+} else {
+    fail "disassemble gettimeofday"
+}
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 2/3] test, gcore: move capture_command_output into lib/gdb.exp
  2014-05-20 12:01 [PATCH v2 1/3] btrace: control memory access during replay Markus Metzger
  2014-05-20 12:00 ` [PATCH v2 3/3] btrace, vdso: add vdso target sections Markus Metzger
@ 2014-05-20 12:00 ` Markus Metzger
  2014-05-20 12:27   ` Pedro Alves
  2014-05-20 12:26 ` [PATCH v2 1/3] btrace: control memory access during replay Pedro Alves
  2014-05-20 16:12 ` Eli Zaretskii
  3 siblings, 1 reply; 12+ messages in thread
From: Markus Metzger @ 2014-05-20 12:00 UTC (permalink / raw)
  To: palves; +Cc: gdb-patches

Allow gcore's capture_command_output function to be used by other tests.

2014-05-20  Markus Metzger  <markus.t.metzger@intel.com>

testsuite/
	* gdb.base/gcore.exp (capture_command_output): Move ...
	* lib/gdb.exp (capture_command_output): ... here.


---
 gdb/testsuite/gdb.base/gcore.exp | 13 -------------
 gdb/testsuite/lib/gdb.exp        | 14 ++++++++++++++
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/gdb/testsuite/gdb.base/gcore.exp b/gdb/testsuite/gdb.base/gcore.exp
index 99743a0..c28a9b3 100644
--- a/gdb/testsuite/gdb.base/gcore.exp
+++ b/gdb/testsuite/gdb.base/gcore.exp
@@ -41,19 +41,6 @@ if { ! [ runto_main ] } then {
     return -1
 }
 
-proc capture_command_output { command prefix } {
-    global gdb_prompt
-    global expect_out
-
-    set output_string ""
-    gdb_test_multiple "$command" "capture_command_output for $command" {
-	-re "${command}\[\r\n\]+${prefix}(.*)\[\r\n\]+$gdb_prompt $" {
-	    set output_string $expect_out(1,string)
-	}
-    }
-    return $output_string
-}
-
 gdb_test "break terminal_func" "Breakpoint .* at .*${srcfile}, line .*" \
 	"set breakpoint at terminal_func"
 
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 3125e7a..5d6b90c 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4771,5 +4771,19 @@ proc parse_args { argset } {
     # number of items expected to be passed into the procedure...
 }
 
+# Capture the output of COMMAND in a string ignoring PREFIX; return that string.
+proc capture_command_output { command prefix } {
+    global gdb_prompt
+    global expect_out
+
+    set output_string ""
+    gdb_test_multiple "$command" "capture_command_output for $command" {
+	-re "${command}\[\r\n\]+${prefix}(.*)\[\r\n\]+$gdb_prompt $" {
+	    set output_string $expect_out(1,string)
+	}
+    }
+    return $output_string
+}
+
 # Always load compatibility stuff.
 load_lib future.exp
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 1/3] btrace: control memory access during replay
@ 2014-05-20 12:01 Markus Metzger
  2014-05-20 12:00 ` [PATCH v2 3/3] btrace, vdso: add vdso target sections Markus Metzger
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Markus Metzger @ 2014-05-20 12:01 UTC (permalink / raw)
  To: palves; +Cc: gdb-patches, Eli Zaretskii

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-05-20  Markus Metzger  <markus.t.metzger@intel.com>

	* record-btrace.c (record_btrace_allow_memory_access): Remove.
	(replay_memory_access_read_only, replay_memory_access_read_write)
	(replay_memory_access_types, replay_memory_access)
	(set_record_btrace_cmdlist, show_record_btrace_cmdlist)
	(cmd_set_record_btrace, cmd_show_record_btrace)
	(cmd_show_replay_memory_access): New.
	(record_btrace_xfer_partial, record_btrace_insert_breakpoint)
	(record_btrace_remove_breakpoint): Replace
	record_btrace_allow_memory_access with replay_memory_access.
	(_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               | 22 ++++++++++
 gdb/record-btrace.c               | 89 ++++++++++++++++++++++++++++++++++-----
 gdb/testsuite/gdb.btrace/data.exp | 10 ++++-
 4 files changed, 113 insertions(+), 12 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index 00ec8b9..be8abc0 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -61,6 +61,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 replay-memory-access (read-only|read-write)
+show record btrace replay-memory-access
+  Control what memory accesses are allowed 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 a6bde12..3f1f5c8 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -6400,6 +6400,28 @@ results.
 @item show record full memory-query
 Show the current setting of @code{memory-query}.
 
+@kindex set record btrace
+The btrace record target does not trace data.  As a convenience,
+when replaying, GDB reads read-only memory off the live program
+directly, assuming that the addresses of the read-only areas
+don't change.  This for example makes it possible to disassemble
+code while replaying, but not to print variables.
+In some cases, being able to inspect variables might be useful.
+You can use the following command for that:
+
+@item set record btrace replay-memory-access
+Control the behavior of the @code{btrace} recording method when
+accessing memory during replay.  If READ-ONLY (the default),
+@value{GDBN} will only allow accesses to read-only memory.
+If READ-WRITE, @value{GDBN} will allow accesses to read-only and to
+read-write memory.  Beware that the accessed memory corresponds
+to the live target and not necessarily to the current replay
+position.
+
+@kindex show record btrace
+@item show record btrace replay-memory-access
+Show the current setting of @code{replay-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..f8f9942 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -42,8 +42,22 @@ static struct target_ops record_btrace_ops;
 /* A new thread observer enabling branch tracing for the new thread.  */
 static struct observer *record_btrace_thread_observer;
 
-/* Temporarily allow memory accesses.  */
-static int record_btrace_allow_memory_access;
+/* Memory access types used in set/show record btrace replay-memory-access.  */
+static const char replay_memory_access_read_only[] = "read-only";
+static const char replay_memory_access_read_write[] = "read-write";
+static const char *const replay_memory_access_types[] =
+{
+  replay_memory_access_read_only,
+  replay_memory_access_read_write,
+  NULL
+};
+
+/* The currently allowed replay memory access type.  */
+static const char *replay_memory_access = replay_memory_access_read_only;
+
+/* 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.  */
@@ -815,7 +829,8 @@ record_btrace_xfer_partial (struct target_ops *ops, enum target_object object,
   struct target_ops *t;
 
   /* Filter out requests that don't make sense during replay.  */
-  if (!record_btrace_allow_memory_access && record_btrace_is_replaying (ops))
+  if (replay_memory_access == replay_memory_access_read_only
+      && record_btrace_is_replaying (ops))
     {
       switch (object)
 	{
@@ -869,18 +884,19 @@ record_btrace_insert_breakpoint (struct target_ops *ops,
 				 struct bp_target_info *bp_tgt)
 {
   volatile struct gdb_exception except;
-  int old, ret;
+  const char *old;
+  int ret;
 
   /* Inserting breakpoints requires accessing memory.  Allow it for the
      duration of this function.  */
-  old = record_btrace_allow_memory_access;
-  record_btrace_allow_memory_access = 1;
+  old = replay_memory_access;
+  replay_memory_access = replay_memory_access_read_write;
 
   ret = 0;
   TRY_CATCH (except, RETURN_MASK_ALL)
     ret = ops->beneath->to_insert_breakpoint (ops->beneath, gdbarch, bp_tgt);
 
-  record_btrace_allow_memory_access = old;
+  replay_memory_access = old;
 
   if (except.reason < 0)
     throw_exception (except);
@@ -896,18 +912,19 @@ record_btrace_remove_breakpoint (struct target_ops *ops,
 				 struct bp_target_info *bp_tgt)
 {
   volatile struct gdb_exception except;
-  int old, ret;
+  const char *old;
+  int ret;
 
   /* Removing breakpoints requires accessing memory.  Allow it for the
      duration of this function.  */
-  old = record_btrace_allow_memory_access;
-  record_btrace_allow_memory_access = 1;
+  old = replay_memory_access;
+  replay_memory_access = replay_memory_access_read_write;
 
   ret = 0;
   TRY_CATCH (except, RETURN_MASK_ALL)
     ret = ops->beneath->to_remove_breakpoint (ops->beneath, gdbarch, bp_tgt);
 
-  record_btrace_allow_memory_access = old;
+  replay_memory_access = old;
 
   if (except.reason < 0)
     throw_exception (except);
@@ -1934,6 +1951,32 @@ 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, "");
+}
+
+/* The "show record btrace replay-memory-access" command.  */
+
+static void
+cmd_show_replay_memory_access (struct ui_file *file, int from_tty,
+			       struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (gdb_stdout, _("Replay memory access is %s.\n"),
+		    replay_memory_access);
+}
+
 void _initialize_record_btrace (void);
 
 /* Initialize btrace commands.  */
@@ -1946,6 +1989,30 @@ _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_enum_cmd ("replay-memory-access", no_class,
+			replay_memory_access_types, &replay_memory_access, _("\
+Set what memory accesses are allowed during replay."), _("\
+Show what memory accesses are allowed during replay."),
+			   _("Default is READ-ONLY.\n\n\
+The btrace record target does not trace data.\n\
+The memory therefore corresponds to the live target and not \
+to the current replay position.\n\n\
+When READ-ONLY, allow accesses to read-only memory during replay.\n\
+When READ-WRITE, allow accesses to read-only and read-write memory during \
+replay."),
+			   NULL, cmd_show_replay_memory_access,
+			   &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..91d8d8b 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 replay-memory-access read-write"
+gdb_test "print glob" "1"
+
+# we can't if we don't explicitly allow it.
+gdb_test_no_output "set record btrace replay-memory-access read-only"
+gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
+
 # stop replaying and try again
-gdb_test "record goto end"
+gdb_test "record goto end" ".*main\.3.*"
 gdb_test "print glob" "1"
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/3] btrace: control memory access during replay
  2014-05-20 12:01 [PATCH v2 1/3] btrace: control memory access during replay Markus Metzger
  2014-05-20 12:00 ` [PATCH v2 3/3] btrace, vdso: add vdso target sections Markus Metzger
  2014-05-20 12:00 ` [PATCH v2 2/3] test, gcore: move capture_command_output into lib/gdb.exp Markus Metzger
@ 2014-05-20 12:26 ` Pedro Alves
  2014-05-20 16:12 ` Eli Zaretskii
  3 siblings, 0 replies; 12+ messages in thread
From: Pedro Alves @ 2014-05-20 12:26 UTC (permalink / raw)
  To: Markus Metzger; +Cc: gdb-patches, Eli Zaretskii

On 05/20/2014 01:00 PM, Markus Metzger wrote:
> 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.
> 

The code bits are OK.


> +  /* Record instructions number limit command.  */

This comment looks like a pasto.

> +  add_setshow_enum_cmd ("replay-memory-access", no_class,
> +			replay_memory_access_types, &replay_memory_access, _("\

Thanks,
-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/3] test, gcore: move capture_command_output into lib/gdb.exp
  2014-05-20 12:00 ` [PATCH v2 2/3] test, gcore: move capture_command_output into lib/gdb.exp Markus Metzger
@ 2014-05-20 12:27   ` Pedro Alves
  0 siblings, 0 replies; 12+ messages in thread
From: Pedro Alves @ 2014-05-20 12:27 UTC (permalink / raw)
  To: Markus Metzger; +Cc: gdb-patches

On 05/20/2014 01:00 PM, Markus Metzger wrote:
> Allow gcore's capture_command_output function to be used by other tests.
> 
> 2014-05-20  Markus Metzger  <markus.t.metzger@intel.com>
> 
> testsuite/
> 	* gdb.base/gcore.exp (capture_command_output): Move ...
> 	* lib/gdb.exp (capture_command_output): ... here.

OK.

Thanks,
-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 3/3] btrace, vdso: add vdso target sections
  2014-05-20 12:00 ` [PATCH v2 3/3] btrace, vdso: add vdso target sections Markus Metzger
@ 2014-05-20 13:16   ` Pedro Alves
  2014-05-20 14:10     ` Metzger, Markus T
  0 siblings, 1 reply; 12+ messages in thread
From: Pedro Alves @ 2014-05-20 13:16 UTC (permalink / raw)
  To: Markus Metzger; +Cc: gdb-patches

Thanks.

On 05/20/2014 01:00 PM, Markus Metzger wrote:

> @@ -92,6 +92,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr,
>    struct section_addr_info *sai;
>    unsigned int i;
>    struct cleanup *cleanup;
> +  struct target_section *sections, *sections_end, *tsec;
>  
>    if (bfd_get_flavour (templ) != bfd_target_elf_flavour)
>      error (_("add-symbol-file-from-memory not supported for this target"));
> @@ -131,6 +132,22 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr,
>  				   from_tty ? SYMFILE_VERBOSE : 0,
>                                     sai, OBJF_SHARED, NULL);
>  
> +  sections = NULL;
> +  sections_end = NULL;
> +  make_cleanup (xfree, sections);

This will always xfree NULL.  You either want:

 make_cleanup (free_current_contents, &sections);

or move the cleanup to within the if/then block.  You also need
to make sure to discard the cleanup on success.

Or, better yet, not install a cleanup at all?  build_section_table
allocates the memory, and then the array is passed directly to
add_target_sections, which can be seen as a transfer of ownership.
If something throws after that call, we don't want the sections be
be simply xfree'd as that'd leave dangling pointers in the target
sections table.

> +
> +  if (build_section_table (nbfd, &sections, &sections_end) == 0)
> +    {
> +      /* Adjust the target section addresses by the load address.  */
> +      for (tsec = sections; tsec != sections_end; ++tsec)
> +	{
> +	  tsec->addr += loadbase;
> +	  tsec->endaddr += loadbase;
> +	}
> +
> +      add_target_sections (&nbfd, sections, sections_end);
> +    }
> +
>    /* This might change our ideas about frames already looked at.  */
>    reinit_frame_cache ();


> +# capture the disassembly of gettimeofday while live debugging
> +set live_gettimeofday [capture_command_output "disassemble gettimeofday" ""]
> +
> +# trace the test code
> +gdb_test_no_output "record btrace"
> +gdb_test "next" "main\.2.*"
> +
> +# capture the disassembly of gettimeofday while replaying
> +gdb_test "record goto begin" "main\.1.*"
> +set replay_gettimeofday [capture_command_output "disassemble gettimeofday" ""]

I think these two capture_command_output calls generate duplicate
gdb.sum output ?  That's why I had with_test_prefix in my suggestion.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH v2 3/3] btrace, vdso: add vdso target sections
  2014-05-20 13:16   ` Pedro Alves
@ 2014-05-20 14:10     ` Metzger, Markus T
  0 siblings, 0 replies; 12+ messages in thread
From: Metzger, Markus T @ 2014-05-20 14:10 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

> -----Original Message-----
> From: Pedro Alves [mailto:palves@redhat.com]
> Sent: Tuesday, May 20, 2014 2:40 PM


> > +  sections = NULL;
> > +  sections_end = NULL;
> > +  make_cleanup (xfree, sections);
> 
> This will always xfree NULL.  You either want:
> 
>  make_cleanup (free_current_contents, &sections);

That's what I wanted.  Thanks!


> or move the cleanup to within the if/then block.  You also need
> to make sure to discard the cleanup on success.
> 
> Or, better yet, not install a cleanup at all?  build_section_table
> allocates the memory, and then the array is passed directly to
> add_target_sections, which can be seen as a transfer of ownership.
> If something throws after that call, we don't want the sections be
> be simply xfree'd as that'd leave dangling pointers in the target
> sections table.

add_target_sections copies the sections.


> > +# capture the disassembly of gettimeofday while live debugging
> > +set live_gettimeofday [capture_command_output "disassemble
> gettimeofday" ""]
> > +
> > +# trace the test code
> > +gdb_test_no_output "record btrace"
> > +gdb_test "next" "main\.2.*"
> > +
> > +# capture the disassembly of gettimeofday while replaying
> > +gdb_test "record goto begin" "main\.1.*"
> > +set replay_gettimeofday [capture_command_output "disassemble
> gettimeofday" ""]
> 
> I think these two capture_command_output calls generate duplicate
> gdb.sum output ?  That's why I had with_test_prefix in my suggestion.

I overlooked that.  Sorry.

Regards,
Markus.
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/3] btrace: control memory access during replay
  2014-05-20 12:01 [PATCH v2 1/3] btrace: control memory access during replay Markus Metzger
                   ` (2 preceding siblings ...)
  2014-05-20 12:26 ` [PATCH v2 1/3] btrace: control memory access during replay Pedro Alves
@ 2014-05-20 16:12 ` Eli Zaretskii
  2014-05-21  6:10   ` Metzger, Markus T
  3 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2014-05-20 16:12 UTC (permalink / raw)
  To: Markus Metzger; +Cc: palves, gdb-patches

> From: Markus Metzger <markus.t.metzger@intel.com>
> Cc: gdb-patches@sourceware.org, Eli Zaretskii <eliz@gnu.org>
> Date: Tue, 20 May 2014 14:00:34 +0200
> 
> 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.

Thanks.

> doc/
> 	* gdb.texinfo: Document it.

That's not how we format ChangeLog entries in gdb/doc/.  Please state
the node name (as if it were a function, in parentheses).

> +@kindex set record btrace
> +The btrace record target does not trace data.  As a convenience,
> +when replaying, GDB reads read-only memory off the live program

@value{GDBN}

> +Control the behavior of the @code{btrace} recording method when

Please be consistent about the markup of "btrace": either plain text
or @code{}; pick one and use it everywhere.

> +accessing memory during replay.  If READ-ONLY (the default),
> +@value{GDBN} will only allow accesses to read-only memory.
> +If READ-WRITE, @value{GDBN} will allow accesses to read-only and to
> +read-write memory.  Beware that the accessed memory corresponds

READ-ONLY and READ-WRITE should be in @code and in lower case.

The documentation part is OK with those fixed.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH v2 1/3] btrace: control memory access during replay
  2014-05-20 16:12 ` Eli Zaretskii
@ 2014-05-21  6:10   ` Metzger, Markus T
  2014-05-21 15:12     ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Metzger, Markus T @ 2014-05-21  6:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: palves, gdb-patches

> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] On Behalf Of Eli Zaretskii
> Sent: Tuesday, May 20, 2014 6:12 PM

Thanks a lot for your review.

> > From: Markus Metzger <markus.t.metzger@intel.com>
> > Cc: gdb-patches@sourceware.org, Eli Zaretskii <eliz@gnu.org>
> > Date: Tue, 20 May 2014 14:00:34 +0200


> > +Control the behavior of the @code{btrace} recording method when
> 
> Please be consistent about the markup of "btrace": either plain text
> or @code{}; pick one and use it everywhere.

I'm using @code{btrace} when referring to the record target or recording
method, and I'm using just btrace when referring to a GDB command.
I hope that's OK.

I fixed one inconsistency I added with this patch.

Regards,
Markus.
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/3] btrace: control memory access during replay
  2014-05-21  6:10   ` Metzger, Markus T
@ 2014-05-21 15:12     ` Eli Zaretskii
  2014-05-22  6:12       ` Metzger, Markus T
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2014-05-21 15:12 UTC (permalink / raw)
  To: Metzger, Markus T; +Cc: palves, gdb-patches

> From: "Metzger, Markus T" <markus.t.metzger@intel.com>
> CC: "palves@redhat.com" <palves@redhat.com>, "gdb-patches@sourceware.org"
> 	<gdb-patches@sourceware.org>
> Date: Wed, 21 May 2014 06:09:59 +0000
> 
> > > +Control the behavior of the @code{btrace} recording method when
> > 
> > Please be consistent about the markup of "btrace": either plain text
> > or @code{}; pick one and use it everywhere.
> 
> I'm using @code{btrace} when referring to the record target or recording
> method, and I'm using just btrace when referring to a GDB command.
> I hope that's OK.

GDB commands also get the @code markup.

> I fixed one inconsistency I added with this patch.

I hope that was with "btrace record target".

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH v2 1/3] btrace: control memory access during replay
  2014-05-21 15:12     ` Eli Zaretskii
@ 2014-05-22  6:12       ` Metzger, Markus T
  2014-05-22 14:58         ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Metzger, Markus T @ 2014-05-22  6:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: palves, gdb-patches

> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] On Behalf Of Eli Zaretskii
> Sent: Wednesday, May 21, 2014 5:13 PM


> > I fixed one inconsistency I added with this patch.
> 
> I hope that was with "btrace record target".

Yes it was.  Is this version OK? https://sourceware.org/ml/gdb-patches/2014-05/msg00457.html

Thanks,
Markus.
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/3] btrace: control memory access during replay
  2014-05-22  6:12       ` Metzger, Markus T
@ 2014-05-22 14:58         ` Eli Zaretskii
  0 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2014-05-22 14:58 UTC (permalink / raw)
  To: Metzger, Markus T; +Cc: palves, gdb-patches

> From: "Metzger, Markus T" <markus.t.metzger@intel.com>
> CC: "palves@redhat.com" <palves@redhat.com>, "gdb-patches@sourceware.org"	<gdb-patches@sourceware.org>
> Date: Thu, 22 May 2014 06:12:00 +0000
> 
> > From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> > owner@sourceware.org] On Behalf Of Eli Zaretskii
> > Sent: Wednesday, May 21, 2014 5:13 PM
> 
> 
> > > I fixed one inconsistency I added with this patch.
> > 
> > I hope that was with "btrace record target".
> 
> Yes it was.  Is this version OK? https://sourceware.org/ml/gdb-patches/2014-05/msg00457.html

Yes, it's fine.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-05-22 14:58 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-20 12:01 [PATCH v2 1/3] btrace: control memory access during replay Markus Metzger
2014-05-20 12:00 ` [PATCH v2 3/3] btrace, vdso: add vdso target sections Markus Metzger
2014-05-20 13:16   ` Pedro Alves
2014-05-20 14:10     ` Metzger, Markus T
2014-05-20 12:00 ` [PATCH v2 2/3] test, gcore: move capture_command_output into lib/gdb.exp Markus Metzger
2014-05-20 12:27   ` Pedro Alves
2014-05-20 12:26 ` [PATCH v2 1/3] btrace: control memory access during replay Pedro Alves
2014-05-20 16:12 ` Eli Zaretskii
2014-05-21  6:10   ` Metzger, Markus T
2014-05-21 15:12     ` Eli Zaretskii
2014-05-22  6:12       ` Metzger, Markus T
2014-05-22 14:58         ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).