From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 105FC3858C52 for ; Thu, 28 Sep 2023 18:28:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 105FC3858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695925687; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cBAlIFutzxDC0KvrU5y+lpU/x15xm0oKLb/5t8WaR0c=; b=e74sjf4OtVMBaCBvJBZt1zBWrefN+IoDCALYszKrDfPrbdR4xjTNybzrzpmojd2LmV5ShT 15BbdSFG/Lx3L13IOvCWGIYjXLIY92mqWOpt3W6lDfzdfVqr/6wdrMsvTWKdbchiqwXp7e ZAJrx2OH2TlvPW8qtAa+DGhdRPA6TwU= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-127-_RL7zmKLNpmElViaWQc6Og-1; Thu, 28 Sep 2023 14:28:06 -0400 X-MC-Unique: _RL7zmKLNpmElViaWQc6Og-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-9a647551b7dso1307944666b.1 for ; Thu, 28 Sep 2023 11:28:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695925685; x=1696530485; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cBAlIFutzxDC0KvrU5y+lpU/x15xm0oKLb/5t8WaR0c=; b=od4lVK+SLLE8yR5JsuxEEDaJVVK8nm41tdTYmO0Ve89wC2ZC62zSft2p0nDbI2KxOG uExh0ZVagmfCv5ehboz89EVBA8lFH+GUHB+YTDd4RSXONvlb5dw0bv7V3lLwJ2BY1dzi CQsM/XTd2Q0sN5Z4sl8v/X898ZwPLibx+UnCSjHWAAcU5bcZhcx5jf8dfNQMU1/AqQK0 H9ghc2hZFamo4TN4e4htiUVXhjcr0/HE0gen90bAB4kwjOHKn8sdpcduG2NfBPWTbMkx SJp3+Vaplx6NsJXNzPjV4XfhXKNqpXJpfKVTAAe9u5EqLu9iHmqgrwv7TfpkJekrV85n kgrQ== X-Gm-Message-State: AOJu0Yw24wpadvfzZ0ma6coPDsf+8EKKg34xKrYxaqJs/hjnVm8TeFGT x+kUjPnVmHShKSPWFeQvpQ39PAkOR9M+wKIpjQO5BcObRwU+0jM+3/MkSJ0bUiSyEhC/eRdIFiJ T4X5/kiUtXOGkV/HtUKRcBA== X-Received: by 2002:a17:907:7e99:b0:9ad:8641:e91b with SMTP id qb25-20020a1709077e9900b009ad8641e91bmr2088381ejc.11.1695925685050; Thu, 28 Sep 2023 11:28:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuIMqRSZD1YIWJorKqJSDFmg/dveVvMnFwjilnJwBOaVZH+sCh10j6B8gY4b9bfBYNtEWgrw== X-Received: by 2002:a17:907:7e99:b0:9ad:8641:e91b with SMTP id qb25-20020a1709077e9900b009ad8641e91bmr2088364ejc.11.1695925684638; Thu, 28 Sep 2023 11:28:04 -0700 (PDT) Received: from localhost (92.40.218.138.threembb.co.uk. [92.40.218.138]) by smtp.gmail.com with ESMTPSA id dt11-20020a170906b78b00b009ae482d70besm11151394ejb.134.2023.09.28.11.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 11:28:04 -0700 (PDT) From: Andrew Burgess To: Aaron Merey , gdb-patches@sourceware.org Cc: Aaron Merey Subject: Re: [PATCH 2/7 v3] gdb/debuginfod: Add debuginfod_section_query In-Reply-To: <20230816044259.2675531-3-amerey@redhat.com> References: <20230816044259.2675531-1-amerey@redhat.com> <20230816044259.2675531-3-amerey@redhat.com> Date: Thu, 28 Sep 2023 19:28:02 +0100 Message-ID: <87y1gqup8t.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Aaron Merey 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 *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 *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 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 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 > *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 > + *destname); > #endif /* DEBUGINFOD_SUPPORT_H */ > -- > 2.41.0