From: Tom Tromey <tromey@redhat.com>
To: Paul Pluzhnikov <ppluzhnikov@google.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [patch] Use mmap instead of obstack_alloc for dwarf debug sections.
Date: Tue, 16 Jun 2009 19:19:00 -0000 [thread overview]
Message-ID: <m3zlc80yxc.fsf@fleche.redhat.com> (raw)
In-Reply-To: <8ac60eac0906101842y2d2fc9fco331cb4336d9508d0@mail.gmail.com> (Paul Pluzhnikov's message of "Wed\, 10 Jun 2009 18\:42\:47 -0700")
>>>>> "Paul" == Paul Pluzhnikov <ppluzhnikov@google.com> writes:
Paul> Sorry, attached the bfd patch instead of the gdb one :-(
Paul> Here is the right one.
Thanks. One point of order -- if you re-send a patch, re-send the
ChangeLog entry too. Not a big deal, but it makes things simpler when
reviewing. Thanks.
I saw in your original post that this patch helps on
memory-constrained machines; your example was 2G of debug info on a 4G
machine. I just want to make sure that this doesn't hurt other cases;
I don't expect it would, but it is good to cross the t's...
I like how this patch cleans up some globals in dwarf2read.c.
I have a few comments, mostly nits, but one real one.
Paul> +struct dwarf2_section_info
Paul> +{
Paul> + asection *asection;
Paul> + gdb_byte *buffer;
Paul> + bfd_size_type size;
Paul> + int was_mmaped;
I would spell this "was_mmapped" (two "p"s).
Paul> +zlib_decompress_section (struct objfile *objfile, asection *sectp,
Paul> + gdb_byte **outbuf, bfd_size_type *outsize)
[...]
Paul> + bfd_size_type compressed_size = bfd_get_section_size (sectp);
Paul> + gdb_byte *compressed_buffer = xmalloc (compressed_size);
Paul> + bfd_size_type uncompressed_size;
Paul> + gdb_byte *uncompressed_buffer;
Paul> + z_stream strm;
Paul> + int rc;
Paul> + int header_size = 12;
Paul> +
Paul> + if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0
Paul> + || bfd_bread (compressed_buffer, compressed_size, abfd) != compressed_size)
Paul> + error (_("Dwarf Error: Can't read DWARF data from '%s'"),
Paul> + bfd_get_filename (abfd));
This isn't your problem -- but I noticed that this will leak
compressed_buffer if there is an error. This code needs to use a
cleanup.
I'll fix this after your patch goes in.
Paul> +static void
Paul> +dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info)
[...]
Paul> +#ifdef HAVE_MMAP
[...]
Paul> + {
Paul> + info->was_mmaped = 1;
Paul> + info->buffer = retbuf + (sectp->filepos & (pagesize - 1)) ;
Paul> + return;
Paul> + }
[...]
Paul> + /* When debugging .o files, we may need to apply relocations; see
Paul> + http://sourceware.org/ml/gdb-patches/2002-04/msg00136.html .
Paul> + We never compress sections in .o files, so we only need to
Paul> + try this when the section is not compressed. */
Paul> + retbuf = symfile_relocate_debug_section (abfd, sectp, buf);
If we're using mmap then we seem to skip this relocation step.
This seems like a bug.
IIUC, this is an unusual case. So perhaps one fix would be to
introduce a new symfile_debug_section_needs_relocate_p, then protect
the mmap branch with that.
Paul> +static void
Paul> +munmap_section_buffer (struct dwarf2_section_info *info)
[...]
Paul> + gdb_assert (munmap ((void *)map_begin, map_length) == 0);
Space after the ")" of the cast to void *.
Tom
next prev parent reply other threads:[~2009-06-16 19:19 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
2009-06-11 1:43 ` Paul Pluzhnikov
2009-06-16 19:19 ` Tom Tromey [this message]
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=m3zlc80yxc.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=ppluzhnikov@google.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