From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 6E3553858C2D for ; Tue, 8 Nov 2022 21:44:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6E3553858C2D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [172.16.0.64] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id AAD1A1E0CB; Tue, 8 Nov 2022 16:44:45 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1667943885; bh=9uQGlbD0WLwJBc+I3l1v8/hr1BfDwcpQ4A4NCeY90DA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=U1Za8i9+Op/rf6Q5PzB/MYY1UD9Hi3d9pMWd2qY9T0+FCzJ/mz6jSMHUL1edE1I5q 1CGOk7ziUIEr67ZDjDCB/YeNDaPB2CgLh3ayZgL8z72Ge1tS1z+FkkEiS/7hg6R9Si Gn1VO1SBNgZC4igDazXDmX8+ZKAvm80yYFHwfBwU= Message-ID: <21fcb251-3946-d180-c457-e996a31f9df8@simark.ca> Date: Tue, 8 Nov 2022 16:44:45 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH] gdb/py-inferior: Keep inferior threads in a map Content-Language: fr To: Lancelot SIX , gdb-patches@sourceware.org Cc: lsix@lancelotsix.com References: <20221107184727.2228056-1-lancelot.six@amd.com> From: Simon Marchi In-Reply-To: <20221107184727.2228056-1-lancelot.six@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_PASS,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 11/7/22 13:47, Lancelot SIX via Gdb-patches wrote: > diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c > index 8847a6d9308..9fd5f30fcdb 100644 > --- a/gdb/python/py-inferior.c > +++ b/gdb/python/py-inferior.c > @@ -30,17 +30,9 @@ > #include "gdbsupport/gdb_signals.h" > #include "py-event.h" > #include "py-stopevent.h" > +#include > > -struct threadlist_entry > -{ > - threadlist_entry (gdbpy_ref &&ref) > - : thread_obj (std::move (ref)) > - { > - } > - > - gdbpy_ref thread_obj; > - struct threadlist_entry *next; > -}; > +using thread_map_t = std::map>; You probably want to use unordered_map, which is preferable when we don't care about key order. Every time someone introduces a use of a map, there's the topic of "but hashtab is faster than std::unordered_map" that comes but, and the fact that gcc has some C++ bindings for it, and that we should import and use it, but that it was never done because its "empty" method confusingly empties the map, rather than returning whether the map is empty. But still, I think that std::unordered_map is preferable over std::map. I haven't checked the rest of the patch, since Tom already has. Simon