From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/2] Use gdb_bfd_get_full_section_contents in auto-load.c
Date: Thu, 17 Oct 2024 18:02:37 -0600 [thread overview]
Message-ID: <20241017-fix-race-pr-symtab-31626-v1-1-3a53459e9651@tromey.com> (raw)
In-Reply-To: <20241017-fix-race-pr-symtab-31626-v1-0-3a53459e9651@tromey.com>
This changes auto-load.c ot use gdb_bfd_get_full_section_contents.
This shouldn't change any behavior, but makes it easier to add locking
in a subsequent patch.
---
gdb/auto-load.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index e753333b1cdfe6a12b1885d1468ef92ef51776af..d4307eac6273803ed7024491169701e8a55fcc6b 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -1114,25 +1114,22 @@ auto_load_section_scripts (struct objfile *objfile, const char *section_name)
{
bfd *abfd = objfile->obfd.get ();
asection *scripts_sect;
- bfd_byte *data = NULL;
scripts_sect = bfd_get_section_by_name (abfd, section_name);
if (scripts_sect == NULL
|| (bfd_section_flags (scripts_sect) & SEC_HAS_CONTENTS) == 0)
return;
- if (!bfd_get_full_section_contents (abfd, scripts_sect, &data))
+ gdb::byte_vector data;
+ if (!gdb_bfd_get_full_section_contents (abfd, scripts_sect, &data))
warning (_("Couldn't read %s section of %ps"),
section_name,
styled_string (file_name_style.style (),
bfd_get_filename (abfd)));
else
{
- gdb::unique_xmalloc_ptr<bfd_byte> data_holder (data);
-
- char *p = (char *) data;
- source_section_scripts (objfile, section_name, p,
- p + bfd_section_size (scripts_sect));
+ const char *p = (const char *) data.data ();
+ source_section_scripts (objfile, section_name, p, p + data.size ());
}
}
--
2.46.1
next prev parent reply other threads:[~2024-10-18 0:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 0:02 [PATCH 0/2] Fix a data race with the background DWARF reader Tom Tromey
2024-10-18 0:02 ` Tom Tromey [this message]
2024-10-18 0:02 ` [PATCH 2/2] Add locking when reading BFD sections Tom Tromey
2024-10-23 22:30 ` [PATCH 0/2] Fix a data race with the background DWARF reader Kevin Buettner
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=20241017-fix-race-pr-symtab-31626-v1-1-3a53459e9651@tromey.com \
--to=tom@tromey.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