From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24724 invoked by alias); 2 Dec 2013 10:36:47 -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 24713 invoked by uid 89); 2 Dec 2013 10:36:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.3 required=5.0 tests=AWL,BAYES_50,RDNS_NONE,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Dec 2013 10:36:45 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rB2AaZQE006676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 2 Dec 2013 05:36:35 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rB2AaWQ7002221; Mon, 2 Dec 2013 05:36:33 -0500 Message-ID: <529C62B0.1030402@redhat.com> Date: Mon, 02 Dec 2013 10:36:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Yao Qi CC: Doug Evans , gdb-patches@sourceware.org Subject: Re: [PATCH] Delegate to target_ops->beneath to read cache lines References: <1385554824-7159-1-git-send-email-yao@codesourcery.com> <5295F877.3060004@redhat.com> <52980180.1050000@codesourcery.com> <529C232A.7080900@codesourcery.com> In-Reply-To: <529C232A.7080900@codesourcery.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-12/txt/msg00027.txt.bz2 On 12/02/2013 06:05 AM, Yao Qi wrote: > On 11/30/2013 03:42 AM, Doug Evans wrote: >> I think a comment is required here explaining why things are the way they are. >> i.e., why we use current_target.beneath instead of ¤t_target. > > I find the comments in target_read_memory can do some explanations, > so I copy that paragraph here. Is it clear to you? > I'd much prefer following my suggestion: https://sourceware.org/ml/gdb-patches/2013-11/msg00941.html Note we already have a target_write_raw_memory function. Do you see a problem with this? --------- Add new target_read_raw_memory function, and consolidate comments. Tested on x86_64 Fedora 17. gdb/ 2013-12-02 Pedro Alves * dcache.c (dcache_read_line): Use target_read_raw_memory. * target.c (target_read_raw_memory): New function. (target_read_stack, target_write_memory, target_write_raw_memory): Update comment. (target_read_core): Add comment. * target.h (target_read_raw_memory): Declare. --- gdb/dcache.c | 11 +++++------ gdb/target.c | 34 ++++++++++++++++++++++++---------- gdb/target.h | 3 +++ 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/gdb/dcache.c b/gdb/dcache.c index 12d1a4b..804d567 100644 --- a/gdb/dcache.c +++ b/gdb/dcache.c @@ -337,14 +337,13 @@ dcache_read_line (DCACHE *dcache, struct dcache_block *db) continue; } - res = target_read (current_target.beneath, TARGET_OBJECT_RAW_MEMORY, - NULL, myaddr, memaddr, reg_len); - if (res < reg_len) + res = target_read_raw_memory (memaddr, myaddr, reg_len); + if (res != 0) return 0; - memaddr += res; - myaddr += res; - len -= res; + memaddr += reg_len; + myaddr += reg_len; + len -= reg_len; } return 1; diff --git a/gdb/target.c b/gdb/target.c index 6c72e70..85b5037 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -1791,16 +1791,30 @@ target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) return TARGET_XFER_E_IO; } +/* Like target_read_memory, but specify explicitly that this is a read + from the target's raw memory. That is, this read bypasses the + dcache, breakpoint shadowing, etc. */ + +int +target_read_raw_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) +{ + /* See comment in target_read_memory about why the request starts at + current_target.beneath. */ + if (target_read (current_target.beneath, TARGET_OBJECT_RAW_MEMORY, NULL, + myaddr, memaddr, len) == len) + return 0; + else + return TARGET_XFER_E_IO; +} + /* Like target_read_memory, but specify explicitly that this is a read from the target's stack. This may trigger different cache behavior. */ int target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) { - /* Dispatch to the topmost target, not the flattened current_target. - Memory accesses check target->to_has_(all_)memory, and the - flattened target doesn't inherit those. */ - + /* See comment in target_read_memory about why the request starts at + current_target.beneath. */ if (target_read (current_target.beneath, TARGET_OBJECT_STACK_MEMORY, NULL, myaddr, memaddr, len) == len) return 0; @@ -1814,6 +1828,8 @@ target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) int target_read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) { + /* See comment in target_read_memory about why the request starts at + current_target.beneath. */ if (target_read (current_target.beneath, TARGET_OBJECT_CODE_MEMORY, NULL, myaddr, memaddr, len) == len) return 0; @@ -1830,9 +1846,8 @@ target_read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) int target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len) { - /* Dispatch to the topmost target, not the flattened current_target. - Memory accesses check target->to_has_(all_)memory, and the - flattened target doesn't inherit those. */ + /* See comment in target_read_memory about why the request starts at + current_target.beneath. */ if (target_write (current_target.beneath, TARGET_OBJECT_MEMORY, NULL, myaddr, memaddr, len) == len) return 0; @@ -1849,9 +1864,8 @@ target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len) int target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len) { - /* Dispatch to the topmost target, not the flattened current_target. - Memory accesses check target->to_has_(all_)memory, and the - flattened target doesn't inherit those. */ + /* See comment in target_read_memory about why the request starts at + current_target.beneath. */ if (target_write (current_target.beneath, TARGET_OBJECT_RAW_MEMORY, NULL, myaddr, memaddr, len) == len) return 0; diff --git a/gdb/target.h b/gdb/target.h index 890171d..f22e5c6 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1051,6 +1051,9 @@ extern int target_read_string (CORE_ADDR, char **, int, int *); extern int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len); +extern int target_read_raw_memory (CORE_ADDR memaddr, gdb_byte *myaddr, + ssize_t len); + extern int target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len); extern int target_read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);