public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Aaron Merey <amerey@redhat.com>, gdb-patches@sourceware.org
Cc: Aaron Merey <amerey@redhat.com>
Subject: Re: [PATCH 2/7 v3] gdb/debuginfod: Add debuginfod_section_query
Date: Thu, 28 Sep 2023 19:28:02 +0100	[thread overview]
Message-ID: <87y1gqup8t.fsf@redhat.com> (raw)
In-Reply-To: <20230816044259.2675531-3-amerey@redhat.com>

Aaron Merey <amerey@redhat.com> writes:

> v2: https://sourceware.org/pipermail/gdb-patches/2023-June/199985.html
>
> v3 has config/debuginfod.m4 changes moved into a separate patch.
>
> Commit message:
>
> Add new function debuginfod_section_query.  This function queries
> debuginfod servers for an individual ELF/DWARF section associated with
> a given build-id.
> ---
>  gdb/debuginfod-support.c | 60 ++++++++++++++++++++++++++++++++++++++++
>  gdb/debuginfod-support.h | 24 ++++++++++++++++
>  2 files changed, 84 insertions(+)
>
> diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
> index a41a4c95785..33bb9d9b7bc 100644
> --- a/gdb/debuginfod-support.c
> +++ b/gdb/debuginfod-support.c
> @@ -80,6 +80,15 @@ debuginfod_exec_query (const unsigned char *build_id,
>    return scoped_fd (-ENOSYS);
>  }
>  
> +scoped_fd
> +debuginfod_section_query (const unsigned char *build_id,
> +			  int build_id_len,
> +			  const char *filename,
> +			  const char *section_name,
> +			  gdb::unique_xmalloc_ptr<char> *destname)
> +{
> +  return scoped_fd (-ENOSYS);
> +}
>  #define NO_IMPL _("Support for debuginfod is not compiled into GDB.")
>  
>  #else
> @@ -412,6 +421,57 @@ debuginfod_exec_query (const unsigned char *build_id,
>  
>    return fd;
>  }
> +
> +/* See debuginfod-support.h  */
> +
> +scoped_fd
> +debuginfod_section_query (const unsigned char *build_id,
> +			  int build_id_len,
> +			  const char *filename,
> +			  const char *section_name,
> +			  gdb::unique_xmalloc_ptr<char> *destname)
> +{
> +#if !defined (HAVE_LIBDEBUGINFOD_FIND_SECTION)
> +  return scoped_fd (-ENOSYS);
> +#else
> +
> + if (!debuginfod_is_enabled ())

This line is under-indented by one space :)

Otherwise:

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew


