All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, "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: Tue, 16 Jul 2024 17:55:01 +0100	[thread overview]
Message-ID: <87cyndgtui.fsf@draig.linaro.org> (raw)
In-Reply-To: <b9b178fc-04f5-49a6-992a-f6920408b41f@linaro.org> (Richard Henderson's message of "Wed, 17 Jul 2024 02:33:23 +1000")

Richard Henderson <richard.henderson@linaro.org> writes:

> 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?

Not really - I just want to check the string hasn't been added before.

>
> 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?

Its basically a hack to deal with the fact everything is tied to the
CPUObject so we register everything multiple times. We could do a if
(!registerd) register() dance but I guess I'm thinking forward to a
hydrogenous future but I guess we'd need to do more work then anyway.

>
>
> r~

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro

  reply	other threads:[~2024-07-16 16:55 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
2024-07-16 16:55   ` Alex Bennée [this message]
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=87cyndgtui.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=akihiko.odaki@daynix.com \
    --cc=gustavo.romero@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.