[llvm-branch-commits] [lldb] [lldb][RISCV] Support RVV register access (PR #184308)
Sam Elliott via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Apr 14 19:54:09 PDT 2026
================
@@ -24,14 +24,54 @@
// System includes - They have to be included after framework includes because
// they define some macros which collide with variable names in other modules
#include <sys/ptrace.h>
+#include <sys/syscall.h>
#include <sys/uio.h>
+#include <unistd.h>
// NT_PRSTATUS and NT_FPREGSET definition
#include <elf.h>
+#ifndef NT_RISCV_VECTOR
+#define NT_RISCV_VECTOR 0x901
+#endif
+#ifndef __NR_riscv_hwprobe
+#define __NR_riscv_hwprobe 258
+#endif
+#ifndef RISCV_HWPROBE_KEY_IMA_EXT_0
+#define RISCV_HWPROBE_KEY_IMA_EXT_0 4
+#endif
+#ifndef RISCV_HWPROBE_IMA_V
+#define RISCV_HWPROBE_IMA_V (1 << 2)
+#endif
+
+struct HWProbeRISCV {
+ int64_t key;
+ uint64_t value;
+};
+
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::process_linux;
+static uint64_t GetVLENB() {
+ struct HWProbeRISCV query = {RISCV_HWPROBE_KEY_IMA_EXT_0, 0};
+ if (syscall(__NR_riscv_hwprobe, &query, 1, 0, NULL, 0) != 0)
+ return 0;
+
+ if ((query.value & RISCV_HWPROBE_IMA_V) == 0)
+ return 0;
----------------
lenary wrote:
One thing I don't understand about the Linux API here is what this returns if you have one of the V subsets (i.e. `zve32x`). presumably false? In these cases you would still have V registers.
Do we also need to take into account the `prctrl`s here: https://docs.kernel.org/arch/riscv/vector.html for whether the process is allowed access to V registers?
I am less familiar with the arch<->Linux<->debugger interactions, sorry if these questions are wrong.
https://github.com/llvm/llvm-project/pull/184308
More information about the llvm-branch-commits
mailing list