Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH]tracepoint.c: tfile_xfer_partial change lma to vma
@ 2010-10-31  7:02 Hui Zhu
  2010-10-31  9:09 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Hui Zhu @ 2010-10-31  7:02 UTC (permalink / raw)
  To: gdb-patches ml

Hi,

KGTP(https://code.google.com/p/kgtp/) can generate tfile in /proc/gtpframe.
When use GDB to open the tfile that get from kgtp in amd64, I got a error:
(gdb) target tfile ./gtpframe
Cannot access memory at address 0xffffffff81140430

I got this error because in tfile_xfer_partial:
     bfd_vma lma;

      for (s = exec_bfd->sections; s; s = s->next)
	{
	  if ((s->flags & SEC_LOAD) == 0 ||
	      (s->flags & SEC_READONLY) == 0)
	    continue;

	  lma = s->lma;
	  size = bfd_get_section_size (s);
	  if (lma <= offset && offset < (lma + size))
	    {
	      amt = (lma + size) - offset;

It use lma to check if the address is in the section.

But in amd64-linux kernel, the vma is different from lma, for example:

./vmlinux:     file format elf64-x86-64

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         005a24dd  ffffffff81000000  0000000001000000  00200000  2**12
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .notes        0000017c  ffffffff815a24e0  00000000015a24e0  007a24e0  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  2 __ex_table    00004260  ffffffff815a2660  00000000015a2660  007a2660  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .rodata       00219825  ffffffff81600000  0000000001600000  00800000  2**6
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 __bug_table   000075a8  ffffffff81819828  0000000001819828  00a19828  2**0

And when kernel exec, the address is in vma.

So  tfile_xfer_partial cannot get the value use lma.

So I make a patch to change lma to vma in tfile_xfer_partial.  Then
the kernel tfile is OK to parse by gdb.

Thanks,
Hui

2010-10-31  Hui Zhu  <teawater@gmail.com>

	* tracepoint.c (tfile_xfer_partial): Change lma to vma.
---
 tracepoint.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--- a/tracepoint.c
+++ b/tracepoint.c
@@ -3991,7 +3991,7 @@ tfile_xfer_partial (struct target_ops *o
     {
       asection *s;
       bfd_size_type size;
-      bfd_vma lma;
+      bfd_vma vma;

       for (s = exec_bfd->sections; s; s = s->next)
 	{
@@ -3999,16 +3999,16 @@ tfile_xfer_partial (struct target_ops *o
 	      (s->flags & SEC_READONLY) == 0)
 	    continue;

-	  lma = s->lma;
+	  vma = s->vma;
 	  size = bfd_get_section_size (s);
-	  if (lma <= offset && offset < (lma + size))
+	  if (vma <= offset && offset < (vma + size))
 	    {
-	      amt = (lma + size) - offset;
+	      amt = (vma + size) - offset;
 	      if (amt > len)
 		amt = len;

 	      amt = bfd_get_section_contents (exec_bfd, s,
-					      readbuf, offset - lma, amt);
+					      readbuf, offset - vma, amt);
 	      return amt;
 	    }
 	}


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

* Re: [PATCH]tracepoint.c: tfile_xfer_partial change lma to vma
  2010-10-31  7:02 [PATCH]tracepoint.c: tfile_xfer_partial change lma to vma Hui Zhu
@ 2010-10-31  9:09 ` Pedro Alves
  2010-11-01  9:03   ` Hui Zhu
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2010-10-31  9:09 UTC (permalink / raw)
  To: gdb-patches; +Cc: Hui Zhu

On Sunday 31 October 2010 06:00:36, Hui Zhu wrote:
> 2010-10-31  Hui Zhu  <teawater@gmail.com>
> 
>         * tracepoint.c (tfile_xfer_partial): Change lma to vma.

Okay, thanks.

-- 
Pedro Alves


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

* Re: [PATCH]tracepoint.c: tfile_xfer_partial change lma to vma
  2010-10-31  9:09 ` Pedro Alves
@ 2010-11-01  9:03   ` Hui Zhu
  0 siblings, 0 replies; 3+ messages in thread
From: Hui Zhu @ 2010-11-01  9:03 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Thanks.  Checked in.

Hui

On Sun, Oct 31, 2010 at 17:09, Pedro Alves <pedro@codesourcery.com> wrote:
> On Sunday 31 October 2010 06:00:36, Hui Zhu wrote:
>> 2010-10-31  Hui Zhu  <teawater@gmail.com>
>>
>>         * tracepoint.c (tfile_xfer_partial): Change lma to vma.
>
> Okay, thanks.
>
> --
> Pedro Alves
>


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

end of thread, other threads:[~2010-11-01  9:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-31  7:02 [PATCH]tracepoint.c: tfile_xfer_partial change lma to vma Hui Zhu
2010-10-31  9:09 ` Pedro Alves
2010-11-01  9:03   ` Hui Zhu

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