From: Jan Kiszka Date: Tue, 17 Feb 2015 21:47:24 +0000 (-0800) Subject: scripts/gdb: add lx_current convenience function X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=116b47b4da037547585cebe4e3275ef68905d509;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git scripts/gdb: add lx_current convenience function This is a shorthand for *$lx_per_cpu("current_task"), i.e. a convenience function to retrieve the currently running task of the active context. Signed-off-by: Jan Kiszka Cc: Thomas Gleixner Cc: Jason Wessel Cc: Andi Kleen Cc: Ben Widawsky Cc: Borislav Petkov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py index 18337e01ddef..b683da92f194 100644 --- a/scripts/gdb/linux/cpus.py +++ b/scripts/gdb/linux/cpus.py @@ -66,3 +66,20 @@ Note that VAR has to be quoted as string.""" PerCpu() + + +class LxCurrentFunc(gdb.Function): + """Return current task. + +$lx_current([CPU]): Return the per-cpu task variable for the given CPU +number. If CPU is omitted, the CPU of the current context is used.""" + + def __init__(self): + super(LxCurrentFunc, self).__init__("lx_current") + + def invoke(self, cpu=-1): + var_ptr = gdb.parse_and_eval("¤t_task") + return per_cpu(var_ptr, cpu).dereference() + + +LxCurrentFunc()