From: Tom Tromey <tom@tromey.com>
To: Tom Tromey <tom@tromey.com>
Cc: Andrew Burgess <andrew.burgess@embecosm.com>,
gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: Reinitialize objfile::section_offsets during objfile reload
Date: Sun, 26 Jan 2020 21:51:00 -0000 [thread overview]
Message-ID: <871rrm6v9r.fsf@tromey.com> (raw)
In-Reply-To: <875zgy6vo5.fsf@tromey.com> (Tom Tromey's message of "Sun, 26 Jan 2020 09:15:38 -0700")
Andrew> When building and testing with '-D_GLIBCXX_DEBUG=1' I noticed that the
Andrew> test gdb.base/reload.exp was failing. This turns out to be because
Andrew> the objfile::section_offsets vector is not reinitialilzed during the
Andrew> objfile reload process, and in this particular test, GDB ends up
Andrew> indexing outside the bounds of the vector.
Tom> Thanks for catching this.
I wonder if this is a regression due to
commit 6a053cb1ff643cec3349d7f2f47ae5573f82d613
Author: Tom Tromey <tromey@adacore.com>
Date: Mon Jan 6 14:34:52 2020 -0700
Change section_offsets to a std::vector
See appended.
I think at the time I thought removing this code would simply preserve
the offsets. But maybe we instead should std::move the offsets out of
the objfile and then move them back in?
This change would preserve the old status quo.
Tom
@@ -2479,9 +2468,6 @@ reread_symbols (void)
new_modtime = new_statbuf.st_mtime;
if (new_modtime != objfile->mtime)
{
- struct section_offsets *offsets;
- int num_offsets;
-
printf_filtered (_("`%s' has changed; re-reading symbols.\n"),
objfile_name (objfile));
@@ -2556,14 +2542,6 @@ reread_symbols (void)
error (_("Can't read symbols from %s: %s."), objfile_name (objfile),
bfd_errmsg (bfd_get_error ()));
- /* Save the offsets, we will nuke them with the rest of the
- objfile_obstack. */
- num_offsets = objfile->num_sections;
- offsets = ((struct section_offsets *)
- alloca (SIZEOF_N_SECTION_OFFSETS (num_offsets)));
- memcpy (offsets, objfile->section_offsets,
- SIZEOF_N_SECTION_OFFSETS (num_offsets));
-
objfile->reset_psymtabs ();
/* NB: after this call to obstack_free, objfiles_changed
@@ -2595,15 +2573,6 @@ reread_symbols (void)
build_objfile_section_table (objfile);
- /* We use the same section offsets as from last time. I'm not
- sure whether that is always correct for shared libraries. */
- objfile->section_offsets = (struct section_offsets *)
- obstack_alloc (&objfile->objfile_obstack,
- SIZEOF_N_SECTION_OFFSETS (num_offsets));
- memcpy (objfile->section_offsets, offsets,
- SIZEOF_N_SECTION_OFFSETS (num_offsets));
- objfile->num_sections = num_offsets;
-
/* What the hell is sym_new_init for, anyway? The concept of
distinguishing between the main file and additional files
in this way seems rather dubious. */
next prev parent reply other threads:[~2020-01-26 16:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-26 11:31 Andrew Burgess
2020-01-26 16:33 ` Tom Tromey
2020-01-26 21:51 ` Tom Tromey [this message]
2020-01-27 20:32 ` Pedro Alves
2020-01-27 19:07 ` Pedro Alves
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=871rrm6v9r.fsf@tromey.com \
--to=tom@tromey.com \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
/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