Skip to content

Commit

Permalink
scripts/gdb: fix lx-device-list-bus and lx-device-list-class
Browse files Browse the repository at this point in the history
After the conversion to bus_to_subsys() and class_to_subsys(), the gdb
scripts listing the system buses and classes respectively was broken, fix
those by returning the subsys_priv pointer and have the various caller
de-reference either the 'bus' or 'class' structure members accordingly.

Link: https://lkml.kernel.org/r/[email protected]
Fixes: 7b884b7 ("driver core: class.c: convert to only use class_to_subsys")
Signed-off-by: Florian Fainelli <[email protected]>
Tested-by: Kuan-Ying Lee <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Jan Kiszka <[email protected]>
Cc: Kieran Bingham <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
ffainelli authored and akpm00 committed Dec 7, 2023
1 parent bc220fe commit 801a2b1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions scripts/gdb/linux/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@ def for_each_bus():
for kobj in kset_for_each_object(gdb.parse_and_eval('bus_kset')):
subsys = container_of(kobj, kset_type.get_type().pointer(), 'kobj')
subsys_priv = container_of(subsys, subsys_private_type.get_type().pointer(), 'subsys')
yield subsys_priv['bus']
yield subsys_priv


def for_each_class():
for kobj in kset_for_each_object(gdb.parse_and_eval('class_kset')):
subsys = container_of(kobj, kset_type.get_type().pointer(), 'kobj')
subsys_priv = container_of(subsys, subsys_private_type.get_type().pointer(), 'subsys')
yield subsys_priv['class']
yield subsys_priv


def get_bus_by_name(name):
for item in for_each_bus():
if item['name'].string() == name:
if item['bus']['name'].string() == name:
return item
raise gdb.GdbError("Can't find bus type {!r}".format(name))


def get_class_by_name(name):
for item in for_each_class():
if item['name'].string() == name:
if item['class']['name'].string() == name:
return item
raise gdb.GdbError("Can't find device class {!r}".format(name))

Expand All @@ -70,13 +70,13 @@ def klist_for_each(klist):


def bus_for_each_device(bus):
for kn in klist_for_each(bus['p']['klist_devices']):
for kn in klist_for_each(bus['klist_devices']):
dp = container_of(kn, device_private_type.get_type().pointer(), 'knode_bus')
yield dp['device']


def class_for_each_device(cls):
for kn in klist_for_each(cls['p']['klist_devices']):
for kn in klist_for_each(cls['klist_devices']):
dp = container_of(kn, device_private_type.get_type().pointer(), 'knode_class')
yield dp['device']

Expand All @@ -103,7 +103,7 @@ def __init__(self):
def invoke(self, arg, from_tty):
if not arg:
for bus in for_each_bus():
gdb.write('bus {}:\t{}\n'.format(bus['name'].string(), bus))
gdb.write('bus {}:\t{}\n'.format(bus['bus']['name'].string(), bus))
for dev in bus_for_each_device(bus):
_show_device(dev, level=1)
else:
Expand All @@ -123,7 +123,7 @@ def __init__(self):
def invoke(self, arg, from_tty):
if not arg:
for cls in for_each_class():
gdb.write("class {}:\t{}\n".format(cls['name'].string(), cls))
gdb.write("class {}:\t{}\n".format(cls['class']['name'].string(), cls))
for dev in class_for_each_device(cls):
_show_device(dev, level=1)
else:
Expand Down

0 comments on commit 801a2b1

Please sign in to comment.