target/espressif: check common_magic instead of gdb_arch string

The value returned by target_get_gdb_arch() is something specific for GDB.
There could be several variants of the same CPU.
If we start implementing all the variants, checking the string value,
could become incorrect.
It's better to check for xtensa->common_magic == XTENSA_COMMON_MAGIC

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: I20f3fdced176c3b9ab00f889743161ecad7280f9
Reviewed-on: https://review.openocd.org/c/openocd/+/7536
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Erhan Kurubas 2023-03-15 01:22:10 +03:00 committed by Antonio Borneo
parent ee31f1578a
commit faeae51d7f
1 changed files with 4 additions and 6 deletions

View File

@ -17,12 +17,10 @@
static struct esp_semihost_data __attribute__((unused)) *target_to_esp_semihost_data(struct target *target) static struct esp_semihost_data __attribute__((unused)) *target_to_esp_semihost_data(struct target *target)
{ {
const char *arch = target_get_gdb_arch(target); struct xtensa *xtensa = target->arch_info;
if (arch) { if (xtensa->common_magic == XTENSA_COMMON_MAGIC)
if (strncmp(arch, "xtensa", 6) == 0) return &target_to_esp_xtensa(target)->semihost;
return &target_to_esp_xtensa(target)->semihost; /* TODO: add riscv */
/* TODO: add riscv */
}
LOG_ERROR("Unknown target arch!"); LOG_ERROR("Unknown target arch!");
return NULL; return NULL;
} }