From patchwork Mon Apr 28 06:12:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 696 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 312DD36007A for ; Sun, 27 Apr 2014 23:16:17 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14314964) id D45AC4F90384; Sun, 27 Apr 2014 23:16:16 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx22.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id AE7AF4F90382 for ; Sun, 27 Apr 2014 23:16:16 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type; q=dns; s=default; b=nYKaI msTgzxVB6UVveob1gsfjEpCFfOrdgbhSDfEwjdlDiy1FKSuHV0jOPYhKucAw66mL ybDswHO4pyb1Ezcl38LRyZ9OZDlZKzRTP9/aVTMA9F3LPsRrcYhGDnet79TlsBp+ ZPt+V93iBAQT7WSrtxpMesG2pkk+ZSHmBP5smo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type; s=default; bh=p2+e5t27Flt 19ndmok45/RPoQ2U=; b=jOKClTXoox23Iunh3v2lfap+wk/e8Xsiga+Ch0DVx9S 5g9ce1qi5Cemd+W+ZnvYwWzIgizuWT7azKAM++mW34Hf+osKaDsNbExwMB01hba7 2Ph16ut+MKq5IYRNWGz40bZsGiNkdMW5QGUMTjUXd/70u0/MH749EC5S8s+5/klM = Received: (qmail 19226 invoked by alias); 28 Apr 2014 06:15:24 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 19110 invoked by uid 89); 28 Apr 2014 06:15:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 28 Apr 2014 06:15:22 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WeeqV-0005ut-10 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Sun, 27 Apr 2014 23:15:19 -0700 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 27 Apr 2014 23:15:18 -0700 Received: from qiyao.dyndns.org.com (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Sun, 27 Apr 2014 23:15:18 -0700 From: Yao Qi To: Subject: [PATCH 4/4] Partially available/unavailable data in requested range Date: Mon, 28 Apr 2014 14:12:18 +0800 Message-ID: <1398665538-16580-5-git-send-email-yao@codesourcery.com> In-Reply-To: <1398665538-16580-1-git-send-email-yao@codesourcery.com> References: <1398665538-16580-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in In gdb.trace/unavailable.exp, an action is defined to collect struct_b.struct_a.array[2] and struct_b.struct_a.array[100], struct StructB { int d, ef; StructA struct_a; int s:1; static StructA static_struct_a; const char *string; }; and the other fields are not collected. When GDB examine traceframe collected by the action, "struct_b" is unavailable completely, which is wrong. (gdb) p struct_b $1 = When GDB reads 'struct_b', it will request to read memory at struct_b's address of length LEN. Since struct_b.d is not collected, no 'M' block includes the first part of the desired range, so tfile_xfer_partial returns TARGET_XFER_UNAVAILABLE and GDB thinks the whole requested range is unavailable. In order to fix this problem, in the iteration to 'M' blocks, we record the lowest address of blocks within the request range. If it has, the requested range isn't unavailable completely. This applies to ctf too. With this patch applied, the result looks good and fails in unavailable.exp is fixed. (gdb) p struct_b $1 = {d = , ef = , struct_a = {a = , b = , array = {, , -1431655766, , -1431655766, }, ptr = , bitfield = }, s = , static static_struct_a = {a = , b = , array = { }, ptr = , bitfield = }, string = } gdb: 2014-04-26 Yao Qi Pedro Alves * tracefile-tfile.c (tfile_xfer_partial): Record the lowest address of blocks that intersects the requested range. Trim LEN up to LOW_ADDR_AVAILABLE if read from executable read-only sections. * ctf.c (ctf_xfer_partial): Likewise. --- gdb/ctf.c | 11 ++++++++++- gdb/tracefile-tfile.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/gdb/ctf.c b/gdb/ctf.c index bac7c28..84d0a48 100644 --- a/gdb/ctf.c +++ b/gdb/ctf.c @@ -1328,6 +1328,9 @@ ctf_xfer_partial (struct target_ops *ops, enum target_object object, struct bt_iter_pos *pos; int i = 0; enum target_xfer_status res; + /* Records the lowest available address of all blocks that + intersects the requested range. */ + ULONGEST low_addr_available = 0; gdb_assert (ctf_iter != NULL); /* Save the current position. */ @@ -1410,6 +1413,10 @@ ctf_xfer_partial (struct target_ops *ops, enum target_object object, } } + if (offset < maddr && maddr < (offset + len)) + if (low_addr_available == 0 || low_addr_available > maddr) + low_addr_available = maddr; + if (bt_iter_next (bt_ctf_get_iter (ctf_iter)) < 0) break; } @@ -1419,7 +1426,9 @@ ctf_xfer_partial (struct target_ops *ops, enum target_object object, /* Requested memory is unavailable in the context of traceframes, and this address falls within a read-only section, fallback - to reading from executable. */ + to reading from executable, up to LOW_ADDR_AVAILABLE */ + if (offset < low_addr_available) + len = min (len, low_addr_available - offset); res = exec_read_partial_read_only (readbuf, offset, len, xfered_len); if (res == TARGET_XFER_OK) diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index efa69b2..37dc691 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -853,6 +853,9 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object, { int pos = 0; enum target_xfer_status res; + /* Records the lowest available address of all blocks that + intersects the requested range. */ + ULONGEST low_addr_available = 0; /* Iterate through the traceframe's blocks, looking for memory. */ @@ -886,13 +889,19 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object, return TARGET_XFER_OK; } + if (offset < maddr && maddr < (offset + len)) + if (low_addr_available == 0 || low_addr_available > maddr) + low_addr_available = maddr; + /* Skip over this block. */ pos += (8 + 2 + mlen); } /* Requested memory is unavailable in the context of traceframes, and this address falls within a read-only section, fallback - to reading from executable. */ + to reading from executable, up to LOW_ADDR_AVAILABLE. */ + if (offset < low_addr_available) + len = min (len, low_addr_available - offset); res = exec_read_partial_read_only (readbuf, offset, len, xfered_len); if (res == TARGET_XFER_OK)