Hexagon: lldb read/write predicate registers p0/p1/p2/p3
PATCH v2 1/1 Hexagon: lldb read/write predicate registers p0/p1/p2/p3
hexagon-core.xml only exposes register p3_0 which is an alias that aggregates the predicate registers. It is more convenient for users to interact directly with the predicate registers.
Tested with lldb downloaded from this location
https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.4/clang+llvm-18.1.4-x86_64-linux-gnu-ubuntu-18.04.tar.xz
BEFORE:
(lldb) reg read p3_0
p3_0 = 0x00000000
(lldb) reg read p0
error: Invalid register name 'p0'.
(lldb) reg write p1 0xf
error: Register not found for 'p1'.
AFTER:
(lldb) reg read p3_0
p3_0 = 0x00000000
(lldb) reg read p0
p0 = 0x00
(lldb) reg read -s 1
Predicate Registers:
p0 = 0x00
p1 = 0x00
p2 = 0x00
p3 = 0x00(lldb) reg write p1 0xf
(lldb) reg read p3_0
p3_0 = 0x00000f00
(lldb) reg write p3_0 0xff00ff00
(lldb) reg read -s 1
Predicate Registers:
p0 = 0x00
p1 = 0xff
p2 = 0x00
p3 = 0xff--- target/hexagon/gdbstub.c | 19 ++++++++++++++++++- gdb-xml/hexagon-core.xml | 6 +++++- 2 files changed, 23 insertions(+), 2 deletions(-)
target/hexagon/gdbstub.c +18 -1
@@ -1,5 +1,5 @@/* -* Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved. +* Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -36,6 +36,14 @@ int hexagon_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)return gdb_get_regl (mem_buf, env->gpr[n]); } + n -=TOTAL_PER_THREAD_REGS ; + +if (n <NUM_PREGS ) { +return gdb_get_reg8 (mem_buf, env->pred[n]); + } + + n -=NUM_PREGS ; +g_assert_not_reached (); }
@@ -56,6 +64,15 @@ int hexagon_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)return sizeof (target_ulong); } + n -=TOTAL_PER_THREAD_REGS ; + +if (n <NUM_PREGS ) { + env->pred[n] =ldtul_p (mem_buf) &0xff ; +return sizeof (uint8_t ); + } + + n -=NUM_PREGS ; +g_assert_not_reached (); }
gdb-xml/hexagon-core.xml +5 -1
@@ -1,6 +1,6 @@ <?xml version="1.0"?> <!-- - Copyright(c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. + Copyright(c) 2023-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. This work is licensed under the terms of the GNU GPL, version 2 or (at your option) any later version. See the COPYING file in the
@@ -80,5 +80,9 @@ <reg name="c29" bitsize="32" offset="244" encoding="uint" format="hex" group="Thread Registers" dwarf_regnum="61"/> <reg name="utimerlo" bitsize="32" offset="248" encoding="uint" format="hex" group="Thread Registers" dwarf_regnum="62"/> <reg name="utimerhi" bitsize="32" offset="252" encoding="uint" format="hex" group="Thread Registers" dwarf_regnum="63"/> + <reg name="p0" bitsize="8" offset="256" encoding="uint" format="hex" group="Predicate Registers" dwarf_regnum="64"/> + <reg name="p1" bitsize="8" offset="257" encoding="uint" format="hex" group="Predicate Registers" dwarf_regnum="65"/> + <reg name="p2" bitsize="8" offset="258" encoding="uint" format="hex" group="Predicate Registers" dwarf_regnum="66"/> + <reg name="p3" bitsize="8" offset="259" encoding="uint" format="hex" group="Predicate Registers" dwarf_regnum="67"/> </feature>
Signature · 1 line
2.34.1
Quoted 38 lines · Taylor Simpson
hexagon-core.xml only exposes register
p3_0which is an alias that aggregates the predicate registers. It is more convenient for users to interact directly with the predicate registers.Tested with lldb downloaded from this location
https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.4/clang+llvm-18.1.4-x86_64-linux-gnu-ubuntu-18.04.tar.xzBEFORE:
(lldb) reg readp3_0p3_0 = 0x00000000(lldb) reg read p0
error: Invalid register name 'p0'.
(lldb) reg write p10xf
error: Register not found for 'p1'.AFTER:
(lldb) reg readp3_0p3_0 = 0x00000000 (lldb) reg read p0 p0 = 0x00 (lldb) reg read -s 1 Predicate Registers: p0 = 0x00 p1 = 0x00 p2 = 0x00 p3 = 0x00(lldb) reg write p1
0xf
(lldb) reg readp3_0p3_0 = 0x00000f00 (lldb) reg write p3_0 0xff00ff00 (lldb) reg read -s 1 Predicate Registers: p0 = 0x00 p1 = 0xff p2 = 0x00 p3 = 0xff
Quoted 1 line
Signed-off-by Taylor Simpson <[email protected]>
Quoted 69 lines
--- target/hexagon/gdbstub.c | 19 ++++++++++++++++++- gdb-xml/hexagon-core.xml | 6 +++++- 2 files changed, 23 insertions(+), 2 deletions(-)target/hexagon/gdbstub.c +18
-1@@ -1,5 +1,5 @@/* -* Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved. +* Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,6 +36,14 @@ int hexagon_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)return gdb_get_regl (mem_buf, env->gpr[n]); } + n -=TOTAL_PER_THREAD_REGS ; + +if (n <NUM_PREGS ) { +return gdb_get_reg8 (mem_buf, env->pred[n]); + } + + n -=NUM_PREGS ; +g_assert_not_reached (); }@@ -56,6 +64,15 @@ int hexagon_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)return sizeof (target_ulong); } + n -=TOTAL_PER_THREAD_REGS ; + +if (n <NUM_PREGS ) { + env->pred[n] =ldtul_p (mem_buf) &0xff ; +return sizeof (uint8_t ); + } + + n -=NUM_PREGS ; +g_assert_not_reached (); }gdb-xml/hexagon-core.xml +5
-1@@ -1,6 +1,6 @@ <?xml version="1.0"?> <!-- - Copyright(c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. + Copyright(c) 2023-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. This work is licensed under the terms of the GNU GPL, version 2 or (at your option) any later version. See the COPYING file in the@@ -80,5 +80,9 @@ <reg name="c29" bitsize="32" offset="244" encoding="uint" format="hex" group="Thread Registers" dwarf_regnum="61"/> <reg name="utimerlo" bitsize="32" offset="248" encoding="uint" format="hex" group="Thread Registers" dwarf_regnum="62"/> <reg name="utimerhi" bitsize="32" offset="252" encoding="uint" format="hex" group="Thread Registers" dwarf_regnum="63"/> + <reg name="p0" bitsize="8" offset="256" encoding="uint" format="hex" group="Predicate Registers" dwarf_regnum="64"/> + <reg name="p1" bitsize="8" offset="257" encoding="uint" format="hex" group="Predicate Registers" dwarf_regnum="65"/> + <reg name="p2" bitsize="8" offset="258" encoding="uint" format="hex" group="Predicate Registers" dwarf_regnum="66"/> + <reg name="p3" bitsize="8" offset="259" encoding="uint" format="hex" group="Predicate Registers" dwarf_regnum="67"/> </feature>
Quoted 39 lines · On Thu, 13 Jun 2024 12:22:09 -0600 Taylor Simpson <[email protected]>…
hexagon-core.xml only exposes register
p3_0which is an alias that aggregates the predicate registers. It is more convenient for users to interact directly with the predicate registers.Tested with lldb downloaded from this location
https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.4/clang+llvm-18.1.4-x86_64-linux-gnu-ubuntu-18.04.tar.xzBEFORE:
(lldb) reg readp3_0p3_0 = 0x00000000(lldb) reg read p0
error: Invalid register name 'p0'.
(lldb) reg write p10xf
error: Register not found for 'p1'.AFTER:
(lldb) reg readp3_0p3_0 = 0x00000000 (lldb) reg read p0 p0 = 0x00 (lldb) reg read -s 1 Predicate Registers: p0 = 0x00 p1 = 0x00 p2 = 0x00 p3 = 0x00(lldb) reg write p1
0xf
(lldb) reg readp3_0p3_0 = 0x00000f00 (lldb) reg write p3_0 0xff00ff00 (lldb) reg read -s 1 Predicate Registers: p0 = 0x00 p1 = 0xff p2 = 0x00 p3 = 0xff
Quoted 1 line
Signed-off-by Taylor Simpson <[email protected]>