This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix buf inside tracepoint tfile memory read


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]