On 16/01/2026 19:24, Pierrick Bouvier wrote: > In practice, it may return anything else than 0 (see > arm_cpu_gdb_write_register for instance). > So the right (vague) description should be: > On success returns 0.
Hmm, it seems to me as if the code is a bit inconsistent here: the plugin API in plugins/api.c returns -1 if it detects an error directly, and the arm_cpu_gdb_write_register() (but it's similar for other archs, e.g., x86_cpu_gdb_write_register()) returns 0 if the register is unknown and the number of bytes written otherwise (in the arm example: 4 for the general-purpose registers). That means that currently, both -1 and 0 as return value indicate an error. Thanks for the catch, that made me dig into the actual gdbstub code a bit more! In order to make this consistent, there are two options I see: 1) Change the plugin API function to return 0 on error (but then it's inconsistent with the qemu_plugin_read_register() function which returns -1 on error), or 2) Change the arch-specific gdbstub functions to return -1 on error instead of 0. What do you think? I'd be happy to prepare a patch for either option. Best regards, Florian
