diff --git a/target/xtensa/gdbstub.c b/target/xtensa/gdbstub.c index fe435bac26..d571c0b6b3 100644 --- a/target/xtensa/gdbstub.c +++ b/target/xtensa/gdbstub.c @@ -46,6 +46,12 @@ void xtensa_count_regs(const XtensaConfig *config, unsigned i; bool count_core_regs = true; + /* Espressif local: allow changing the behavior here based on QEMU_XTENSA_COUNT_WINDOW_REGS + * environment variable. + */ + const char* count_window_regs_env = getenv("QEMU_XTENSA_COUNT_WINDOW_REGS"); + bool count_window_regs = count_window_regs_env != NULL && strcmp(count_window_regs_env, "0") != 0; + for (i = 0; config->gdb_regmap.reg[i].targno >= 0; ++i) { if (config->gdb_regmap.reg[i].type != xtRegisterTypeTieState && config->gdb_regmap.reg[i].type != xtRegisterTypeMapped && diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index ca214b948a..32b95d0370 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -185,6 +185,15 @@ static void xtensa_core_class_init(ObjectClass *oc, void *data) * in the gdb/xtensa-config.c inside gdb source tree or inside gdb overlay. */ cc->gdb_num_core_regs = config->gdb_regmap.num_regs; + + /* Espressif local: allow changing the behavior here using + * QEMU_XTENSA_CORE_REGS_ONLY environment variable, to support different + * GDB builds + */ + const char* core_regs_only = getenv("QEMU_XTENSA_CORE_REGS_ONLY"); + if (core_regs_only != NULL && strcmp(core_regs_only, "0") != 0) { + cc->gdb_num_core_regs = config->gdb_regmap.num_core_regs; + } } void xtensa_register_core(XtensaConfigList *node)