Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757528AbcCCLoS (ORCPT ); Thu, 3 Mar 2016 06:44:18 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:32967 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756977AbcCCLl1 (ORCPT ); Thu, 3 Mar 2016 06:41:27 -0500 From: Kieran Bingham To: jan.kiszka@siemens.com, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, peter.griffin@linaro.org, maxime.coquelin@st.com, Kieran Bingham Subject: [PATCHv3 10/13] scripts/gdb: Add cpu iterators Date: Thu, 3 Mar 2016 11:41:04 +0000 Message-Id: <1457005267-843-11-git-send-email-kieran.bingham@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457005267-843-1-git-send-email-kieran.bingham@linaro.org> References: <1457005267-843-1-git-send-email-kieran.bingham@linaro.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1183 Lines: 43 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 --- 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