[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 2/3] target/ppc: Add GDB callbacks for SPRs
From: |
Fabiano Rosas |
Subject: |
[Qemu-devel] [PATCH v4 2/3] target/ppc: Add GDB callbacks for SPRs |
Date: |
Tue, 22 Jan 2019 15:01:11 -0200 |
These will be used to let GDB know about PPC's Special Purpose
Registers (SPR).
They take an index based on the order the registers appear in the XML
file sent by QEMU to GDB. This index does not match the actual
location of the registers in the env->spr array so the
gdb_find_spr_idx function does that conversion.
Signed-off-by: Fabiano Rosas <address@hidden>
---
target/ppc/translate_init.inc.c | 54 ++++++++++++++++++++++++++++++++-
1 file changed, 53 insertions(+), 1 deletion(-)
diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c
index 710064a25d..f29ac3558a 100644
--- a/target/ppc/translate_init.inc.c
+++ b/target/ppc/translate_init.inc.c
@@ -9487,6 +9487,55 @@ static bool avr_need_swap(CPUPPCState *env)
#endif
}
+#if !defined(CONFIG_USER_ONLY)
+static int gdb_find_spr_idx(CPUPPCState *env, int n)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) {
+ ppc_spr_t *spr = &env->spr_cb[i];
+
+ if (spr->name && spr->gdb_id == n) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+static int gdb_get_spr_reg(CPUPPCState *env, uint8_t *mem_buf, int n)
+{
+ int reg;
+ int len;
+
+ reg = gdb_find_spr_idx(env, n);
+ if (reg < 0) {
+ return 0;
+ }
+
+ len = TARGET_LONG_SIZE;
+ stn_p(mem_buf, len, env->spr[reg]);
+ ppc_maybe_bswap_register(env, mem_buf, len);
+ return len;
+}
+
+static int gdb_set_spr_reg(CPUPPCState *env, uint8_t *mem_buf, int n)
+{
+ int reg;
+ int len;
+
+ reg = gdb_find_spr_idx(env, n);
+ if (reg < 0) {
+ return 0;
+ }
+
+ len = TARGET_LONG_SIZE;
+ ppc_maybe_bswap_register(env, mem_buf, len);
+ env->spr[reg] = ldn_p(mem_buf, len);
+
+ return len;
+}
+#endif
+
static int gdb_get_float_reg(CPUPPCState *env, uint8_t *mem_buf, int n)
{
if (n < 32) {
@@ -9716,7 +9765,10 @@ static void ppc_cpu_realize(DeviceState *dev, Error
**errp)
gdb_register_coprocessor(cs, gdb_get_vsx_reg, gdb_set_vsx_reg,
32, "power-vsx.xml", 0);
}
-
+#ifndef CONFIG_USER_ONLY
+ gdb_register_coprocessor(cs, gdb_get_spr_reg, gdb_set_spr_reg,
+ pcc->gdb_num_sprs, "power-spr.xml", 0);
+#endif
qemu_init_vcpu(cs);
pcc->parent_realize(dev, errp);
--
2.17.1
- [Qemu-devel] [PATCH v4 0/3] ppc/gdbstub: Expose SPRs to GDB, Fabiano Rosas, 2019/01/22
- [Qemu-devel] [PATCH v4 1/3] target/ppc: Add SPRs XML generation code for gdbstub, Fabiano Rosas, 2019/01/22
- [Qemu-devel] [PATCH v4 2/3] target/ppc: Add GDB callbacks for SPRs,
Fabiano Rosas <=
- Re: [Qemu-devel] [Qemu-ppc] [PATCH v4 2/3] target/ppc: Add GDB callbacks for SPRs, Alexey Kardashevskiy, 2019/01/24
- Re: [Qemu-devel] [Qemu-ppc] [PATCH v4 2/3] target/ppc: Add GDB callbacks for SPRs, David Gibson, 2019/01/26
- Re: [Qemu-devel] [Qemu-ppc] [PATCH v4 2/3] target/ppc: Add GDB callbacks for SPRs, Fabiano Rosas, 2019/01/28
- Re: [Qemu-devel] [Qemu-ppc] [PATCH v4 2/3] target/ppc: Add GDB callbacks for SPRs, Alexey Kardashevskiy, 2019/01/28
- Re: [Qemu-devel] [Qemu-ppc] [PATCH v4 2/3] target/ppc: Add GDB callbacks for SPRs, Fabiano Rosas, 2019/01/30
- Re: [Qemu-devel] [Qemu-ppc] [PATCH v4 2/3] target/ppc: Add GDB callbacks for SPRs, Alexey Kardashevskiy, 2019/01/31
- Re: [Qemu-devel] [Qemu-ppc] [PATCH v4 2/3] target/ppc: Add GDB callbacks for SPRs, Fabiano Rosas, 2019/01/31
- Re: [Qemu-devel] [Qemu-ppc] [PATCH v4 2/3] target/ppc: Add GDB callbacks for SPRs, Alexey Kardashevskiy, 2019/01/31
[Qemu-devel] [PATCH v4 3/3] target/ppc: Enable reporting of SPRs to GDB, Fabiano Rosas, 2019/01/22