From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7034 invoked by alias); 1 Apr 2013 02:40:30 -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 7016 invoked by uid 89); 1 Apr 2013 02:40:22 -0000 X-Spam-SWARE-Status: No, score=-4.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL autolearn=ham version=3.3.1 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 01 Apr 2013 02:40:19 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1UMUfQ-0005Fu-LI from Yao_Qi@mentor.com ; Sun, 31 Mar 2013 19:40:16 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 31 Mar 2013 19:40:16 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.1.289.1; Sun, 31 Mar 2013 19:40:15 -0700 Message-ID: <5158F347.6030602@codesourcery.com> Date: Mon, 01 Apr 2013 02:40:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Pedro Alves CC: Subject: Re: [PATCH] Rely on beneath to do partial xfer from tfile target References: <1363774156-31949-1-git-send-email-yao@codesourcery.com> <5149A022.7070302@redhat.com> <514C291B.7010201@codesourcery.com> In-Reply-To: <514C291B.7010201@codesourcery.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-SW-Source: 2013-04/txt/msg00000.txt.bz2 On 03/22/2013 05:49 PM, Yao Qi wrote: > I agree that is the best choice. The "non-const- > not-collected data" should be also, right? If so, I'll > post a patch to change "Cannot access memory at address" to > "". In valops.c:read_value_memory, we have if (get_traceframe_number () < 0 || !traceframe_available_memory (&available_memory, memaddr, length)) { } else { /* Fallback to reading from read-only sections. */ } The code is correct to remote target, however it is not perfect to tfile target when the current traceframe is not selected (get_traceframe_number returns -1). In this case, GDB should fall back to the 'else' branch to read from read-only sections, so the fix could be 'don't check the return value of get_traceframe_number and let the target decide where to read data from (live inferior or read-only sections)'. We don't check get_traceframe_number here, means target_ops method 'to_traceframe_info' will be called on many targets, so we change its default to 'return_zero' instead of 'tcomplain'. Fortunately, we make use of an inconsistency of 'to_traceframe_info' of remote target and tfile target. That is, when current traceframe number is -1, remote_traceframe_info returns NULL and tfile_traceframe_info return a empty traceframe_info pointer. In this way, the usage of 'to_traceframe_info' is extended, so I add some comments to it. The rationale of this patch is to teach 'to_traceframe_info' returns something different so that GDB is able to tell the differences of targets when current traceframe is not selected. The other caller to traceframe_available_memory is guarded by 'get_traceframe_number () != -1', so changes here don't affect it. Regression tested on x86_64-linux. Is it OK? -- Yao (齐尧) gdb: 2013-04-01 Yao Qi * target.c (update_current_target): Change the default action of 'to_traceframe_info' from tcomplain to return_zero. * target.h (struct target_ops) : Add more comments. * valops.c (read_value_memory): Call traceframe_available_memory unconditionally. gdb/testsuite: 2013-04-01 Yao Qi * gdb.trace/read-memory.exp (test_from_remote): Update test. (teset_from_exec): Likewise. --- gdb/target.c | 2 +- gdb/target.h | 15 ++++++++++++--- gdb/testsuite/gdb.trace/read-memory.exp | 10 ++++------ gdb/valops.c | 3 +-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/gdb/target.c b/gdb/target.c index 9193c97..97da6b1 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -948,7 +948,7 @@ update_current_target (void) tcomplain); de_fault (to_traceframe_info, (struct traceframe_info * (*) (void)) - tcomplain); + return_zero); de_fault (to_supports_evaluation_of_breakpoint_conditions, (int (*) (void)) return_zero); diff --git a/gdb/target.h b/gdb/target.h index ee3fbff..072117e 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -850,9 +850,18 @@ struct target_ops (const char *id); /* Return a traceframe info object describing the current - traceframe's contents. This method should not cache data; - higher layers take care of caching, invalidating, and - re-fetching when necessary. */ + traceframe's contents. If the target doesn't support + traceframe info, return NULL. If the current traceframe is not + selected (the current traceframe number is -1), the target can + choose to return either NULL or an empty traceframe info. If + NULL is returned, for example in remote target, GDB will read + from the live inferior. If an empty traceframe info is + returned, for example in tfile target, which means the + traceframe info is available, but the requested memory is not + available in it. GDB will try to see if the requested memory + is available in the read-only sections. This method should not + cache data; higher layers take care of caching, invalidating, + and re-fetching when necessary. */ struct traceframe_info *(*to_traceframe_info) (void); /* Ask the target to use or not to use agent according to USE. Return 1 diff --git a/gdb/testsuite/gdb.trace/read-memory.exp b/gdb/testsuite/gdb.trace/read-memory.exp index e7c0af3..21b0e7e 100644 --- a/gdb/testsuite/gdb.trace/read-memory.exp +++ b/gdb/testsuite/gdb.trace/read-memory.exp @@ -104,9 +104,8 @@ proc test_from_remote { target } { } with_test_prefix "/wo setting traceframe" { - gdb_test "print testglob" "Cannot access memory at address.*" - gdb_test "print testglob_not_collected" \ - "Cannot access memory at address.*" + gdb_test "print testglob" " = " + gdb_test "print testglob_not_collected" " = " gdb_test "print constglob" " = 10000" gdb_test "print constglob_not_collected" " = 100" } @@ -141,9 +140,8 @@ proc teset_from_exec { target } { "change to ${target} target" with_test_prefix "exec to ${target} /wo setting traceframe" { - gdb_test "print testglob" "Cannot access memory at address.*" - gdb_test "print testglob_not_collected" \ - "Cannot access memory at address.*" + gdb_test "print testglob" " = " + gdb_test "print testglob_not_collected" " = " gdb_test "print constglob" " = 10000" gdb_test "print constglob_not_collected" " = 100" } diff --git a/gdb/valops.c b/gdb/valops.c index 93c09d8..80b9995 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1117,8 +1117,7 @@ read_value_memory (struct value *val, int embedded_offset, { VEC(mem_range_s) *available_memory; - if (get_traceframe_number () < 0 - || !traceframe_available_memory (&available_memory, memaddr, length)) + if (!traceframe_available_memory (&available_memory, memaddr, length)) { if (stack) read_stack (memaddr, buffer, length); -- 1.7.7.6