--- gdb-weekly-CVS-7.2.50.20110125/gdb/dwarf2read.c.tom 2011-02-05 14:45:40.204371900 +0300 +++ gdb-weekly-CVS-7.2.50.20110125/gdb/dwarf2read.c 2011-02-05 15:41:51.501930300 +0300 @@ -1519,9 +1519,10 @@ /* Read the contents of the section SECTP from object file specified by OBJFILE, store info about the section into INFO. - If the section is compressed, uncompress it before returning. */ + If the section is compressed, uncompress it before returning. + Returns the size of data accessable via info->buffer. */ -static void +static bfd_size_type dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) { bfd *abfd = objfile->obfd; @@ -1530,13 +1531,13 @@ unsigned char header[4]; if (info->readin) - return; + return info->size; info->buffer = NULL; info->was_mmapped = 0; info->readin = 1; if (dwarf2_section_empty_p (info)) - return; + return info->size; /* Check if the file has a 4-byte header indicating compression. */ if (info->size > sizeof (header) @@ -1548,7 +1549,7 @@ { zlib_decompress_section (objfile, sectp, &info->buffer, &info->size); - return; + return info->size; } } @@ -1574,7 +1575,7 @@ #if HAVE_POSIX_MADVISE posix_madvise (retbuf, map_length, POSIX_MADV_WILLNEED); #endif - return; + return info->size; } } #endif @@ -1591,28 +1592,13 @@ if (retbuf != NULL) { info->buffer = retbuf; - return; + return info->size; } if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0 || bfd_bread (buf, info->size, abfd) != info->size) error (_("Dwarf Error: Can't read DWARF data from '%s'"), bfd_get_filename (abfd)); -} - -/* A helper function that returns the size of a section in a safe way. - If you are positive that the section has been read before using the - size, then it is safe to refer to the dwarf2_section_info object's - "size" field directly. In other cases, you must call this - function, because for compressed sections the size field is not set - correctly until the section has been read. */ - -static bfd_size_type -dwarf2_section_size (struct objfile *objfile, - struct dwarf2_section_info *info) -{ - if (!info->readin) - dwarf2_read_section (objfile, info); return info->size; } @@ -1644,11 +1630,10 @@ else gdb_assert_not_reached ("unexpected section"); - dwarf2_read_section (objfile, info); + *sizep = dwarf2_read_section (objfile, info); *sectp = info->asection; *bufp = info->buffer; - *sizep = info->size; } @@ -2149,8 +2134,7 @@ sec = &dwarf2_per_objfile->types; else sec = &dwarf2_per_objfile->info; - dwarf2_read_section (objfile, sec); - buffer_size = sec->size; + buffer_size = dwarf2_read_section (objfile, sec); buffer = sec->buffer; info_ptr = buffer + this_cu->offset; beg_of_comp_unit = info_ptr; @@ -2845,7 +2829,7 @@ bfd_get_filename (abfd)); if (header->abbrev_offset - >= dwarf2_section_size (dwarf2_per_objfile->objfile, + >= dwarf2_read_section (dwarf2_per_objfile->objfile, &dwarf2_per_objfile->abbrev)) error (_("Dwarf Error: bad offset (0x%lx) in compilation unit header " "(offset 0x%lx + 6) [in module %s]"), @@ -14413,7 +14397,7 @@ /* ".debug_loc" may not exist at all, or the offset may be outside the section. If so, fall through to the complaint in the other branch. */ - && DW_UNSND (attr) < dwarf2_section_size (dwarf2_per_objfile->objfile, + && DW_UNSND (attr) < dwarf2_read_section (dwarf2_per_objfile->objfile, &dwarf2_per_objfile->loc)) { struct dwarf2_loclist_baton *baton;