From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14162 invoked by alias); 20 Mar 2013 11:40:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 14126 invoked by uid 89); 20 Mar 2013 11:40:28 -0000 X-Spam-SWARE-Status: No, score=-8.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 20 Mar 2013 11:40:25 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2KBeK2V018006 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 20 Mar 2013 07:40:22 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2KBeIQ2024170; Wed, 20 Mar 2013 07:40:19 -0400 Message-ID: <5149A022.7070302@redhat.com> Date: Wed, 20 Mar 2013 11:57:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 MIME-Version: 1.0 To: Yao Qi CC: gdb-patches@sourceware.org Subject: Re: [PATCH] Rely on beneath to do partial xfer from tfile target References: <1363774156-31949-1-git-send-email-yao@codesourcery.com> In-Reply-To: <1363774156-31949-1-git-send-email-yao@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-03/txt/msg00732.txt.bz2 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 = 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, or printing the value of the variable in the executable. The latter seems to me the least desirable, with 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 Yao Qi * 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" \ + " = " "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"