From: Richard Henderson <richard.henderson@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Cc: "Akihiko Odaki" <akihiko.odaki@daynix.com>,
"Gustavo Bueno Romero" <gustavo.romero@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"open list:ARM TCG CPUs" <qemu-arm@nongnu.org>
Subject: Re: [RFC PATCH] gdbstub: Re-factor gdb command extensions
Date: Wed, 17 Jul 2024 02:33:23 +1000 [thread overview]
Message-ID: <b9b178fc-04f5-49a6-992a-f6920408b41f@linaro.org> (raw)
In-Reply-To: <20240716114229.329355-1-alex.bennee@linaro.org>
On 7/16/24 21:42, Alex Bennée wrote:
> void gdb_extend_qsupported_features(char *qsupported_features)
> {
> - /*
> - * We don't support different sets of CPU gdb features on different CPUs yet
> - * so assert the feature strings are the same on all CPUs, or is set only
> - * once (1 CPU).
> - */
> - g_assert(extended_qsupported_features == NULL ||
> - g_strcmp0(extended_qsupported_features, qsupported_features) == 0);
> -
> - extended_qsupported_features = qsupported_features;
> + if (!extended_qsupported_features) {
> + extended_qsupported_features = g_strdup(qsupported_features);
> + } else if (!g_strrstr(extended_qsupported_features, qsupported_features)) {
Did you really need the last instance of the substring?
I'll note that g_strrstr is quite simplistic, whereas strstr has a much more scalable
algorithm.
> + char *old = extended_qsupported_features;
> + extended_qsupported_features = g_strdup_printf("%s%s", old, qsupported_features);
Right tool for the right job, please: g_strconcat().
That said, did you *really* want to concatenate now, and have to search through the
middle, as opposed to storing N strings separately? You could defer the concat until the
actual negotiation with gdb. That would reduce strstr above to a loop over strcmp.
> + for (int i = 0; i < extensions->len; i++) {
> + gpointer entry = g_ptr_array_index(extensions, i);
> + if (!g_ptr_array_find(table, entry, NULL)) {
> + g_ptr_array_add(table, entry);
Are you expecting the same GdbCmdParseEntry object to be registered multiple times? Can
we fix that at a higher level?
r~
next prev parent reply other threads:[~2024-07-16 16:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 11:42 [RFC PATCH] gdbstub: Re-factor gdb command extensions Alex Bennée
2024-07-16 12:42 ` Gustavo Romero
2024-07-16 13:48 ` Alex Bennée
2024-07-16 14:09 ` Peter Maydell
2024-07-16 15:13 ` Gustavo Romero
2024-07-16 16:33 ` Richard Henderson [this message]
2024-07-16 16:55 ` Alex Bennée
2024-07-16 21:53 ` Richard Henderson
2024-07-17 8:24 ` Alex Bennée
2024-07-17 12:59 ` Peter Maydell
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=b9b178fc-04f5-49a6-992a-f6920408b41f@linaro.org \
--to=richard.henderson@linaro.org \
--cc=akihiko.odaki@daynix.com \
--cc=alex.bennee@linaro.org \
--cc=gustavo.romero@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.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 NNTP newsgroup(s).