From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by sourceware.org (Postfix) with ESMTPS id A0A2F3858401 for ; Wed, 23 Aug 2023 15:43:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A0A2F3858401 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-31768ce2e81so5138657f8f.1 for ; Wed, 23 Aug 2023 08:43:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692805395; x=1693410195; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3uOiqwPheG1Jn3gQ6EjYePbyf4I43MbUWag9VYN9L34=; b=ik5xtJwD6N9M8fh+LddwvIT8Kob7oBq/MvRzxEV5gy00Mf6Hg9ywoIRUNZdCBgoskf sd3q/MVn0NgNHnTT2rFYjDiKTP3HJRnvYvEL+IBRSaqVjBOEfLJ1XXfV3UCGB25A/lvi x7BmmE5mN1ZFcqQxCTfw9at8jvXVWh6YrHObo/1C6g17JnlhvHXx7/blVnpCeEhJwhpV sM6GSHWr2Ueko0Lh3u+O3v7eSbEx/Ad7D1PcRprLgNA7tPthPBPlLq1I0FYCYIRAkE4q +rw5UdqVJo8t3oY4voaRwHFEkr44Icc8orC26hE+cRNwGRtHejzWOQpy2z19mdCpades MC/g== X-Gm-Message-State: AOJu0Yy7Ht2atwA38CdlPEYIubmOxi9N6xaFHmNaDoPaFFcuDmcEJAex SLzNv2uJXkIjmbCvhcj/5Pc= X-Google-Smtp-Source: AGHT+IHdlXlxKl+pMZjU2mZMnWOvALiEDg2A7uGwoYwB9uQ9BwzGzbxWdn4YL09VaUeTbSNsS4SZJw== X-Received: by 2002:a5d:6a04:0:b0:317:3b13:94c3 with SMTP id m4-20020a5d6a04000000b003173b1394c3mr8381160wru.41.1692805395206; Wed, 23 Aug 2023 08:43:15 -0700 (PDT) Received: from ?IPV6:2001:8a0:f90f:8600:1c58:11cc:d925:aeac? ([2001:8a0:f90f:8600:1c58:11cc:d925:aeac]) by smtp.gmail.com with ESMTPSA id j16-20020a056000125000b0031779a6b451sm19503468wrx.83.2023.08.23.08.43.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Aug 2023 08:43:14 -0700 (PDT) Message-ID: <6e0dd204-8e42-677e-2f5f-cc40c3d780b3@palves.net> Date: Wed, 23 Aug 2023 16:43:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH 2/2] [gdb/build] Return const reference in thread_info_to_thread_handle Content-Language: en-US To: Tom de Vries , gdb-patches@sourceware.org References: <20230821105356.869-1-tdevries@suse.de> <20230821105356.869-2-tdevries@suse.de> <4917ef2f-f50a-efc0-59a8-30e86d5ac53b@palves.net> <947d8961-598d-5680-185c-f583d69124c8@suse.de> From: Pedro Alves In-Reply-To: <947d8961-598d-5680-185c-f583d69124c8@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 List-Id: On 22/08/23 18:34, Tom de Vries wrote: > I've given the gdb::array_view a try, and that works fine, and greatly simplifies the patch, so thanks for that suggestion. Great! > The first patch is no longer necessary, but we could consider committing it nevertheless, since the work is done and may be needed in the future. I agree. > > -gdb::byte_vector > +gdb::array_view > remote_target::thread_info_to_thread_handle (struct thread_info *tp) > { > remote_thread_info *priv = get_remote_thread_info (tp); > diff --git a/gdb/target-debug.h b/gdb/target-debug.h > index acb01d47e7c..31c25e9aefd 100644 > --- a/gdb/target-debug.h > +++ b/gdb/target-debug.h > @@ -236,4 +236,18 @@ target_debug_print_gdb_byte_vector_r (gdb::byte_vector &vector) > { > target_debug_print_const_gdb_byte_vector_r (vector); > } > + > +static void > +target_debug_print_gdb_array_view_const_gdb_byte (gdb::array_view &vector) array_views should be passed by value normally (because they're small). Did you run into something that forced this to be a reference? Or was it just copied from the vector case? If it works, we should just drop the &. Also, one of the points of array_view is that you can pass a vector as array_view argument, like you can pass std::string as string_view argument -- would it work to make target_debug_print_const_gdb_byte_vector_r call this new target_debug_print_gdb_array_view_const_gdb_byte instead of duplicating that code? > +{ > + gdb_puts ("{", gdb_stdlog); > + > + for (size_t i = 0; i < vector.size (); i++) > + { > + gdb_printf (gdb_stdlog, " %s", > + phex_nz (vector[i], 1)); > + } > + gdb_puts (" }", gdb_stdlog); > +} > + > #endif /* TARGET_DEBUG_H */ ... > diff --git a/gdb/target.c b/gdb/target.c > index 16f43d072cd..8b1d48d91d9 100644 > --- a/gdb/target.c > +++ b/gdb/target.c > @@ -2640,7 +2640,7 @@ target_thread_handle_to_thread_info (const gdb_byte *thread_handle, > > /* See target.h. */ > > -gdb::byte_vector > +gdb::array_view > target_thread_info_to_thread_handle (struct thread_info *tip) > { > target_ops *target = current_inferior ()->top_target (); > diff --git a/gdb/target.h b/gdb/target.h > index 6ae400e2cc2..0cea955cbd7 100644 > --- a/gdb/target.h > +++ b/gdb/target.h > @@ -39,6 +39,10 @@ struct expression; > struct dcache_struct; > struct inferior; > > +/* Define const gdb_byte using one identifier, to make it easy for > + make-target-delegates.py to parse. */ > +typedef const gdb_byte const_gdb_byte; That's unfortunate, but I can live with it.