Skip to content

Commit

Permalink
scripts/gdb: add lx_current convenience function
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Jason Wessel <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Ben Widawsky <[email protected]>
Cc: Borislav Petkov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
jan-kiszka authored and torvalds committed Feb 17, 2015
1 parent fe7f9ed commit 116b47b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions scripts/gdb/linux/cpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,20 @@ def invoke(self, var_name, cpu=-1):


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("&current_task")
return per_cpu(var_ptr, cpu).dereference()


LxCurrentFunc()

0 comments on commit 116b47b

Please sign in to comment.