From: Tom Tromey <tom@tromey.com>
To: Aaron Merey via Gdb-patches <gdb-patches@sourceware.org>
Cc: Aaron Merey <amerey@redhat.com>,
tom@tromey.com, aburgess@redhat.com, lsix@lancelotsix.com
Subject: Re: [PATCH 1/2] gdb: Add soname to build-id mapping for core files
Date: Fri, 04 Mar 2022 07:53:54 -0700 [thread overview]
Message-ID: <871qzhvke5.fsf@tromey.com> (raw)
In-Reply-To: <20220303013501.265407-2-amerey@redhat.com> (Aaron Merey via Gdb-patches's message of "Wed, 2 Mar 2022 20:35:00 -0500")
>>>>> "Aaron" == Aaron Merey via Gdb-patches <gdb-patches@sourceware.org> writes:
Aaron> Since commit aa2d5a422 gdb has been able to read executable and shared
Aaron> library build-ids within core files.
Aaron> Expand this functionality so that each core file bfd maintains a map of
Aaron> soname to build-id for each shared library referenced in the core file.
Aaron> This feature may be used to verify that gdb has found the correct shared
Aaron> libraries for core files and to facilitate downloading shared libaries via
Aaron> debuginfod.
Thanks for working on this.
Aaron> + gdb::unique_xmalloc_ptr<char> soname =
Aaron> + gdb_bfd_read_elf_soname (bfd->filename);
The '=' should go after the line break.
Aaron> +/* Mapping of a core file's shared library sonames to their respective
Aaron> + build-ids. Added to the registries of core file bfds. */
Aaron> +
Aaron> +typedef std::unordered_map<std::string, std::string> soname_build_id_map;
Aaron> +
Aaron> +/* Key used to associate a soname_build_id_map to a core file bfd. */
Aaron> +
Aaron> +static const struct bfd_data *cbfd_soname_build_id_data_key;
I think it's better to use the template form, like
static const struct bfd_key<soname_build_id_map> cbfd_soname_build_id_data_key;
More comments on this below.
Aaron> + soname_build_id_map *mapptr = (soname_build_id_map *)
Aaron> + bfd_data (abfd.get (), cbfd_soname_build_id_data_key);
... this cast won't be needed:
soname_build_id_map *mapptr = cbfd_soname_build_id_data_key.get (abfd.get ());
Aaron> + if (mapptr == nullptr)
Aaron> + {
Aaron> + mapptr = new soname_build_id_map ();
Aaron> + set_bfd_data (abfd.get (), cbfd_soname_build_id_data_key, mapptr);
mapptr = cbfd_soname_build_id_data_key.emplace (abfd.get ());
Aaron> +/* See solib.h. */
Aaron> +
Aaron> +gdb::unique_xmalloc_ptr<char>
Aaron> +get_cbfd_soname_build_id (gdb_bfd_ref_ptr abfd, const char *soname)
Aaron> +{
Why does this return a unique_xmalloc_ptr?
Aaron> +/* Free memory allocated for a soname_build_id_map. */
Aaron> +
Aaron> +static void
Aaron> +delete_soname_build_id_map (struct bfd *abfd, void *mapptr)
Aaron> +{
Aaron> + if (mapptr != nullptr)
Aaron> + delete (soname_build_id_map *) mapptr;
Aaron> +}
With the template form, this can go away entirely.
Aaron> _initialize_solib ()
Aaron> {
Aaron> solib_data = gdbarch_data_register_pre_init (solib_init);
Aaron> + cbfd_soname_build_id_data_key = (const struct bfd_data *)
Aaron> + register_bfd_data_with_cleanup (nullptr, delete_soname_build_id_map);
This won't be needed with the template form.
Tom
next prev parent reply other threads:[~2022-03-04 14:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-03 1:34 [PATCH 0/2] Add debuginfod core file support Aaron Merey
2022-03-03 1:35 ` [PATCH 1/2] gdb: Add soname to build-id mapping for core files Aaron Merey
2022-03-04 14:53 ` Tom Tromey [this message]
2022-03-08 0:30 ` Aaron Merey
2022-03-11 15:23 ` Tom Tromey
2022-03-11 21:44 ` Aaron Merey
2022-03-18 19:03 ` Tom Tromey
2022-03-21 18:21 ` Aaron Merey
2022-03-03 1:35 ` [PATCH 2/2] PR gdb/27570: missing support for debuginfod in core_target::build_file_mappings Aaron Merey
2022-03-04 15:20 ` Tom Tromey
2022-03-08 0:33 ` Aaron Merey
2022-03-11 15:27 ` Tom Tromey
2022-03-11 21:49 ` Aaron Merey
2022-03-21 18:22 ` Aaron Merey
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=871qzhvke5.fsf@tromey.com \
--to=tom@tromey.com \
--cc=aburgess@redhat.com \
--cc=amerey@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=lsix@lancelotsix.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).