From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [patch] Use mmap instead of obstack_alloc for dwarf debug sections.
Date: Thu, 11 Jun 2009 01:40:00 -0000 [thread overview]
Message-ID: <8ac60eac0906101839t4d3978fyc1c6d3b3e2eccb6e@mail.gmail.com> (raw)
In-Reply-To: <m3vdniw74z.fsf@fleche.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1186 bytes --]
On Sat, May 30, 2009 at 3:36 PM, Tom Tromey<tromey@redhat.com> wrote:
>>>>>> "Paul" == Paul Pluzhnikov <ppluzhnikov@google.com> writes:
>
> Tom> It has a number of minor formatting problems, mostly missing spaces
> Tom> before open parens.
>
> Paul> Sorry, these get me every time :-(
>
> Yeah. Whatever happened to running gdb_indent.sh?
Running gdb_indent.sh on these sources produces way too many incorrect
indentations :-(
I tried my best to have a space before parens this time.
> Paul> I would have used bfd_get_file_window(), but it's only compiled in
> Paul> when --use-mmap was given to bfd/configure.
> Paul> Is there a way to turn that on for GDB?
>
> Paul> Is it ok to do this in gdb/dwarf2read.c:
> Paul> if (info->size > 4 * pagesize && (sectp->flags & SEC_RELOC) == 0
> Paul> && (abfd->flags & BFD_IN_MEMORY) == 0)
>
> I don't know the answer to either of these.
> If nobody here knows, I suggest asking on the binutils list.
> If they aren't ok, maybe we could add a new BFD function for this.
bfd_mmap is now checking in; attached patch uses it.
Tested on Linux/x86_64 with no regressions.
Thanks,
--
Paul Pluzhnikov
[-- Attachment #2: bfd-mmap-patch-20090610.txt --]
[-- Type: text/plain, Size: 4922 bytes --]
Index: bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.482
diff -u -p -u -r1.482 bfd-in2.h
--- bfd-in2.h 1 Jun 2009 13:11:51 -0000 1.482
+++ bfd-in2.h 10 Jun 2009 17:01:28 -0000
@@ -463,6 +463,7 @@ extern int bfd_seek (bfd *, file_ptr, in
extern file_ptr bfd_tell (bfd *);
extern int bfd_flush (bfd *);
extern int bfd_stat (bfd *, struct stat *);
+extern void *bfd_mmap (bfd *, void *, bfd_size_type, int, int, file_ptr);
/* Deprecated old routines. */
#if __GNUC__
Index: bfdio.c
===================================================================
RCS file: /cvs/src/src/bfd/bfdio.c,v
retrieving revision 1.21
diff -u -p -u -r1.21 bfdio.c
--- bfdio.c 24 May 2009 11:47:27 -0000 1.21
+++ bfdio.c 10 Jun 2009 17:01:28 -0000
@@ -158,6 +158,8 @@ DESCRIPTION
. int (*bclose) (struct bfd *abfd);
. int (*bflush) (struct bfd *abfd);
. int (*bstat) (struct bfd *abfd, struct stat *sb);
+. void* (*bmmap) (struct bfd *abfd, void *addr, bfd_size_type len,
+. int prot, int flags, file_ptr offset);
.};
*/
@@ -511,3 +513,31 @@ bfd_get_size (bfd *abfd)
return buf.st_size;
}
+
+
+/*
+FUNCTION
+ bfd_mmap
+
+SYNOPSIS
+ void *bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
+ int prot, int flags, file_ptr offset);
+
+DESCRIPTION
+ Return mmap()ed region of the file, if possible and implemented.
+
+*/
+
+void *
+bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
+ int prot, int flags, file_ptr offset)
+{
+ void *ret = (void *)-1;
+ if ((abfd->flags & BFD_IN_MEMORY) != 0)
+ return ret;
+
+ if (abfd->iovec == NULL)
+ return ret;
+
+ return abfd->iovec->bmmap (abfd, addr, len, prot, flags, offset);
+}
Index: cache.c
===================================================================
RCS file: /cvs/src/src/bfd/cache.c,v
retrieving revision 1.34
diff -u -p -u -r1.34 cache.c
--- cache.c 30 Oct 2008 09:05:32 -0000 1.34
+++ cache.c 10 Jun 2009 17:01:28 -0000
@@ -46,6 +46,10 @@ SUBSECTION
#include "libbfd.h"
#include "libiberty.h"
+#ifdef HAVE_MMAP
+#include <sys/mman.h>
+#endif
+
/* In some cases we can optimize cache operation when reopening files.
For instance, a flush is entirely unnecessary if the file is already
closed, so a flush would use CACHE_NO_OPEN. Similarly, a seek using
@@ -388,10 +392,38 @@ cache_bstat (struct bfd *abfd, struct st
return sts;
}
+static void *
+cache_bmmap (struct bfd *abfd ATTRIBUTE_UNUSED,
+ void *addr ATTRIBUTE_UNUSED,
+ bfd_size_type len ATTRIBUTE_UNUSED,
+ int prot ATTRIBUTE_UNUSED,
+ int flags ATTRIBUTE_UNUSED,
+ file_ptr offset ATTRIBUTE_UNUSED)
+{
+ void *ret = (void *) -1;
+
+ if ((abfd->flags & BFD_IN_MEMORY) != 0)
+ abort ();
+#ifdef HAVE_MMAP
+ else
+ {
+ FILE *f = bfd_cache_lookup (abfd, CACHE_NO_SEEK_ERROR);
+ if (f == NULL)
+ return ret;
+
+ ret = mmap (addr, len, prot, flags, fileno (f), offset);
+ if (ret == (void *) -1)
+ bfd_set_error (bfd_error_system_call);
+ }
+#endif
+
+ return ret;
+}
+
static const struct bfd_iovec cache_iovec =
{
&cache_bread, &cache_bwrite, &cache_btell, &cache_bseek,
- &cache_bclose, &cache_bflush, &cache_bstat
+ &cache_bclose, &cache_bflush, &cache_bstat, &cache_bmmap
};
/*
Index: libbfd.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd.h,v
retrieving revision 1.216
diff -u -p -u -r1.216 libbfd.h
--- libbfd.h 1 Jun 2009 13:11:52 -0000 1.216
+++ libbfd.h 10 Jun 2009 17:01:28 -0000
@@ -773,6 +773,9 @@ struct bfd_iovec
int (*bclose) (struct bfd *abfd);
int (*bflush) (struct bfd *abfd);
int (*bstat) (struct bfd *abfd, struct stat *sb);
+ /* Just like mmap: (void*)-1 on failure, mmapped address on success. */
+ void *(*bmmap) (struct bfd *abfd, void *addr, bfd_size_type len,
+ int prot, int flags, file_ptr offset);
};
/* Extracted from bfdwin.c. */
struct _bfd_window_internal {
Index: opncls.c
===================================================================
RCS file: /cvs/src/src/bfd/opncls.c,v
retrieving revision 1.53
diff -u -p -u -r1.53 opncls.c
--- opncls.c 23 Aug 2008 08:08:58 -0000 1.53
+++ opncls.c 10 Jun 2009 17:01:28 -0000
@@ -505,9 +505,20 @@ opncls_bstat (struct bfd *abfd, struct s
return (vec->stat) (abfd, vec->stream, sb);
}
+static void *
+opncls_bmmap (struct bfd *abfd ATTRIBUTE_UNUSED,
+ void *addr ATTRIBUTE_UNUSED,
+ bfd_size_type len ATTRIBUTE_UNUSED,
+ int prot ATTRIBUTE_UNUSED,
+ int flags ATTRIBUTE_UNUSED,
+ file_ptr offset ATTRIBUTE_UNUSED)
+{
+ return (void *) -1;
+}
+
static const struct bfd_iovec opncls_iovec = {
&opncls_bread, &opncls_bwrite, &opncls_btell, &opncls_bseek,
- &opncls_bclose, &opncls_bflush, &opncls_bstat
+ &opncls_bclose, &opncls_bflush, &opncls_bstat, &opncls_bmmap
};
bfd *
next prev parent reply other threads:[~2009-06-11 1:40 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-27 0:12 Paul Pluzhnikov
2009-05-28 1:16 ` Tom Tromey
2009-05-28 16:57 ` Paul Pluzhnikov
2009-05-30 22:36 ` Tom Tromey
2009-06-11 1:40 ` Paul Pluzhnikov [this message]
2009-06-11 1:43 ` Paul Pluzhnikov
2009-06-16 19:19 ` Tom Tromey
2009-06-16 20:43 ` Paul Pluzhnikov
2009-06-16 20:59 ` Tom Tromey
2009-06-16 21:07 ` Paul Pluzhnikov
2009-06-18 9:20 ` Ken Werner
2009-06-18 14:06 ` Paul Pluzhnikov
2009-06-18 14:11 ` Paul Pluzhnikov
2009-06-18 15:02 ` Ken Werner
2009-06-18 16:33 ` Paul Pluzhnikov
2009-06-19 7:10 ` Ken Werner
2009-06-23 15:03 ` [patch] Fix a reread_symbols regression by mmap [Re: [patch] Use mmap instead of obstack_alloc for dwarf debug sections.] Jan Kratochvil
2009-06-23 17:35 ` Paul Pluzhnikov
2009-06-23 18:08 ` Tom Tromey
2009-06-23 18:21 ` Jan Kratochvil
2009-06-23 20:00 ` Tom Tromey
2009-06-25 19:21 ` [patch] Replace reread_symbols by load+free calls Jan Kratochvil
2009-06-25 19:57 ` Pedro Alves
2009-06-25 23:25 ` Jan Kratochvil
2009-08-02 21:04 ` cancelled: " Jan Kratochvil
2009-08-14 23:09 ` Tom Tromey
2009-08-14 23:12 ` Pedro Alves
2009-08-17 15:41 ` Tom Tromey
2011-12-18 11:54 ` Jan Kratochvil
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=8ac60eac0906101839t4d3978fyc1c6d3b3e2eccb6e@mail.gmail.com \
--to=ppluzhnikov@google.com \
--cc=gdb-patches@sources.redhat.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