public inbox for linux-next@vger.kernel.org 
 help / color / mirror / Atom feed
From: Koichiro Den <koichiro.den@canonical•com>
To: linux-next@vger•kernel.org
Cc: jan.kiszka@siemens•com, kbingham@kernel•org,
	linux-kernel@vger•kernel.org
Subject: [PATCH] scripts/gdb/symbols: follow up on refactoring for const struct bin_attribute
Date: Sun, 12 Jan 2025 21:21:49 +0900	[thread overview]
Message-ID: <20250112122149.9939-1-koichiro.den@canonical.com> (raw)

The work for 'const struct bin_attribute' [1] was merged into linux-next
but did not include updates to the lx-symbols code. So it now fails with
the following error:
Python Exception <class 'gdb.error'>: There is no member named nsections.
Error occurred in Python: There is no member named nsections.

Restore its functionality by aligning it with those changes on
kernel/module/sysfs.c.

[1] https://lore.kernel.org/all/20241227-sysfs-const-bin_attr-module-v2-0-e267275f0f37@weissschuh.net/

Signed-off-by: Koichiro Den <koichiro.den@canonical•com>
---
 scripts/gdb/linux/symbols.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
index f6c1b063775a..8efefd30df49 100644
--- a/scripts/gdb/linux/symbols.py
+++ b/scripts/gdb/linux/symbols.py
@@ -89,16 +89,26 @@ lx-symbols command."""
                 return name
         return None
 
+    def _iter_bin_attrs(self, bin_attrs):
+        while True:
+            try:
+                bin_attr = bin_attrs.dereference()
+            except gdb.MemoryError:
+                break
+            if bin_attr == 0:
+                break
+            yield bin_attr
+            bin_attrs += 1
+
     def _section_arguments(self, module, module_addr):
         try:
             sect_attrs = module['sect_attrs'].dereference()
         except gdb.error:
             return str(module_addr)
 
-        attrs = sect_attrs['attrs']
         section_name_to_address = {
-            attrs[n]['battr']['attr']['name'].string(): attrs[n]['address']
-            for n in range(int(sect_attrs['nsections']))}
+            bin_attr['attr']['name'].string(): bin_attr['private']
+            for bin_attr in self._iter_bin_attrs(sect_attrs['grp']['bin_attrs'])}
 
         textaddr = section_name_to_address.get(".text", module_addr)
         args = []
-- 
2.45.2


             reply	other threads:[~2025-01-12 12:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-12 12:21 Koichiro Den [this message]
2025-02-13  4:38 ` [PATCH] scripts/gdb/symbols: follow up on refactoring for const struct bin_attribute Mohamed Khalfella
2025-02-27  0:17   ` Mohamed Khalfella
2025-02-27  0:59     ` Koichiro Den
2025-02-27  1:05       ` Mohamed Khalfella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250112122149.9939-1-koichiro.den@canonical.com \
    --to=koichiro.den@canonical$(echo .)com \
    --cc=jan.kiszka@siemens$(echo .)com \
    --cc=kbingham@kernel$(echo .)org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-next@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox