From: Jan Kiszka <jan.kiszka@siemens.com>
To: Antonio Quartulli <antonio@mandelbit.com>, kbingham@kernel.org
Cc: linux-kernel@vger.kernel.org, "Thomas Weißschuh" <linux@weissschuh.net>
Subject: Re: [PATCH] scripts/gdb/linux/symbols.py: address changes to module_sect_attrs
Date: Fri, 21 Feb 2025 17:52:37 +0100 [thread overview]
Message-ID: <7d00d9cb-6860-446c-9eb2-a908c9f7b15c@siemens.com> (raw)
In-Reply-To: <20250221130304.5882-1-antonio@mandelbit.com>
On 21.02.25 14:03, Antonio Quartulli wrote:
> When loading symbols from kernel modules we used to iterate
> from 0 to module_sect_attrs::nsections, in order to
> retrieve their name and address.
>
> However module_sect_attrs::nsections has been removed from
> the struct by a previous commit.
>
> Re-arrange the iteration by accessing all items in
> module_sect_attrs::grp::bin_attrs[] until NULL is found
> (it's a NULL terminated array).
>
> At the same time the symbol address cannot be extracted
> from module_sect_attrs::attrs[]::address anymore because
> it has also been deleted. Fetch it from
> module_sect_attrs::grp::bin_attrs[]::private as described
> in 4b2c11e4aaf7.
>
> Fixes: d8959b947a8d ("module: sysfs: Drop member 'module_sect_attrs::nsections'")
> Fixes: 4b2c11e4aaf7 ("module: sysfs: Drop member 'module_sect_attr::address'")
> Cc: Thomas Weißschuh <linux@weissschuh.net>
> Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
> ---
> scripts/gdb/linux/symbols.py | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
> index f6c1b063775a..610a3dd3c7b4 100644
> --- a/scripts/gdb/linux/symbols.py
> +++ b/scripts/gdb/linux/symbols.py
> @@ -15,6 +15,7 @@ import gdb
> import os
> import re
>
> +from itertools import count
> from linux import modules, utils, constants
>
>
> @@ -95,10 +96,14 @@ lx-symbols command."""
> 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']))}
> + section_name_to_address = {}
> + for i in count():
> + # this is a NULL terminated array
> + if sect_attrs['grp']['bin_attrs'][i] == 0x0:
> + break
> +
> + attr = sect_attrs['grp']['bin_attrs'][i].dereference()
> + section_name_to_address[attr['attr']['name']] = attr['private']
You dropped that .string() from the name - I don't remember the details
anymore but we have it all around when picking up strings from C
structures. Was there a particular reason to do that?
>
> textaddr = section_name_to_address.get(".text", module_addr)
> args = []
Thanks for picking up this task so quickly!
Jan
--
Siemens AG, Foundational Technologies
Linux Expert Center
next prev parent reply other threads:[~2025-02-21 16:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 15:21 scripts_gdb: Python Exception <class 'gdb.error'>: There is no member named nsections Antonio Quartulli
2025-02-21 6:45 ` Jan Kiszka
2025-02-21 13:03 ` [PATCH] scripts/gdb/linux/symbols.py: address changes to module_sect_attrs Antonio Quartulli
2025-02-21 16:52 ` Jan Kiszka [this message]
2025-02-21 20:33 ` Antonio Quartulli
2025-02-21 20:40 ` [PATCH v2] " Antonio Quartulli
2025-02-26 5:31 ` Jan Kiszka
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=7d00d9cb-6860-446c-9eb2-a908c9f7b15c@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=antonio@mandelbit.com \
--cc=kbingham@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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
all inboxes | Powered by JetHome®