Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix buf inside tracepoint tfile memory read
@ 2012-06-15 10:29 Hui Zhu
  2012-06-15 15:07 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Hui Zhu @ 2012-06-15 10:29 UTC (permalink / raw)
  To: gdb-patches ml, Joel Brobecker

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  <hui_zhu@mentor.com>

	* 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;
 	    }


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix buf inside tracepoint tfile memory read
  2012-06-15 10:29 [PATCH] Fix buf inside tracepoint tfile memory read Hui Zhu
@ 2012-06-15 15:07 ` Pedro Alves
  2012-06-16 15:33   ` Hui Zhu
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2012-06-15 15:07 UTC (permalink / raw)
  To: Hui Zhu; +Cc: gdb-patches ml, Joel Brobecker

On 06/15/2012 11:28 AM, Hui Zhu wrote:

> 2012-06-15  Hui Zhu  <hui_zhu@mentor.com>
> 
> 	* tracepoint.c (tfile_xfer_partial): Add a lseek.


Okay, thanks.

I wonder if a testcase could be constructed?

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix buf inside tracepoint tfile memory read
  2012-06-15 15:07 ` Pedro Alves
@ 2012-06-16 15:33   ` Hui Zhu
  0 siblings, 0 replies; 3+ messages in thread
From: Hui Zhu @ 2012-06-16 15:33 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches ml, Joel Brobecker

On Fri, Jun 15, 2012 at 11:06 PM, Pedro Alves <palves@redhat.com> wrote:
> On 06/15/2012 11:28 AM, Hui Zhu wrote:
>
>> 2012-06-15  Hui Zhu  <hui_zhu@mentor.com>
>>
>>       * tracepoint.c (tfile_xfer_partial): Add a lseek.
>
>
> Okay, thanks.
>
> I wonder if a testcase could be constructed?
>
> --
> Pedro Alves

Thanks.  Checked in.

http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.14375&r2=1.14376
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/tracepoint.c.diff?cvsroot=src&r1=1.257&r2=1.258

I will post the test for it later.

Best,
Hui


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-16 15:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-15 10:29 [PATCH] Fix buf inside tracepoint tfile memory read Hui Zhu
2012-06-15 15:07 ` Pedro Alves
2012-06-16 15:33   ` Hui Zhu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox