lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 7 Mar 2016 22:47:04 -0500
From:	Jeff Mahoney <jeffm@...e.com>
To:	Kieran Bingham <kieran.bingham@...aro.org>, jan.kiszka@...mens.com,
	linux-kernel@...r.kernel.org
Cc:	lee.jones@...aro.org, peter.griffin@...aro.org,
	maxime.coquelin@...com
Subject: Re: [PATCHv3 02/13] scripts/gdb: Provide kernel list item generators

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
> 
> CC: Jeff Mahoney <jeffm@...e.com>
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@...aro.org>
> ---
> 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(+)
> 
> 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 = utils.CachedType("struct list_head")
>  
>  
> +def list_for_each(head):
> +    if head.type == list_head.get_type().pointer():
> +        head = head.dereference()
> +    elif head.type != list_head.get_type():
> +        raise gdb.GdbError("Must be struct list_head not %s" % list_head.type)

Shouldn't this be % head.type?

> +
> +    node = head['next'].dereference()
> +    while node.address != head.address:
> +        yield node.address
> +        node = node['next'].dereference()
> +
> +
> +def list_for_each_entry(head, gdbtype, member):
> +    for node in list_for_each(head):
> +        if node.type != 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

-- 
Jeff Mahoney
SUSE Labs



Download attachment "signature.asc" of type "application/pgp-signature" (882 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