From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 3/3] gdb: keep internalvars sorted
Date: Mon, 13 Feb 2023 23:21:39 -0500 [thread overview]
Message-ID: <20230214042139.73638-3-simon.marchi@efficios.com> (raw)
In-Reply-To: <20230214042139.73638-1-simon.marchi@efficios.com>
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
next prev parent reply other threads:[~2023-02-14 4:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-14 4:21 [PATCH 1/3] gdb: store internalvars in an std::vector Simon Marchi
2023-02-14 4:21 ` [PATCH 2/3] gdb: use std::string for internalvar::name Simon Marchi
2023-02-14 4:21 ` Simon Marchi [this message]
2023-02-14 10:54 ` [PATCH 1/3] gdb: store internalvars in an std::vector Lancelot SIX
2023-02-14 18:41 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230214042139.73638-3-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).