Skip to contentSkip to conversation

target/xtensa: clean up gdbstub register handling

PATCH New Max Filippov 1 participant 1 message Aug 20, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 target/xtensa: clean up gdbstub register handling

- move register counting to xtensa/gdbstub.c
- add symbolic names for register types and flags from GDB and use them in register counting and access functions.

---
Changes v1->v2:
- add missing dereference to the n_regs/n_core_regs in xtensa_count_regs

 target/xtensa/cpu.h     |  2 ++
 target/xtensa/gdbstub.c | 60 +++++++++++++++++++++++++++++++++++++++----------
 target/xtensa/helper.c  | 12 +---------
 3 files changed, 51 insertions(+), 23 deletions(-)
target/xtensa/cpu.h +2 -0
index 51b455146494..7472cf3ca32a 100644
@@ -503,6 +503,8 @@ void xtensa_cpu_do_unassigned_access(CPUState *cpu, hwaddr addr,
 void xtensa_cpu_dump_state(CPUState *cpu, FILE *f,
                            fprintf_function cpu_fprintf, int flags);
 hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+void xtensa_count_regs(const XtensaConfig *config,
+                       unsigned *n_regs, unsigned *n_core_regs);
 int xtensa_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);
 int xtensa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
target/xtensa/gdbstub.c +48 -12

113 lines not on this page · raw message

target/xtensa/helper.c +1 -11
index efb3cef12813..f74636f67854 100644
@@ -95,20 +95,10 @@ void xtensa_finalize_config(XtensaConfig *config)
 
     if (config->gdb_regmap.num_regs == 0 ||
         config->gdb_regmap.num_core_regs == 0) {
-        unsigned i;
         unsigned n_regs = 0;
         unsigned n_core_regs = 0;
 
-        for (i = 0; config->gdb_regmap.reg[i].targno >= 0; ++i) {
-            if (config->gdb_regmap.reg[i].type != 5 &&
-                config->gdb_regmap.reg[i].type != 6 &&
-                config->gdb_regmap.reg[i].type != 7) {
-                ++n_regs;
-                if ((config->gdb_regmap.reg[i].flags & 0x1) == 0) {
-                    ++n_core_regs;
-                }
-            }
-        }
+        xtensa_count_regs(config, &n_regs, &n_core_regs);
         if (config->gdb_regmap.num_regs == 0) {
             config->gdb_regmap.num_regs = n_regs;
         }
Signature · 1 line
2.11.0