Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753608AbcCHDrP (ORCPT ); Mon, 7 Mar 2016 22:47:15 -0500 Received: from mx2.suse.de ([195.135.220.15]:51165 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753247AbcCHDrO (ORCPT ); Mon, 7 Mar 2016 22:47:14 -0500 Subject: Re: [PATCHv3 02/13] scripts/gdb: Provide kernel list item generators To: Kieran Bingham , jan.kiszka@siemens.com, linux-kernel@vger.kernel.org References: <1457005267-843-1-git-send-email-kieran.bingham@linaro.org> <1457005267-843-3-git-send-email-kieran.bingham@linaro.org> Cc: lee.jones@linaro.org, peter.griffin@linaro.org, maxime.coquelin@st.com From: Jeff Mahoney Message-ID: <56DE4B38.8060308@suse.com> Date: Mon, 7 Mar 2016 22:47:04 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1457005267-843-3-git-send-email-kieran.bingham@linaro.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="O7HsR0gSX3raKXDIdN4eWVPexLuoXt5XF" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3736 Lines: 100 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --O7HsR0gSX3raKXDIdN4eWVPexLuoXt5XF Content-Type: multipart/mixed; boundary="5PoiHtHIVw6gOixmf18kjoxTP9usfHUpp" From: Jeff Mahoney To: Kieran Bingham , jan.kiszka@siemens.com, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, peter.griffin@linaro.org, maxime.coquelin@st.com Message-ID: <56DE4B38.8060308@suse.com> Subject: Re: [PATCHv3 02/13] scripts/gdb: Provide kernel list item generators References: <1457005267-843-1-git-send-email-kieran.bingham@linaro.org> <1457005267-843-3-git-send-email-kieran.bingham@linaro.org> In-Reply-To: <1457005267-843-3-git-send-email-kieran.bingham@linaro.org> --5PoiHtHIVw6gOixmf18kjoxTP9usfHUpp Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 3/3/16 6:40 AM, Kieran Bingham wrote: > Facilitate linked-list items by providing a generator to return > the dereferenced, and type-cast objects from a kernel linked list >=20 > CC: Jeff Mahoney >=20 > Signed-off-by: Kieran Bingham > --- > Changes since v1: > * items function removed, and replaced with Jeff Mahoney's cleaner > implementations of list_for_each, and list_for_each_entry > --- > scripts/gdb/linux/lists.py | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) >=20 > diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py > index 3a3775bc162b..9f4503738e26 100644 > --- a/scripts/gdb/linux/lists.py > +++ b/scripts/gdb/linux/lists.py > @@ -18,6 +18,26 @@ from linux import utils > list_head =3D utils.CachedType("struct list_head") > =20 > =20 > +def list_for_each(head): > + if head.type =3D=3D list_head.get_type().pointer(): > + head =3D head.dereference() > + elif head.type !=3D list_head.get_type(): > + raise gdb.GdbError("Must be struct list_head not %s" % list_he= ad.type) Shouldn't this be % head.type? > + > + node =3D head['next'].dereference() > + while node.address !=3D head.address: > + yield node.address > + node =3D node['next'].dereference() > + > + > +def list_for_each_entry(head, gdbtype, member): > + for node in list_for_each(head): > + if node.type !=3D list_head.get_type().pointer(): > + raise TypeError("Type %s found. " > + "Expected struct list_head *." % node.type= ) Nit, but FWIW, I've adopted the kernel style of always keeping strings on one line so they're easily greppable. -Jeff --=20 Jeff Mahoney SUSE Labs --5PoiHtHIVw6gOixmf18kjoxTP9usfHUpp-- --O7HsR0gSX3raKXDIdN4eWVPexLuoXt5XF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.19 (Darwin) Comment: GPGTools - http://gpgtools.org iQIcBAEBAgAGBQJW3ks8AAoJEB57S2MheeWyeh4QAIWvLTSPGH+k8bORLY9sfa/Y rCDwTX5N+PFxhwQqQKcu1unz49aPVknYHF7652Jg5OAMn4QA2ZcnCL5QzXfhDQcY 70C2TvNxm8MAy804XmVP5yKOV3b28r+zCRBeAtTkBQmtTFGl1HieoHMW+D1fnMBF doqseEj6eD+s4fBozfLxqvqnxC4Tj9E+cWY8X+BUFou4l2htqKlQL7+tQtiQrvFC vsXWs5OjIchTm9zFKRh8kF8OkddFvQZD7JL8JXov9fWwYjeysVLEFglpiPW2jAuR s7gX7MIq8QHPT2fUQuVpC5jk40NuaKtHL4tUaoqd/PLFbLGk+OVIhGS4T306nCUC HhdNII6bfWuuCMSieRYeru1AEfAiiwo3Nfcf6sBV0obVuq4VaksK5CeT0Sp/e7Le 8aFwGT03djQ2uzf5bqEQ9bg0zI3Z5MtCQs7xPP70wG/+aNB6w3LWXzxhiompyHnb 08JegO8/J61cm4c8MxZnMgrwd6YTPj43WLxIWzihEAIFM2rsbkhWWI2uH6FpcnyA iP4qizmJiV3nK/x3cSzKaI09vjWUACWbH59SLfnCmdlItzsI4aPUsAzA8/Rb8fiZ BERnL4vCwj1fl+3stVEGNH5dPArD5GaKAMZBk3mY8EUG5zxVPSINLPAmUiKKtzVS GIpDS+0LpCwIikCW1Ubk =oxsx -----END PGP SIGNATURE----- --O7HsR0gSX3raKXDIdN4eWVPexLuoXt5XF--