From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1913 invoked by alias); 31 Oct 2010 07:02:38 -0000 Received: (qmail 1742 invoked by uid 22791); 31 Oct 2010 07:02:27 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,TW_KG X-Spam-Check-By: sourceware.org Received: from mail-wy0-f169.google.com (HELO mail-wy0-f169.google.com) (74.125.82.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 31 Oct 2010 07:01:55 +0000 Received: by wyf23 with SMTP id 23so4790693wyf.0 for ; Sun, 31 Oct 2010 00:00:42 -0700 (PDT) Received: by 10.216.3.145 with SMTP id 17mr1115196weh.109.1288504857355; Sat, 30 Oct 2010 23:00:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.182.139 with HTTP; Sat, 30 Oct 2010 23:00:36 -0700 (PDT) From: Hui Zhu Date: Sun, 31 Oct 2010 07:02:00 -0000 Message-ID: Subject: [PATCH]tracepoint.c: tfile_xfer_partial change lma to vma To: gdb-patches ml Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-10/txt/msg00403.txt.bz2 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 * 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; } }