Message ID | 20231028045813.685389-1-debug@rivosinc.com (mailing list archive) |
---|---|
State | Handled Elsewhere, archived |
Headers | show |
Series | [v6] scripts/gdb: add lx_current support for riscv | expand |
Context | Check | Description |
---|---|---|
conchuod/vmtest-for-next-PR | fail | PR summary |
conchuod/patch-1-test-1 | fail | .github/scripts/patches/build_rv32_defconfig.sh |
conchuod/patch-1-test-2 | fail | .github/scripts/patches/build_rv64_clang_allmodconfig.sh |
conchuod/patch-1-test-3 | fail | .github/scripts/patches/build_rv64_gcc_allmodconfig.sh |
conchuod/patch-1-test-4 | fail | .github/scripts/patches/build_rv64_nommu_k210_defconfig.sh |
conchuod/patch-1-test-5 | fail | .github/scripts/patches/build_rv64_nommu_virt_defconfig.sh |
conchuod/patch-1-test-6 | success | .github/scripts/patches/checkpatch.sh |
conchuod/patch-1-test-7 | success | .github/scripts/patches/dtb_warn_rv64.sh |
conchuod/patch-1-test-8 | success | .github/scripts/patches/header_inline.sh |
conchuod/patch-1-test-9 | success | .github/scripts/patches/kdoc.sh |
conchuod/patch-1-test-10 | success | .github/scripts/patches/module_param.sh |
conchuod/patch-1-test-11 | success | .github/scripts/patches/verify_fixes.sh |
conchuod/patch-1-test-12 | success | .github/scripts/patches/verify_signedoff.sh |
diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py index 255dc18cb9da..cba589e5b57d 100644 --- a/scripts/gdb/linux/cpus.py +++ b/scripts/gdb/linux/cpus.py @@ -179,6 +179,21 @@ def get_current_task(cpu): else: raise gdb.GdbError("Sorry, obtaining the current task is not allowed " "while running in userspace(EL0)") + elif utils.is_target_arch("riscv"): + current_tp = gdb.parse_and_eval("$tp") + scratch_reg = gdb.parse_and_eval("$sscratch") + + # by default tp points to current task + current_task = current_tp.cast(task_ptr_type) + + # scratch register is set 0 in trap handler after entering kernel. + # When hart is in user mode, scratch register is pointing to task_struct. + # and tp is used by user mode. So when scratch register holds larger value + # (negative address as ulong is larger value) than tp, then use scratch register. + if (scratch_reg.cast(utils.get_ulong_type()) > current_tp.cast(utils.get_ulong_type())): + current_task = scratch_reg.cast(task_ptr_type) + + return current_task.dereference() else: raise gdb.GdbError("Sorry, obtaining the current task is not yet " "supported with this arch")