Skip to contentSkip to conversation

scripts/gdb: fix aarch64 userspace detection in get_current_task

PATCH Applied Jan Kiszka 1 participant 1 message Jan 10, 2025 GDB kernel debugging helper scripts

lore
Share & tools
lore

Jan Kiszka

author maintainer
#0 lore raw

PATCH 1/1 scripts/gdb: fix aarch64 userspace detection in get_current_task

From: Jan Kiszka <[email protected]>

At least recent gdb releases (seen with 14.2) return SP_EL0 as signed long which lets the right-shift always return 0.

---
 scripts/gdb/linux/cpus.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gdb/linux/cpus.py +1 -1
index 2f11c4f9c345..13eb8b3901b8 100644
@@ -167,7 +167,7 @@ def get_current_task(cpu):
             var_ptr = gdb.parse_and_eval("&pcpu_hot.current_task")
             return per_cpu(var_ptr, cpu).dereference()
     elif utils.is_target_arch("aarch64"):
-        current_task_addr = gdb.parse_and_eval("$SP_EL0")
+        current_task_addr = gdb.parse_and_eval("(unsigned long)$SP_EL0")
         if (current_task_addr >> 63) != 0:
             current_task = current_task_addr.cast(task_ptr_type)
             return current_task.dereference()
Signature · 1 line
2.43.0