From: Dave Korn <dave.korn.cygwin@googlemail.com>
To: Paul Pluzhnikov <ppluzhnikov@google.com>
Cc: binutils@sourceware.org, Tom Tromey <tromey@redhat.com>,
gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: How to get file descriptor from abfd?
Date: Sun, 31 May 2009 18:12:00 -0000 [thread overview]
Message-ID: <4A22CB56.3070704@gmail.com> (raw)
In-Reply-To: <8ac60eac0905311056l3b8edf98rc6abfe28853e0b6d@mail.gmail.com>
Paul Pluzhnikov wrote:
> Currently GDB allocates memory and does a bfd_read() on dwarf debug sections.
>
> This causes GDB to be significantly slower on low-memory machines than
> it has to be, and I have a patch to fix this by directly mmap()ing the
> debug sections instead:
> http://sourceware.org/ml/gdb-patches/2009-05/txt00023.txt
>
> In that patch, I do:
>
> + caddr_t retbuf = mmap (0, map_length, PROT_READ, MAP_PRIVATE,
> + fileno ((FILE *)abfd->iostream),
> + pg_offset);
>
> and this cast of abfd->iostream has been flagged as possibly un-kosher.
>
> What is the proper way to get access to the underlying file descriptor
> for a given abfd (if there is one)?
> If there isn't a way, should there be?
It's a bad idea, because anything you do to that FILE* might confuse the
underlying bfd_iovec stream. The cleanest design would be to add an mmap
member function to bfd_iovec.
> I would have used bfd_get_file_window(), but it's only compiled in
> when --use-mmap was given to bfd/configure.
>
> Is there a way to turn that on for GDB?
Just configure with it. It will be passed to the included bfd/ configure.
> Is it ok to do this:
>
> if ((abfd->flags & BFD_IN_MEMORY) == 0) ...
>
> in gdb/dwarf2read.c?
Won't be necessary if you do it the iovec way, there will just be a stub
implementation of 'bmmap()' for in-memory iovecs and a real one (conditioned
on HAVE_MMAP) for file-based iovecs. Then gdb can call the bfd_mmap wrapper
function speculatively and just fall back to the old way of doing it if that
returns an error code.
cheers,
DaveK
next prev parent reply other threads:[~2009-05-31 18:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-31 17:56 Paul Pluzhnikov
2009-05-31 18:12 ` Dave Korn [this message]
2009-06-02 5:55 ` Paul Pluzhnikov
2009-06-08 16:10 ` Paul Pluzhnikov
2009-06-10 15:14 ` Dave Korn
2009-06-10 17:09 ` Paul Pluzhnikov
2009-06-10 23:59 ` Alan Modra
2009-06-11 0:42 ` Paul Pluzhnikov
2009-06-11 2:14 ` Dave Korn
2009-06-11 3:28 ` Dave Korn
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=4A22CB56.3070704@gmail.com \
--to=dave.korn.cygwin@googlemail.com \
--cc=binutils@sourceware.org \
--cc=gdb-patches@sourceware.org \
--cc=ppluzhnikov@google.com \
--cc=tromey@redhat.com \
/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