Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757449AbcCCLrp (ORCPT ); Thu, 3 Mar 2016 06:47:45 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:36539 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755254AbcCCLlU (ORCPT ); Thu, 3 Mar 2016 06:41:20 -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 03/13] scripts/gdb: Convert modules usage to lists functions Date: Thu, 3 Mar 2016 11:40:57 +0000 Message-Id: <1457005267-843-4-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: 1936 Lines: 59 Simplify the module list functions with the new list_for_each_entry abstractions Signed-off-by: Kieran Bingham --- scripts/gdb/linux/modules.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py index 25db8cff44a2..571489b3b9c2 100644 --- a/scripts/gdb/linux/modules.py +++ b/scripts/gdb/linux/modules.py @@ -13,7 +13,7 @@ import gdb -from linux import cpus, utils +from linux import cpus, utils, lists module_type = utils.CachedType("struct module") @@ -23,12 +23,9 @@ def module_list(): global module_type module_ptr_type = module_type.get_type().pointer() modules = gdb.parse_and_eval("modules") - entry = modules['next'] - end_of_list = modules.address - while entry != end_of_list: - yield utils.container_of(entry, module_ptr_type, "list") - entry = entry['next'] + for module in lists.list_for_each_entry(modules, module_ptr_type, "list"): + yield module def find_module_by_name(name): @@ -79,17 +76,15 @@ class LxLsmod(gdb.Command): size=str(module['core_size']), ref=str(module['refcnt']['counter']))) - source_list = module['source_list'] t = self._module_use_type.get_type().pointer() - entry = source_list['next'] first = True - while entry != source_list.address: - use = utils.container_of(entry, t, "source_list") + sources = module['source_list'] + for use in lists.list_for_each_entry(sources, t, "source_list"): gdb.write("{separator}{name}".format( separator=" " if first else ",", name=use['source']['name'].string())) first = False - entry = entry['next'] + gdb.write("\n") -- 2.5.0