scripts/gdb: Fix lx-device-list-bus and lx-device-list-class
PATCH 1/1 scripts/gdb: Fix lx-device-list-bus and lx-device-list-class
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.
--- scripts/gdb/linux/device.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
scripts/gdb/linux/device.py +8 -8
@@ -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))
@@ -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']
@@ -103,7 +103,7 @@ class LxDeviceListBus(gdb.Command): 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:
@@ -123,7 +123,7 @@ class LxDeviceListClass(gdb.Command): 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:
Signature · 1 line
2.34.1
Quoted 8 lines · On Wed, 29 Nov 2023 20:33:16 -0800 Florian Fainelli…
After the conversion to
bus_to_subsys()andclass_to_subsys(), the gdb scripts listing the system buses and classes respectively was broken, fix those by returning thesubsys_privpointer and have the various caller de-reference either the 'bus' or 'class' structure members accordingly.Fixes 83b9148df2c9 ("driver core: bus: bus iterator cleanups")Fixes 7b884b7f24b4 ("driver core: class.c: convert to only use class_to_subsys")
I don't know how -stable maintainers handle more than one Fixes:. One of the above was released in 6.3, the other in 6.4. What are they to do?
My opinion: developers should use Fixes: as a request to -stable maintainers to target a particular kernel version (and later).
If the developers indeed want to fix both kernel versions then wouldn't two patches be best?
Quoted 8 lines · Andrew Morton
Quoted 6 lines · On Wed, 29 Nov 2023 20:33:16 -0800 Florian Fainelli…
After the conversion to
bus_to_subsys()andclass_to_subsys(), the gdb scripts listing the system buses and classes respectively was broken, fix those by returning thesubsys_privpointer and have the various caller de-reference either the 'bus' or 'class' structure members accordingly.
Quoted 6 lines
Quoted 2 lines
Fixes 83b9148df2c9 ("driver core: bus: bus iterator cleanups")Fixes 7b884b7f24b4 ("driver core: class.c: convert to only use class_to_subsys")I don't know how -stable maintainers handle more than one Fixes:. One of the above was released in 6.3, the other in 6.4. What are they to do?
Neither are stable kernels fortunately, so any kernel >= 6.4 where both issues are present should be able to cleanly cherry-pick the change.
I suppose this should have called for me to issue two patches, one fixing lx-device-list-bus and the other one fixing lx-device-list-class, though it seems like this is such a niche usage that it may not matter that much.
Quoted 7 lines
My opinion: developers should use Fixes: as a request to -stable maintainers to target a particular kernel version (and later).
If the developers indeed want to fix both kernel versions then wouldn't two patches be best?
They probably would, or I could submit a targeted fix for 6.3 for instance.
Signature · 1 line
Florian
Quoted 9 lines · On Thu, 30 Nov 2023 14:00:32 -0800 Florian Fainelli…
Quoted 6 lines
Quoted 2 lines
Fixes 83b9148df2c9 ("driver core: bus: bus iterator cleanups")Fixes 7b884b7f24b4 ("driver core: class.c: convert to only use class_to_subsys")I don't know how -stable maintainers handle more than one Fixes:. One of the above was released in 6.3, the other in 6.4. What are they to do?
Neither are stable kernels fortunately, so any kernel >= 6.4 where both issues are present should be able to cleanly cherry-pick the change.
OK, I'll change it to just 6.4's 7b884b7f24b4 to simplify life.
Quoted 4 lines
I suppose this should have called for me to issue two patches, one fixing lx-device-list-bus and the other one fixing lx-device-list-class, though it seems like this is such a niche usage that it may not matter that much.
It is indeed nichey :)
Quoted 11 lines · Florian Fainelli
After the conversion to
bus_to_subsys()andclass_to_subsys(), the gdb
scripts listing the system buses and classes respectively was broken, fix those by returning thesubsys_privpointer and have the various caller de-reference either the 'bus' or 'class' structure members accordingly.Fixes 83b9148df2c9 ("driver core: bus: bus iterator cleanups")Fixes 7b884b7f24b4 ("driver core: class.c: convert to only use
class_to_subsys")Signed-off-by Florian Fainelli <[email protected]>
Thanks,
Kuan-Ying Lee
Quoted 86 lines
--- scripts/gdb/linux/device.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)scripts/gdb/linux/device.py +0
-0@@ -36,26 +36,26 @@ def for_each_bus(): for kobj inkset_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')scripts/gdb/linux/device.py +1
-1- yield subsys_priv['bus'] + yield subsys_priv def for_each_class(): for kobj inkset_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')scripts/gdb/linux/device.py +5
-5- 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))@@ -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']
scripts/gdb/linux/device.py +1
-1@@ -103,7 +103,7 @@ class LxDeviceListBus(gdb.Command): 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:scripts/gdb/linux/device.py +1
-1@@ -123,7 +123,7 @@ class LxDeviceListClass(gdb.Command): 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: