From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: Florian Hofhammer <florian.hofhammer@fhofhammer.de>,
qemu-ppc@nongnu.org,
Pierrick Bouvier <pierrick.bouvier@linaro.org>,
qemu-devel@nongnu.org
Subject: Re: ppc-linux-user GDB stub broken
Date: Fri, 27 Feb 2026 15:01:06 +0000 [thread overview]
Message-ID: <87bjhaxmbx.fsf@draig.linaro.org> (raw)
In-Reply-To: <70d4f460-c5c5-45ac-9ef0-2307ea4834f2@linaro.org> ("Philippe Mathieu-Daudé"'s message of "Fri, 27 Feb 2026 14:09:14 +0100")
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> On 27/2/26 10:58, Philippe Mathieu-Daudé wrote:
>> Hi Florian,
>
>
>>> on current master (d8a9d97317d03190b34498741f98f22e2a9afe3e), the basic
>>> gdb stub test fails for ppc-linux-user when running "make check-tcg".
>
>
>>> I've debugged around a bit but I don't know my way around the gdbstub
>>> internals enough to propose a patch right away, so I'll just summarize
>>> what I figured out so far.
>>> 1. Due to cc->gdb_num_core_regs not being set explicitly anymore, it is
>>> set to 0 at the end of gdbstub/gdbstub.c:gdb_init_cpu(). In the same
>>> function, cpu->gdb_num_regs gets set to 70.
>>> 2. When the test tries to read a register in gdbstub/gdbstub.c:gdb_read_register(),
>>> the first condition of "reg < cc->gdb_num_core_regs" is always false.
>>> Also, the register number for fpscr passed to the function is is 103,
>>> and cpu->gdb_num_regs is also 103. If the register number is supposed
>>> to be an index (as I understand it), this would indicate an
>>> off-by-one error somewhere.
>>>
>>> If you have some pointers on where to look / what to check out for
>>> fixing this, I'll happily try to work on a patch. But I suppose that
>>> somebody more experienced with this could probably fix this much faster
>>> than I can.
>> I'll have a look.
>
> Short term, this seems to fix it:
>
> -- >8 --
> diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
> index 90f4b95135b..0b0a5d1e044 100644
> --- a/gdbstub/gdbstub.c
> +++ b/gdbstub/gdbstub.c
> @@ -610,6 +610,10 @@ void gdb_register_coprocessor(CPUState *cpu,
> guint i;
> int base_reg = cpu->gdb_num_regs;
>
> + if (g_pos && g_pos != base_reg) {
> + base_reg = g_pos;
> + }
> +
> for (i = 0; i < cpu->gdb_regs->len; i++) {
> /* Check for duplicates. */
> s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i);
> @@ -622,14 +626,7 @@ void gdb_register_coprocessor(CPUState *cpu,
>
> /* Add to end of list. */
> cpu->gdb_num_regs += feature->num_regs;
> - if (g_pos) {
> - if (g_pos != base_reg) {
> - error_report("Error: Bad gdb register numbering for '%s', "
> - "expected %d got %d", feature->xml, g_pos,
> base_reg);
> - } else {
> - cpu->gdb_num_g_regs = cpu->gdb_num_regs;
> - }
> - }
> + cpu->gdb_num_g_regs = cpu->gdb_num_regs;
> }
>
> void gdb_unregister_coprocessor_all(CPUState *cpu)
> diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c
> index e0aae9c9eaf..51b14b95b9f 100644
> --- a/target/ppc/gdbstub.c
> +++ b/target/ppc/gdbstub.c
> @@ -502,7 +502,7 @@ void ppc_gdb_init(CPUState *cs, PowerPCCPUClass *pcc)
> {
> if (pcc->insns_flags & PPC_FLOAT) {
> gdb_register_coprocessor(cs, gdb_get_float_reg, gdb_set_float_reg,
> - gdb_find_static_feature("power-fpu.xml"), 0);
> + gdb_find_static_feature("power-fpu.xml"), 71);
> }
> if (pcc->insns_flags & PPC_ALTIVEC) {
> gdb_register_coprocessor(cs, gdb_get_avr_reg, gdb_set_avr_reg,
>
> ---
Tested-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2026-02-27 15:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 8:28 ppc-linux-user GDB stub broken Florian Hofhammer
2026-02-27 9:58 ` Philippe Mathieu-Daudé
2026-02-27 13:09 ` Philippe Mathieu-Daudé
2026-02-27 15:01 ` Alex Bennée [this message]
2026-02-27 21:40 ` Philippe Mathieu-Daudé
2026-02-27 21:43 ` Pierrick Bouvier
2026-02-27 21:47 ` Pierrick Bouvier
2026-02-27 17:21 ` Pierrick Bouvier
2026-02-27 21:24 ` Pierrick Bouvier
2026-02-28 17:53 ` Alex Bennée
2026-03-01 0:40 ` Pierrick Bouvier
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=87bjhaxmbx.fsf@draig.linaro.org \
--to=alex.bennee@linaro.org \
--cc=florian.hofhammer@fhofhammer.de \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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 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.