[PATCH] Rely on beneath to do partial xfer from tfile target

Pedro Alves palves@redhat.com
Wed Mar 20 11:57:00 GMT 2013


On 03/20/2013 10:09 AM, Yao Qi wrote:

> This patch is to revert some changes from this patch
> 
>   [PATCH] Do partial xfers from trace file
>   http://sourceware.org/ml/gdb-patches/2010-04/msg00082.html

Stan mentioned:

"I also made the tfile target has_all_memory, and added an emulation of QTro behavior, which
 lets disassembly and the like work, but rejects attempts to print non-constant globals
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 that were not collected."
 ^^^^^^^^^^^^^^^^^^^^^^^^

That predated the whole target_traceframe_info/traceframe_available_memory
mechanism.  If we disable it, with:

 diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
 index 71af22b..6d7bc1e 100644
 --- a/gdb/tracepoint.c
 +++ b/gdb/tracepoint.c
 @@ -5141,6 +5141,7 @@ tfile_traceframe_info (void)
    struct traceframe_info *info = XCNEW (struct traceframe_info);
  
    traceframe_walk_blocks (build_traceframe_info, 0, info);
 +  return NULL;
    return info;
  }
 
Then, without your patch, we get:

 (gdb) p non_const_not_collected_glob 
 Cannot access memory at address 0x601324

But with your patch, we'd get:

 (gdb) p non_const_not_collected_glob 
 $1 = 14124

But since we do have the target_traceframe_info mechanism,
then we always get:

 (gdb) p non_const_not_collected_glob 
 $1 = <unavailable>

Which is better than the original error.  So far so good.

But the patch has another related change in behavior which
it didn't look like was considered.  If we load the tfile target,
but we're not yet looking at any trace frame, we currently get:

 (gdb) p testglob
 Cannot access memory at address 0x60131c

With your patch, we now get:

 (gdb) p testglob
 $1 = 31415

So we're left discussing whether that is a desirable change.
I can see arguments for error, <unavailable> or printing
the value of the variable in the executable.  The latter seems
to me the least desirable, with <unavailable> perhaps being
the best one?

Meanwhile, I've applied this testsuite patch that covers
the behavior that the patch doesn't change, WRT to non-const
globals, and your disassembly bit.

Thanks!

------------------------
Subject: tfile.exp: Test printing a non-const global that is not covered by the trace frame; test disassembling.

Make sure we don't fallback to printing the initial value of a
non-const variable in the executable.

Also make sure we can do 'disassemble', as another test that GDB is
able to read read-only parts from the executable (the existing test of
printing constglob also covers that case).

gdb/testsuite/
2013-03-20  Pedro Alves  <palves@redhat.com>
	    Yao Qi <yao@codesourcery.com>

	* gdb.trace/tfile.c: Add comments.
	(nonconstglob): New global.
	* gdb.trace/tfile.exp: Add comments.  Test printing a non-const
	global that is not covered by the trace frame.  Test
	disassembling.
---
 gdb/testsuite/gdb.trace/tfile.c   |    6 ++++++
 gdb/testsuite/gdb.trace/tfile.exp |   15 +++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/gdb/testsuite/gdb.trace/tfile.c b/gdb/testsuite/gdb.trace/tfile.c
index 11c79d9..7c0c774 100644
--- a/gdb/testsuite/gdb.trace/tfile.c
+++ b/gdb/testsuite/gdb.trace/tfile.c
@@ -13,12 +13,18 @@ char trbuf[1000];
 char *trptr;
 char *tfsizeptr;
 
+/* These globals are put in the trace buffer.  */
+
 int testglob = 31415;
 
 int testglob2 = 271828;
 
+/* But these below are not.  */
+
 const int constglob = 10000;
 
+int nonconstglob = 14124;
+
 int
 start_trace_file (char *filename)
 {
diff --git a/gdb/testsuite/gdb.trace/tfile.exp b/gdb/testsuite/gdb.trace/tfile.exp
index 2bdde37..56e2a79 100644
--- a/gdb/testsuite/gdb.trace/tfile.exp
+++ b/gdb/testsuite/gdb.trace/tfile.exp
@@ -64,8 +64,23 @@ gdb_test "print testglob" " = 31415" "print testglob on trace file"
 
 gdb_test "print testglob2" " = 271828" "print testglob2 on trace file"
 
+# This global is not covered by the trace frame, but since it's const,
+# we should be able to read it from the executable.
+
 gdb_test "print constglob" " = 10000" "print constglob on trace file"
 
+# Similarly, disassembly should find the read-only pieces in the executable.
+gdb_test "disassemble main" \
+    "Dump of assembler code for function main:.*   $hex <\\+0\\>:.*End of assembler dump\."
+
+# This global is also not covered by the trace frame, and since it's
+# non-const, we should _not_ read it from the executable, as that
+# would show the variable's initial value, not the current at time the
+# trace frame was created.
+
+gdb_test "print nonconstglob" \
+    " = <unavailable>" "print nonconstglob on trace file"
+
 gdb_test "tfind" "Target failed to find requested trace frame." \
     "tfind does not find a second frame in trace file"
 




More information about the Gdb-patches mailing list