This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH]tracepoint.c: tfile_xfer_partial change lma to vma
- From: Hui Zhu <teawater at gmail dot com>
- To: gdb-patches ml <gdb-patches at sourceware dot org>
- Date: Sun, 31 Oct 2010 14:00:36 +0800
- Subject: [PATCH]tracepoint.c: tfile_xfer_partial change lma to vma
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;
}
}