diff options
author | Tristan Gingold <gingold@adacore.com> | 2011-06-27 08:41:39 +0000 |
---|---|---|
committer | Tristan Gingold <gingold@adacore.com> | 2011-06-27 08:41:39 +0000 |
commit | b315ab2151bc2501de3ab6f0075ecc1646c2ae67 (patch) | |
tree | a0a2379f5bcc8bc1b83332956726ecdcac3c3add | |
parent | 4c95ab762cbc17e3221e4cc38e728e665576793f (diff) | |
download | binutils-b315ab2151bc2501de3ab6f0075ecc1646c2ae67.zip binutils-b315ab2151bc2501de3ab6f0075ecc1646c2ae67.tar.gz binutils-b315ab2151bc2501de3ab6f0075ecc1646c2ae67.tar.bz2 |
2011-06-27 Tristan Gingold <gingold@adacore.com>
* dwarf2read.c (struct dwarf2_section_info): Replace was_mmapped
field by map_addr and map_len.
(dwarf2_read_section): Adjust for the new bfd_mmap api.
(munmap_section_buffer): Likewise.
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/dwarf2read.c | 29 |
2 files changed, 21 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b10ce0f..cd62b1c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2011-06-27 Tristan Gingold <gingold@adacore.com> + + * dwarf2read.c (struct dwarf2_section_info): Replace was_mmapped + field by map_addr and map_len. + (dwarf2_read_section): Adjust for the new bfd_mmap api. + (munmap_section_buffer): Likewise. + 2011-06-24 Tom Tromey <tromey@redhat.com> * varobj.c (update_dynamic_varobj_children): Make 'name' const. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 399d593..cfe0514 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -134,7 +134,10 @@ struct dwarf2_section_info asection *asection; gdb_byte *buffer; bfd_size_type size; - int was_mmapped; + /* Not NULL if the section was actually mmapped. */ + void *map_addr; + /* Page aligned size of mmapped area. */ + bfd_size_type map_len; /* True if we have tried to read this section. */ int readin; }; @@ -1562,7 +1565,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) if (info->readin) return; info->buffer = NULL; - info->was_mmapped = 0; + info->map_addr = NULL; info->readin = 1; if (dwarf2_section_empty_p (info)) @@ -1592,17 +1595,14 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) if (info->size > 4 * pagesize && (sectp->flags & SEC_RELOC) == 0) { - off_t pg_offset = sectp->filepos & ~(pagesize - 1); - size_t map_length = info->size + sectp->filepos - pg_offset; - caddr_t retbuf = bfd_mmap (abfd, 0, map_length, PROT_READ, - MAP_PRIVATE, pg_offset); + info->buffer = bfd_mmap (abfd, 0, info->size, PROT_READ, + MAP_PRIVATE, sectp->filepos, + &info->map_addr, &info->map_len); - if (retbuf != MAP_FAILED) + if ((caddr_t)info->buffer != MAP_FAILED) { - info->was_mmapped = 1; - info->buffer = retbuf + (sectp->filepos & (pagesize - 1)) ; #if HAVE_POSIX_MADVISE - posix_madvise (retbuf, map_length, POSIX_MADV_WILLNEED); + posix_madvise (info->map_addr, info->map_len, POSIX_MADV_WILLNEED); #endif return; } @@ -15357,14 +15357,13 @@ show_dwarf2_cmd (char *args, int from_tty) static void munmap_section_buffer (struct dwarf2_section_info *info) { - if (info->was_mmapped) + if (info->map_addr != NULL) { #ifdef HAVE_MMAP - intptr_t begin = (intptr_t) info->buffer; - intptr_t map_begin = begin & ~(pagesize - 1); - size_t map_length = info->size + begin - map_begin; + int res; - gdb_assert (munmap ((void *) map_begin, map_length) == 0); + res = munmap (info->map_addr, info->map_len); + gdb_assert (res == 0); #else /* Without HAVE_MMAP, we should never be here to begin with. */ gdb_assert_not_reached ("no mmap support"); |