Skip to content

Commit 78eb0c6

Browse files
Changbin Dutorvalds
authored andcommitted
scripts/faddr2line: fix error when addr2line output contains discriminator
When addr2line output contains discriminator, the current awk script cannot parse it. This patch fixes it by extracting key words using regex which is more reliable. $ scripts/faddr2line vmlinux tlb_flush_mmu_free+0x26 tlb_flush_mmu_free+0x26/0x50: tlb_flush_mmu_free at mm/memory.c:258 (discriminator 3) scripts/faddr2line: eval: line 173: unexpected EOF while looking for matching `)' Link: http://lkml.kernel.org/r/[email protected] Fixes: 6870c01 ("scripts/faddr2line: show the code context") Signed-off-by: Changbin Du <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Philippe Ombredanne <[email protected]> Cc: NeilBrown <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Kate Stewart <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent e438302 commit 78eb0c6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

scripts/faddr2line

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ __faddr2line() {
170170
echo "$file_lines" | while read -r line
171171
do
172172
echo $line
173-
eval $(echo $line | awk -F "[ :]" '{printf("n1=%d;n2=%d;f=%s",$NF-5, $NF+5, $(NF-1))}')
173+
n=$(echo $line | sed 's/.*:\([0-9]\+\).*/\1/g')
174+
n1=$[$n-5]
175+
n2=$[$n+5]
176+
f=$(echo $line | sed 's/.*at \(.\+\):.*/\1/g')
174177
awk 'NR>=strtonum("'$n1'") && NR<=strtonum("'$n2'") {printf("%d\t%s\n", NR, $0)}' $f
175178
done
176179

0 commit comments

Comments
 (0)