Re: [PATCH 2/2] scripts/gdb: add helpers to find and list devices

From: Stephen Boyd
Date: Tue Jun 25 2019 - 23:18:11 EST


Quoting Leonard Crestez (2019-06-25 13:05:12)
> Add helper commands and functions for finding pointers to struct device
> by enumerating linux device bus/class infrastructure. This can be used
> to fetch subsystem and driver-specific structs:
>
> (gdb) p *$container_of($lx_device_find_by_class_name("net", "eth0"), "struct net_device", "dev")
> (gdb) p *$container_of($lx_device_find_by_bus_name("i2c", "0-004b"), "struct i2c_client", "dev")
> (gdb) p *(struct imx_port*)$lx_device_find_by_class_name("tty", "ttymxc1")->parent->driver_data
>
> Several generic "lx-device-list" functions are included to enumerate
> devices by bus and class:
>
> (gdb) lx-device-list-bus usb
> (gdb) lx-device-list-class
> (gdb) lx-device-list-tree &platform_bus
>
> Similar information is available in /sys but pointer values are
> deliberately hidden.
>
> Signed-off-by: Leonard Crestez <leonard.crestez@xxxxxxx>
> ---

Reviewed-by: Stephen Boyd <sboyd@xxxxxxxxxx>