Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: binutils@sourceware.org
Cc: Tom Tromey <tromey@redhat.com>,
	        gdb-patches ml <gdb-patches@sourceware.org>
Subject: How to get file descriptor from abfd?
Date: Sun, 31 May 2009 17:56:00 -0000	[thread overview]
Message-ID: <8ac60eac0905311056l3b8edf98rc6abfe28853e0b6d@mail.gmail.com> (raw)

Greetings,

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?

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?

The  bfd_get_file_window() performs above cast, after checking for:

      (abfd->flags & BFD_IN_MEMORY) == 0)

and later

      if (abfd->iostream == NULL
	  && (abfd->iovec == NULL
	      || abfd->iovec->bseek (abfd, offset, SEEK_SET) != 0))

The last 3 conditions can not be true in gdb/dwarf2read.c because we just
performed bfd_seek and bfd_bread on abfd.

Looks like BFD_IN_MEMORY could be set though.

Is it ok to do this:

  if ((abfd->flags & BFD_IN_MEMORY) == 0) ...

in gdb/dwarf2read.c?

Thanks,
-- 
Paul Pluzhnikov


             reply	other threads:[~2009-05-31 17:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-31 17:56 Paul Pluzhnikov [this message]
2009-05-31 18:12 ` Dave Korn
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=8ac60eac0905311056l3b8edf98rc6abfe28853e0b6d@mail.gmail.com \
    --to=ppluzhnikov@google.com \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --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