From: Vladimir Simonov <sv@sw.ru>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: gdb: Incorrect stack unwinding if compressed debug info is used
Date: Sat, 05 Feb 2011 13:53:00 -0000 [thread overview]
Message-ID: <4D4D52F2.7080802@sw.ru> (raw)
In-Reply-To: <m3tygj7d90.fsf@fleche.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 752 bytes --]
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
[-- Attachment #2: gdb-7.2-compressed-section-cleanup.patch --]
[-- Type: text/plain, Size: 3732 bytes --]
--- 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;
}
\f
@@ -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;
next prev parent reply other threads:[~2011-02-05 13:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1296238472.3009.ezmlm@sourceware.org>
2011-01-31 16:57 ` Vladimir Simonov
2011-02-02 19:55 ` Paul Pluzhnikov
2011-02-03 16:51 ` Vladimir Simonov
2011-02-04 16:35 ` Tom Tromey
2011-02-04 16:34 ` Tom Tromey
2011-02-04 17:47 ` Vladimir Simonov
2011-02-04 17:56 ` Tom Tromey
2011-02-04 18:43 ` Vladimir Simonov
2011-02-04 20:31 ` Tom Tromey
2011-02-05 13:53 ` Vladimir Simonov [this message]
2011-02-07 15:00 ` Tom Tromey
2011-02-01 7:34 ` gdb: Incorrect stack unwinding if debug info is compressed Vladimir Simonov
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=4D4D52F2.7080802@sw.ru \
--to=sv@sw.ru \
--cc=gdb-patches@sourceware.org \
--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