From: Hui Zhu <teawater@gmail.com>
To: gdb-patches ml <gdb-patches@sourceware.org>
Subject: [PATCH]tracepoint.c: tfile_xfer_partial change lma to vma
Date: Sun, 31 Oct 2010 07:02:00 -0000 [thread overview]
Message-ID: <AANLkTimQ3q7j0UBZJWr=axkww1oATr5YC4dMgyyifbQm@mail.gmail.com> (raw)
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;
}
}
next reply other threads:[~2010-10-31 7:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-31 7:02 Hui Zhu [this message]
2010-10-31 9:09 ` Pedro Alves
2010-11-01 9:03 ` Hui Zhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='AANLkTimQ3q7j0UBZJWr=axkww1oATr5YC4dMgyyifbQm@mail.gmail.com' \
--to=teawater@gmail.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).