From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2HERO3IM62O4QDIAWB0awg (envelope-from ) for ; Mon, 13 Feb 2023 23:22:10 -0500 Received: by simark.ca (Postfix, from userid 112) id EFBC61E221; Mon, 13 Feb 2023 23:22:10 -0500 (EST) 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=GIsYWskA; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id B56021E110 for ; Mon, 13 Feb 2023 23:22:10 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C6D5F3858434 for ; Tue, 14 Feb 2023 04:22:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6D5F3858434 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676348527; bh=5zyKHuRJkBAifpLx+PPJvaa+Mq7OiYotWkFoUZauRhE=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=GIsYWskAvaJEynuOcOlK+gGWC3zunDWVoxCysSAWCH4DuVP9j8Gm69nxvBNCoqO+G rucCCM21xD5/9pomBaLmEcG1ktg4PEjNVhoJIAzcyBwnlDzuKRMBI5TY5jp4WLFu2+ cUXbHBQqxUTYRk2atfeFhS3viLckUj881DiCJMXw= Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id D70833858D33 for ; Tue, 14 Feb 2023 04:21:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D70833858D33 Received: from localhost.localdomain (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 659DA1E221; Mon, 13 Feb 2023 23:21:41 -0500 (EST) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 3/3] gdb: keep internalvars sorted Date: Mon, 13 Feb 2023 23:21:39 -0500 Message-Id: <20230214042139.73638-3-simon.marchi@efficios.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214042139.73638-1-simon.marchi@efficios.com> References: <20230214042139.73638-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" In a test (downstream in ROCgdb), there was a test case failing when GDB_REVERSE_INIT_FUNCTIONS was set. The test was assuming a particular order in the output of "show convenience". And the order changed with GDB_REVERSE_INIT_FUNCTIONS. I think that a nice way to fix it is to make the output of "show convenience" sorted, and therefore stable. Ideally, I think that the the user-visible behavior of GDB should not change when using GDB_REVERSE_INIT_FUNCTIONS. Plus, it makes the output of "show convenience" look nice, not that it's really important. So, change create_internalvar to keep the internalvars vector sorted. Change-Id: I3a916a641e0d50ff698f5d097ef0cf10637ab8de --- gdb/value.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gdb/value.c b/gdb/value.c index 68499896af8c..2c37f94cba99 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1920,8 +1920,15 @@ complete_internalvar (completion_tracker &tracker, const char *name) struct internalvar * create_internalvar (const char *name) { - internalvars.emplace_back (new internalvar); - internalvar *var = internalvars.back ().get (); + auto it = std::lower_bound (internalvars.begin (), + internalvars.end (), + name, + [] (const internalvar_up &var, const char *name_) + { + return var->name < name_; + }); + + internalvar *var = internalvars.emplace (it, new internalvar)->get (); var->name = name; var->kind = INTERNALVAR_VOID; -- 2.39.1