Record the base register index in the generated C file. Check at runtime that either @g_pos argument of gdb_register_coprocessor() is zero, or it the base register index.
This change pass 'make check-tcg' test suite, which runs the tests/tcg/multiarch/gdbstub/registers.py test, itself calling gdb_register_coprocessor() for each target tested. Signed-off-by: Philippe Mathieu-Daudé <[email protected]> --- include/exec/gdbstub.h | 1 + gdbstub/gdbstub.c | 2 ++ scripts/feature_to_c.py | 1 + 3 files changed, 4 insertions(+) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index bd7182c4d32..12e7b5b7282 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -6,6 +6,7 @@ typedef struct GDBFeature { const char *xml; const char *name; const char * const *regs; + int base_reg; int num_regs; } GDBFeature; diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 90f4b95135b..6eadae3804e 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -610,6 +610,8 @@ void gdb_register_coprocessor(CPUState *cpu, guint i; int base_reg = cpu->gdb_num_regs; + assert(!g_pos || g_pos == feature->base_reg); + for (i = 0; i < cpu->gdb_regs->len; i++) { /* Check for duplicates. */ s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); diff --git a/scripts/feature_to_c.py b/scripts/feature_to_c.py index 1329695ad04..a52cd2e9ec6 100644 --- a/scripts/feature_to_c.py +++ b/scripts/feature_to_c.py @@ -102,6 +102,7 @@ def writeliteral(indent, bytes): sys.stdout.write(',\n') sys.stdout.write( ' },\n') + sys.stdout.write(f' .base_reg = {base_reg},\n') sys.stdout.write(f' .num_regs = {num_regs},\n') sys.stdout.write( ' },\n') -- 2.52.0
