From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6189 invoked by alias); 5 Feb 2011 13:53:32 -0000 Received: (qmail 6180 invoked by uid 22791); 5 Feb 2011 13:53:31 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,TW_BJ X-Spam-Check-By: sourceware.org Received: from mail.apical.co.uk (HELO srv1.office.apical.co.uk) (213.106.251.44) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 05 Feb 2011 13:53:24 +0000 Received: from [10.250.148.115] (23.nat.acronis.net [91.195.22.23]) (authenticated bits=0) by srv1.office.apical.co.uk (8.14.4/8.14.4) with ESMTP id p15Dr8TH030744 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sat, 5 Feb 2011 13:53:10 GMT Message-ID: <4D4D52F2.7080802@sw.ru> Date: Sat, 05 Feb 2011 13:53:00 -0000 From: Vladimir Simonov User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-2.fc11 Thunderbird/3.0.4 MIME-Version: 1.0 To: Tom Tromey CC: gdb-patches@sourceware.org Subject: Re: gdb: Incorrect stack unwinding if compressed debug info is used References: <1296238472.3009.ezmlm@sourceware.org> <4D46D872.6080407@sw.ru> <4D4C383A.3000203@sw.ru> <4D4C4576.2020709@sw.ru> In-Reply-To: Content-Type: multipart/mixed; boundary="------------080500060906090400070008" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-02/txt/msg00106.txt.bz2 This is a multi-part message in MIME format. --------------080500060906090400070008 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 752 On 02/04/2011 11:31 PM, Tom Tromey wrote: > Vladimir> May be just change dwarf2_read_section to return > Vladimir> size? > > I think the name is ok, but I extended the comment to try to clear up > the semantics. > > I am going to check in the appended patch. If you still think the name > is not good, pick a better one and I will rename it. Please see attached patch. Hope it explains what I meant under "change dwarf2_read_section". If such changes are not acceptable by some reason(performance?, readability?, something else) then I'm OK with current naming. I definitely don't insist on such changes, I just interested in understanding gdb "coding policy". If it is difficult to explain please ignore this mail. Best regards Vladimir Simonov --------------080500060906090400070008 Content-Type: text/plain; name="gdb-7.2-compressed-section-cleanup.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gdb-7.2-compressed-section-cleanup.patch" Content-length: 3732 --- 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; --------------080500060906090400070008--