From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29326 invoked by alias); 15 Jun 2012 10:29:28 -0000 Received: (qmail 29316 invoked by uid 22791); 15 Jun 2012 10:29:26 -0000 X-SWARE-Spam-Status: No, hits=-4.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-wg0-f43.google.com (HELO mail-wg0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 15 Jun 2012 10:29:14 +0000 Received: by wgbdr1 with SMTP id dr1so2206861wgb.12 for ; Fri, 15 Jun 2012 03:29:12 -0700 (PDT) Received: by 10.180.78.228 with SMTP id e4mr3346203wix.4.1339756152679; Fri, 15 Jun 2012 03:29:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.122.193 with HTTP; Fri, 15 Jun 2012 03:28:32 -0700 (PDT) From: Hui Zhu Date: Fri, 15 Jun 2012 10:29:00 -0000 Message-ID: Subject: [PATCH] Fix buf inside tracepoint tfile memory read To: gdb-patches ml , Joel Brobecker Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes 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 X-SW-Source: 2012-06/txt/msg00504.txt.bz2 Hi, When I try tfile with KGTP, got some error that tfine didn't give the right value of memory. So I checked the code and found that: if (maddr <= offset && offset < (maddr + mlen)) { amt = (maddr + mlen) - offset; if (amt > len) amt = len; tfile_read (readbuf, amt); return amt; } This part code is for memroy read form tfile. But if the offset is not same with maddr, it will not read from the right part. Because this code always read from the 0 offset of this part of memory. So I add some code to handle this issue, and it is fixed. Please help me review it. Joel, I remember GDB will release a new version after 3 weeks. I suggest this issue be fixed before this release. Thanks, Hui 2012-06-15 Hui Zhu * tracepoint.c (tfile_xfer_partial): Add a lseek. --- tracepoint.c | 2 ++ 1 file changed, 2 insertions(+) --- a/tracepoint.c +++ b/tracepoint.c @@ -4545,6 +4545,8 @@ tfile_xfer_partial (struct target_ops *o if (amt > len) amt = len; + if (maddr != offset) + lseek (trace_fd, offset - maddr, SEEK_CUR); tfile_read (readbuf, amt); return amt; }