Skip to contentSkip to conversation

scripts/decode_stacktrace: Accept dash/underscore in modules

PATCH In review Evan Green 3 participants 3 messages May 31, 2019 – Jun 3, 2019

lore
Share & tools
lore

Evan Green

author
#0 lore raw

PATCH 1/1 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.

---

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(-)
scripts/decode_stacktrace.sh +1 -1
index fa704f17275e..13e5fbafdf2f 100755
@@ -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
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 28 lines · Evan Green

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.

---

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(-)
scripts/decode_stacktrace.sh +0 -0
index fa704f17275e..13e5fbafdf2f 100755

scripts/decode_stacktrace.sh parse_symbol() { · line 34

Quoted 8 lines
scripts/decode_stacktrace.sh +1 -1
@@ -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
Acked-by on v1 1/1
#2 lore raw
In reply to Evan Green
Quoted 6 lines · Evan Green

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.

Quoted 6 lines

For example, this line:

[   27.919759]  hda_widget_sysfs_init+0x2b8/0x3a5 [snd_hda_core]

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

Quoted 24 lines

---

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(-)
scripts/decode_stacktrace.sh +1 -1
index fa704f17275e..13e5fbafdf2f 100755
@@ -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