From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16284 invoked by alias); 20 Apr 2014 12:50:43 -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 16272 invoked by uid 89); 20 Apr 2014 12:50:43 -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; Sun, 20 Apr 2014 12:50:42 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WbrCh-0005Mt-91 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Sun, 20 Apr 2014 05:50:39 -0700 Received: from SVR-ORW-FEM-06.mgc.mentorg.com ([147.34.97.120]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 20 Apr 2014 05:50:38 -0700 Received: from qiyao.dyndns.org.com (147.34.91.1) by SVR-ORW-FEM-06.mgc.mentorg.com (147.34.97.120) with Microsoft SMTP Server id 14.2.247.3; Sun, 20 Apr 2014 05:50:38 -0700 From: Yao Qi To: Subject: [PATCH] Partially available/unavailable data in requested range Date: Sun, 20 Apr 2014 12:50:00 -0000 Message-ID: <1397998086-750-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-04/txt/msg00395.txt.bz2 I am testing again my pending patches "Visit varobj available children only in MI" and find a regression in mi-available-children-only.exp, in which we collect part of the fields of struct simple, struct simple { int a; /* Collected by both. */ int b; /* Collected by action 2. */ struct { struct { int g; /* Collected by action 1. */ int h; /* Collected by action 2. */ } s3; int d; /* Collected by action 1. */ } s1; struct { int e; int f; /* Collected by action 1. */ } s2; }; When GDB examine traceframe collected by action 1, some collected fields are unavailable, which is wrong. (gdb) p s $1 = {a = 0, b = , s1 = {s3 = {g = , h = }, d = }, s2 = {e = , f = }} 1. When GDB reads struct 's', it will request to read memory at address S of length 28. Since s.a is collected while s.b isn't, tfile_xfer_partial will return TARGET_XFER_OK and *xfered_len is set to 4 (length of s.a). 2. Then, GDB request to read memory at address S + 4 of length 24. No block includes the first part of the desired range, so tfile_xfer_partial returns TARGET_XFER_UNAVAILABLE and GDB thinks the range [S + 4, S + 28) is unavailable. In order to fix this problem, in the iteration to 'M' blocks, we record the minimal 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 mi-available-children-only.exp are fixed as a result. (gdb) p s $1 = {a = 0, b = , s1 = {s3 = {g = 0, h = }, d = 0}, s2 = {e = , f = 0}} I don't add a test case for it because mi-available-children-only.exp will cover it. gdb: 2014-04-20 Yao Qi * tracefile-tfile.c (tfile_xfer_partial): Record the minimal address of blocks and return TARGET_XFER_UNAVAILABLE if it is within the requested range. * ctf.c (ctf_xfer_partial): Likewise. --- gdb/ctf.c | 18 ++++++++++++++++++ gdb/tracefile-tfile.c | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/gdb/ctf.c b/gdb/ctf.c index bac7c28..253548d 100644 --- a/gdb/ctf.c +++ b/gdb/ctf.c @@ -1328,6 +1328,7 @@ ctf_xfer_partial (struct target_ops *ops, enum target_object object, struct bt_iter_pos *pos; int i = 0; enum target_xfer_status res; + ULONGEST min_addr_available = 0; gdb_assert (ctf_iter != NULL); /* Save the current position. */ @@ -1410,6 +1411,13 @@ ctf_xfer_partial (struct target_ops *ops, enum target_object object, } } + /* If the block is within the desired range, the desired + range isn't fully unavailable. Record the minimal address + of blocks. */ + if (offset < maddr && maddr < (offset + len)) + if (min_addr_available == 0 || min_addr_available > maddr) + min_addr_available = maddr; + if (bt_iter_next (bt_ctf_get_iter (ctf_iter)) < 0) break; } @@ -1417,6 +1425,16 @@ ctf_xfer_partial (struct target_ops *ops, enum target_object object, /* Restore the position. */ bt_iter_set_pos (bt_ctf_get_iter (ctf_iter), pos); + /* There should be at least one block within desired range, and + range [OFFSET, MIN_ADDR_AVAILABLE) is unavailable. Tell + caller about it and caller will request memory from + MIN_ADDR_AVAILABLE. */ + if (offset < min_addr_available) + { + *xfered_len = min_addr_available - offset; + return TARGET_XFER_UNAVAILABLE; + } + /* Requested memory is unavailable in the context of traceframes, and this address falls within a read-only section, fallback to reading from executable. */ diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index efa69b2..472f387 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -853,6 +853,7 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object, { int pos = 0; enum target_xfer_status res; + ULONGEST min_addr_available = 0; /* Iterate through the traceframe's blocks, looking for memory. */ @@ -886,10 +887,27 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object, return TARGET_XFER_OK; } + /* If the block is within the desired range, the desired + range isn't fully unavailable. Record the minimal address + of blocks. */ + if (offset < maddr && maddr < (offset + len)) + if (min_addr_available == 0 || min_addr_available > maddr) + min_addr_available = maddr; + /* Skip over this block. */ pos += (8 + 2 + mlen); } + /* There should be at least one block within desired range, and + range [OFFSET, MIN_ADDR_AVAILABLE) is unavailable. Tell + caller about it and caller will request memory from + MIN_ADDR_AVAILABLE. */ + if (offset < min_addr_available) + { + *xfered_len = min_addr_available - offset; + return TARGET_XFER_UNAVAILABLE; + } + /* Requested memory is unavailable in the context of traceframes, and this address falls within a read-only section, fallback to reading from executable. */ -- 1.9.0