2019-05-31 21:01:14

by Evan Green

[permalink] [raw]
Subject: [PATCH] scripts/decode_stacktrace: Accept dash/underscore in modules

The manpage for modprobe mentions that dashes and underscores are
treated interchangeably in module names. The stack trace dumps seem
to print module names with underscores. Use bash to replace _ with
the pattern [-_] so that file names with dashes or underscores can be
found.

For example, this line:
[ 27.919759] hda_widget_sysfs_init+0x2b8/0x3a5 [snd_hda_core]

should find a module named snd-hda-core.ko.

Signed-off-by: Evan Green <[email protected]>
---

Note: This should apply atop linux-next.

Thanks to Doug for showing me the bash string substitution magic.

---
scripts/decode_stacktrace.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
index fa704f17275e..13e5fbafdf2f 100755
--- a/scripts/decode_stacktrace.sh
+++ b/scripts/decode_stacktrace.sh
@@ -28,7 +28,7 @@ parse_symbol() {
local objfile=${modcache[$module]}
else
[[ $modpath == "" ]] && return
- local objfile=$(find "$modpath" -name "$module.ko*" -print -quit)
+ local objfile=$(find "$modpath" -name "${module//_/[-_]}.ko*" -print -quit)
[[ $objfile == "" ]] && return
modcache[$module]=$objfile
fi
--
2.20.1


2019-05-31 21:03:41

by Doug Anderson

[permalink] [raw]
Subject: Re: [PATCH] scripts/decode_stacktrace: Accept dash/underscore in modules

Hi,

On Fri, May 31, 2019 at 1:59 PM Evan Green <[email protected]> wrote:
>
> The manpage for modprobe mentions that dashes and underscores are
> treated interchangeably in module names. The stack trace dumps seem
> to print module names with underscores. Use bash to replace _ with
> the pattern [-_] so that file names with dashes or underscores can be
> found.
>
> For example, this line:
> [ 27.919759] hda_widget_sysfs_init+0x2b8/0x3a5 [snd_hda_core]
>
> should find a module named snd-hda-core.ko.
>
> Signed-off-by: Evan Green <[email protected]>
> ---
>
> Note: This should apply atop linux-next.
>
> Thanks to Doug for showing me the bash string substitution magic.
>
> ---
> scripts/decode_stacktrace.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
> index fa704f17275e..13e5fbafdf2f 100755
> --- a/scripts/decode_stacktrace.sh
> +++ b/scripts/decode_stacktrace.sh
> @@ -28,7 +28,7 @@ parse_symbol() {
> local objfile=${modcache[$module]}
> else
> [[ $modpath == "" ]] && return
> - local objfile=$(find "$modpath" -name "$module.ko*" -print -quit)
> + local objfile=$(find "$modpath" -name "${module//_/[-_]}.ko*" -print -quit)
> [[ $objfile == "" ]] && return
> modcache[$module]=$objfile
> fi

Reviewed-by: Douglas Anderson <[email protected]>

2019-06-03 07:54:10

by Konstantin Khlebnikov

[permalink] [raw]
Subject: Re: [PATCH] scripts/decode_stacktrace: Accept dash/underscore in modules

On 31.05.2019 23:59, Evan Green wrote:
> The manpage for modprobe mentions that dashes and underscores are
> treated interchangeably in module names. The stack trace dumps seem
> to print module names with underscores. Use bash to replace _ with
> the pattern [-_] so that file names with dashes or underscores can be
> found.
>
> For example, this line:
> [ 27.919759] hda_widget_sysfs_init+0x2b8/0x3a5 [snd_hda_core]
>
> should find a module named snd-hda-core.ko.
>
> Signed-off-by: Evan Green <[email protected]>

Acked-by: Konstantin Khlebnikov <[email protected]>

> ---
>
> Note: This should apply atop linux-next.
>
> Thanks to Doug for showing me the bash string substitution magic.
>
> ---
> scripts/decode_stacktrace.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
> index fa704f17275e..13e5fbafdf2f 100755
> --- a/scripts/decode_stacktrace.sh
> +++ b/scripts/decode_stacktrace.sh
> @@ -28,7 +28,7 @@ parse_symbol() {
> local objfile=${modcache[$module]}
> else
> [[ $modpath == "" ]] && return
> - local objfile=$(find "$modpath" -name "$module.ko*" -print -quit)
> + local objfile=$(find "$modpath" -name "${module//_/[-_]}.ko*" -print -quit)
> [[ $objfile == "" ]] && return
> modcache[$module]=$objfile
> fi
>