From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CMhbM96P52RBTgoAWB0awg (envelope-from ) for ; Thu, 24 Aug 2023 13:14:06 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=SMiPqnc3; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id CEC931E0C2; Thu, 24 Aug 2023 13:14:06 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id BF0DB1E092 for ; Thu, 24 Aug 2023 13:14:04 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6C79E38555A0 for ; Thu, 24 Aug 2023 17:14:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C79E38555A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1692897244; bh=hbL8FwaJkkWtoEc36ogyzbtdgivEYaX4ZdzxM5YhzXY=; h=Date:Subject:References:In-Reply-To:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=SMiPqnc3A1Xq5EYpiULP4OX60IsTsO78x+M2WXIFrLTOTSoa66zFYvZ0TTIsTdXYD aASrtYBzImg/6z6h2YTuA6H+Pi258MJYobsgl7h+I27GbQiIbyODaq3a0j+7QDHViY VTTu5Mo3ZmfrNTNMKnGLeJom9MMU+Xvv1bnvkTj0= Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by sourceware.org (Postfix) with ESMTPS id 90A51385697F for ; Thu, 24 Aug 2023 17:12:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 90A51385697F Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-34cb979c9b9so185555ab.1 for ; Thu, 24 Aug 2023 10:12:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692897145; x=1693501945; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hbL8FwaJkkWtoEc36ogyzbtdgivEYaX4ZdzxM5YhzXY=; b=ltzlFd+vTQcnj1+UAtzgWaNBXiEl2kqwpJMuwfih/HhWauPR3kjN1YnDYOl3PPKte0 bvQ1E/5t7L/kEiwEu9qN4N+wzuefZZ7uWscI+GIa5oateykIz9vZm0aMkwhUl6Jm2E3W 0j7vHOCwbrrPKb3MQ9GutHqddbUZcFzhXB9C1+Ks38QEgR7mpri/btjaxclXSpDUYl4W 63c9d+PYIW4QY5lwFdyJ59sWjItnvbB5K9M8msaD1cZ39IiGldjiKt/6YIPzVVtAwpx0 X31pPyjPqGxYBAoT5WfZ/Ful4XX6Ngs+8CaoVNGoz6//qHtUJ0LMJiQcZ0SX0RHYLiuK 2DcQ== X-Gm-Message-State: AOJu0YzLnrjYl137X1BAWhpIgsUiJQGbuvoa8vuUKIfc3WBYHYhf4HOI fH0+725BWNI44CLbq0ZJLL4XQuTofKn5L/wbTygYiQ== X-Google-Smtp-Source: AGHT+IF4nJhr88gj5h1WmbhubSDnko2F0IEn6AQxAkm1Ft5a9PsBtFoXzU+jwomhml+SSOz+mQLfjg== X-Received: by 2002:a05:6e02:1241:b0:34c:b943:d170 with SMTP id j1-20020a056e02124100b0034cb943d170mr5666591ilq.18.1692897144772; Thu, 24 Aug 2023 10:12:24 -0700 (PDT) Received: from localhost.localdomain (75-166-142-177.hlrn.qwest.net. [75.166.142.177]) by smtp.gmail.com with ESMTPSA id n8-20020a92d9c8000000b0034986f6d9a9sm4722515ilq.78.2023.08.24.10.12.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 10:12:24 -0700 (PDT) Date: Thu, 24 Aug 2023 11:12:23 -0600 Subject: [PATCH 6/7] Convert solib-rocm to new type-safe gdb_bfd_openr_iovec MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230824-gdb-bfd-vec-v1-6-850e4e907ed1@adacore.com> References: <20230824-gdb-bfd-vec-v1-0-850e4e907ed1@adacore.com> In-Reply-To: <20230824-gdb-bfd-vec-v1-0-850e4e907ed1@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom Tromey via Gdb-patches Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" This converts the solib-rocm BFD iovec implementations to the new type-safe gdb_bfd_openr_iovec. They were already essentially using this approach, just without the type-safe wrapper. I can't build or test this patch. --- gdb/solib-rocm.c | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c index 882920a3711..145624b888a 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -268,7 +268,7 @@ namespace { /* Interface to interact with a ROCm code object stream. */ -struct rocm_code_object_stream +struct rocm_code_object_stream : public gdb_bfd_iovec_base { DISABLE_COPY_AND_ASSIGN (rocm_code_object_stream); @@ -457,8 +457,8 @@ rocm_code_object_stream_memory::read (void *buf, file_ptr size, } /* anonymous namespace */ -static void * -rocm_bfd_iovec_open (bfd *abfd, void *inferior_void) +static gdb_bfd_iovec_base * +rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) { gdb::string_view uri (bfd_get_filename (abfd)); gdb::string_view protocol_delim = "://"; @@ -522,7 +522,6 @@ rocm_bfd_iovec_open (bfd *abfd, void *inferior_void) { ULONGEST offset = 0; ULONGEST size = 0; - inferior *inferior = static_cast (inferior_void); auto try_strtoulst = [] (gdb::string_view v) { @@ -607,28 +606,6 @@ rocm_bfd_iovec_open (bfd *abfd, void *inferior_void) } } -static int -rocm_bfd_iovec_close (bfd *nbfd, void *data) -{ - delete static_cast (data); - - return 0; -} - -static file_ptr -rocm_bfd_iovec_pread (bfd *abfd, void *data, void *buf, file_ptr size, - file_ptr offset) -{ - return static_cast (data)->read (buf, size, - offset); -} - -static int -rocm_bfd_iovec_stat (bfd *abfd, void *data, struct stat *sb) -{ - return static_cast (data)->stat (sb); -} - static gdb_bfd_ref_ptr rocm_solib_bfd_open (const char *pathname) { @@ -636,10 +613,12 @@ rocm_solib_bfd_open (const char *pathname) if (strstr (pathname, "://") == nullptr) return svr4_so_ops.bfd_open (pathname); - gdb_bfd_ref_ptr abfd - = gdb_bfd_openr_iovec (pathname, "elf64-amdgcn", rocm_bfd_iovec_open, - current_inferior (), rocm_bfd_iovec_pread, - rocm_bfd_iovec_close, rocm_bfd_iovec_stat); + auto open = [&] (bfd *nbfd) -> gdb_bfd_iovec_base * + { + return rocm_bfd_iovec_open (nbfd, current_inferior ()); + }; + + gdb_bfd_ref_ptr abfd = gdb_bfd_openr_iovec (pathname, "elf64-amdgcn", open); if (abfd == nullptr) error (_("Could not open `%s' as an executable file: %s"), pathname, -- 2.40.1