lkml.org 
[lkml]   [2016]   [Mar]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCHv3 10/13] scripts/gdb: Add cpu iterators
Date
The linux kernel provides macro's for iterating against values from the
cpu_list masks. By providing some commonly used masks, we can mirror the
kernels helper macros with easy to use generators.

Signed-off-by: Kieran Bingham <kieran.bingham@linaro.org>
---
scripts/gdb/linux/cpus.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py
index 4297b83fedef..59e24472c507 100644
--- a/scripts/gdb/linux/cpus.py
+++ b/scripts/gdb/linux/cpus.py
@@ -100,6 +100,27 @@ def cpu_list(mask_name):
yield cpu


+def each_online_cpu():
+ for cpu in cpu_list("cpu_online_mask"):
+ yield cpu
+
+
+def each_present_cpu():
+ for cpu in cpu_list("cpu_present_mask"):
+ yield cpu
+
+
+def each_possible_cpu():
+ for cpu in cpu_list("cpu_possible_mask"):
+ yield cpu
+
+
+def print_cpus():
+ gdb.write("Possible CPUS : {}\n".format(list(each_possible_cpu())))
+ gdb.write("Present CPUS : {}\n".format(list(each_present_cpu())))
+ gdb.write("Online CPUS : {}\n".format(list(each_online_cpu())))
+
+
class PerCpu(gdb.Function):
"""Return per-cpu variable.

--
2.5.0
\
 
 \ /
  Last update: 2016-03-03 13:41    [W:0.164 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site