public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* How to get file descriptor from abfd?
@ 2009-05-31 17:56 Paul Pluzhnikov
  2009-05-31 18:12 ` Dave Korn
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Pluzhnikov @ 2009-05-31 17:56 UTC (permalink / raw)
  To: binutils; +Cc: Tom Tromey, gdb-patches ml

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-06-11  3:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-31 17:56 How to get file descriptor from abfd? Paul Pluzhnikov
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

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).