Skip to content

Commit ec6d2c8

Browse files
committed
esp32: send correct register list to GDB depending on reg_class
1 parent 370c35e commit ec6d2c8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/target/esp32.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -741,16 +741,25 @@ static int xtensa_get_gdb_reg_list(struct target *target,
741741
{
742742
int i;
743743
struct esp32_common *esp32 = target->arch_info;
744-
LOG_DEBUG("%s, reg_class=%i", __func__, (int)reg_class);
745744

746-
*reg_list_size = XT_NUM_REGS_G_COMMAND;
745+
if (reg_class == REG_CLASS_ALL)
746+
{
747+
*reg_list_size = esp32->core_caches[esp32->active_cpu]->num_regs;
748+
}
749+
else
750+
{
751+
*reg_list_size = XT_NUM_REGS_G_COMMAND;
752+
}
753+
754+
LOG_DEBUG("%s, reg_class=%i, num_regs=%d", __func__, (int)reg_class, *reg_list_size);
755+
747756
*reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
748757

749758
if (!*reg_list) {
750-
return ERROR_COMMAND_SYNTAX_ERROR;
759+
return ERROR_FAIL;
751760
}
752761

753-
for (i = 0; i < XT_NUM_REGS_G_COMMAND; i++) {
762+
for (i = 0; i < *reg_list_size; i++) {
754763
(*reg_list)[i] = &esp32->core_caches[esp32->active_cpu]->reg_list[i];
755764
}
756765

0 commit comments

Comments
 (0)