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 D70833858D33 for ; Tue, 14 Feb 2023 04:21:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D70833858D33 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com 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) From: Simon Marchi 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-Spam-Status: No, score=-1173.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_SOFTFAIL,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: 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