On 11/7/24 04:44, Song Gao wrote:
GDB already support LoongArch vector extension[1], QEMU gdb adds
LoongArch vector registers support, so that users can use 'info all-registers'
to get all vector registers values.

[1]: 
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=1e9569f383a3d5a88ee07d0c2401bd95613c222e

Signed-off-by: Song Gao <gaos...@loongson.cn>
---
based-on:
  https://patchew.org/QEMU/20240607035016.2975799-1-maob...@loongson.cn/

v2:
- fix tab line wrapper issue.
- Link to v1: 
https://patchew.org/QEMU/20240621065406.864232-1-gaos...@loongson.cn/

  configs/targets/loongarch64-linux-user.mak |  2 +-
  configs/targets/loongarch64-softmmu.mak    |  2 +-
  target/loongarch/gdbstub.c                 | 70 +++++++++++++++++++++-
  gdb-xml/loongarch-lasx.xml                 | 60 +++++++++++++++++++
  gdb-xml/loongarch-lsx.xml                  | 59 ++++++++++++++++++
  5 files changed, 189 insertions(+), 4 deletions(-)
  create mode 100644 gdb-xml/loongarch-lasx.xml
  create mode 100644 gdb-xml/loongarch-lsx.xml


+static int loongarch_gdb_get_vec(CPUState *cs, GByteArray *mem_buf, int n, int 
vl)
+{
+    LoongArchCPU *cpu = LOONGARCH_CPU(cs);
+    CPULoongArchState *env = &cpu->env;
+    int i, length = 0;
+
+    if (0 <= n && n < 32) {
+        for (i = 0; i < vl / 64; i++) {

Preferably using FOO_PER_BAR definitions for 32 & 64 magic values,

Reviewed-by: Philippe Mathieu-Daudé <phi...@linaro.org>

+            length += gdb_get_reg64(mem_buf, env->fpr[n].vreg.D(i));
+        }
+    }
+
+    return length;
+}
+
+static int loongarch_gdb_set_vec(CPUState *cs, uint8_t *mem_buf, int n, int vl)
+{
+    LoongArchCPU *cpu = LOONGARCH_CPU(cs);
+    CPULoongArchState *env = &cpu->env;
+    int i, length = 0;
+
+    if (0 <= n && n < 32) {
+        for (i = 0; i < vl / 64; i++) {
+            env->fpr[n].vreg.D(i) = ldq_le_p(mem_buf + 8 * i);
+            length += 8;
+        }
+    }
+
+    return length;
+}


Reply via email to