> +    return scoped_fd (-ENOSYS);
> +
> +  debuginfod_client *c = get_debuginfod_client ();
> +
> +  if (c == nullptr)
> +    return scoped_fd (-ENOMEM);
> +
> +  char *dname = nullptr;
> +  std::string desc = std::string ("section ") + section_name + " for";
> +  scoped_fd fd;
> +  gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
> +
> +  {
> +    user_data data (desc.c_str (), filename);
> +    debuginfod_set_user_data (c, &data);
> +    if (target_supports_terminal_ours ())
> +      {
> +	term_state.emplace ();
> +	target_terminal::ours ();
> +      }
> +
> +    fd = scoped_fd (debuginfod_find_section (c, build_id, build_id_len,
> +					     section_name, &dname));
> +    debuginfod_set_user_data (c, nullptr);
> +  }
> +
> +  print_outcome (fd.get (), desc.c_str (), filename);
> +  gdb_assert (destname != nullptr);
> +
> +  if (fd.get () >= 0)
> +    destname->reset (dname);
> +
> +  return fd;
> +#endif /* HAVE_LIBDEBUGINFOD_FIND_SECTION */
> +}
> +
>  #endif
>  
>  /* Set callback for "set debuginfod enabled".  */
> diff --git a/gdb/debuginfod-support.h b/gdb/debuginfod-support.h
> index 633600a79da..9701e3b4685 100644
> --- a/gdb/debuginfod-support.h
> +++ b/gdb/debuginfod-support.h
> @@ -81,4 +81,28 @@ extern scoped_fd debuginfod_exec_query (const unsigned char *build_id,
>  					const char *filename,
>  					gdb::unique_xmalloc_ptr<char>
>  					  *destname);
> +
> +/* Query debuginfod servers for the binary contents of a ELF/DWARF section
> +   from a file matching BUILD_ID.  BUILD_ID can be given as a binary blob
> +   or a null-terminated string.  If given as a binary blob, BUILD_ID_LEN
> +   should be the number of bytes.  If given as a null-terminated string,
> +   BUILD_ID_LEN should be 0.
> +
> +   FILENAME should be the name or path associated with the file matching
> +   BUILD_ID.  It is used for printing messages to the user.
> +
> +   SECTION_NAME should be the name of an ELF/DWARF section.
> +
> +   If the file is successfully retrieved, return a file descriptor and store
> +   the file's local path in DESTNAME.  If unsuccessful, print an error message
> +   and return a negative errno.  If GDB is not built with debuginfod or
> +   libdebuginfod does not support section queries, this function returns
> +   -ENOSYS.  */
> +
> +extern scoped_fd debuginfod_section_query (const unsigned char *build_id,
> +					   int build_id_len,
> +					   const char *filename,
> +					   const char *section_name,
> +					   gdb::unique_xmalloc_ptr<char>
> +					     *destname);
>  #endif /* DEBUGINFOD_SUPPORT_H */
> -- 
> 2.41.0


  parent reply	other threads:[~2023-09-28 18:28 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-16  4:42 [PATCH 0/7] gdb/debuginfod: Add on-demand debuginfo downloading Aaron Merey
2023-08-16  4:42 ` [PATCH 1/7] config/debuginfod.m4: Add check for libdebuginfod 0.188 Aaron Merey
2023-09-19 14:33   ` Aaron Merey
2023-09-27 10:28     ` Nick Clifton
2023-09-27 19:14       ` Aaron Merey
2023-08-16  4:42 ` [PATCH 2/7 v3] gdb/debuginfod: Add debuginfod_section_query Aaron Merey
2023-09-19 14:33   ` Aaron Merey
2023-09-28 18:28   ` Andrew Burgess [this message]
2023-10-02 18:07     ` Aaron Merey
2023-08-16  4:42 ` [PATCH 3/7 v3] gdb: Add command 'maint set/show debuginfod download-sections' Aaron Merey
2023-08-16 12:45   ` Eli Zaretskii
2023-09-19 14:34     ` Aaron Merey
2023-09-28 18:32   ` Andrew Burgess
2023-10-02 18:08     ` Aaron Merey
2023-08-16  4:42 ` [PATCH 4/7 v5] gdb: Buffer output streams during events that might download debuginfo Aaron Merey
2023-09-19 14:34   ` Aaron Merey
2023-10-10 21:55   ` [PATCH v6] " Aaron Merey
2023-10-24 11:22     ` Andrew Burgess
2023-10-28  0:25       ` Aaron Merey
2023-08-16  4:42 ` [PATCH 5/7 v2] gdb/progspace: Add reverse safe iterator and template for unwrapping iterator Aaron Merey
2023-09-19 14:35   ` Aaron Merey
2023-10-10 21:56     ` [PING*2][PATCH " Aaron Merey
2023-08-16  4:42 ` [PATCH 6/7 v4] gdb/debuginfod: Support on-demand debuginfo downloading Aaron Merey
2023-09-19 14:35   ` Aaron Merey
2023-10-10 21:57     ` [PING*2][PATCH " Aaron Merey
2023-08-16  4:42 ` [PATCH 7/7 v4] gdb/debuginfod: Add .debug_line downloading Aaron Merey
2023-09-19 14:35   ` Aaron Merey
2023-10-10 21:58     ` [PING*2][PATCH " 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=87y1gqup8t.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=amerey@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).