]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
scripts/decodecode: make it take multiline Code line
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 1 Feb 2018 00:14:10 +0000 (16:14 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 1 Feb 2018 01:18:34 +0000 (17:18 -0800)
In case of running scripts/decodecode without any parameters in order to
give a copy'n'pasted Code line from, for example, email it would parse
only first line of it, while in emails it's split to few.

ie, when you have a file out of oops the Code line looks like

  Code: hh hh ... <hh> ... hh\n

When copy'n'paste from, for example, email where sender or some middle
MTA split it, the line looks like:

  Code: hh hh ... hh\n
  hh ... <hh> ... hh\n
  hh hh ... hh\n

The Code line followed by another oops line usually contains characters
out of hex digit + space + < + > set.

So add logic to join this split back if and only if the following lines
have hex digits, or spaces, or '<', or '>' characters.  It will be quite
unlikely to have a broken input in well formed Oops or dmesg, thus a
simple regex is being used.

Link: http://lkml.kernel.org/r/20171212100323.33201-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Dave Martin <Dave.Martin@arm.com>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/decodecode

index 5ea07109933043888b802c9252205c7da3b7705c..9cef558528aac890dfc2d2545aa9eb2fd8be3934 100755 (executable)
@@ -21,12 +21,24 @@ trap cleanup EXIT
 
 T=`mktemp` || die "cannot create temp file"
 code=
+cont=
 
 while read i ; do
 
 case "$i" in
 *Code:*)
        code=$i
+       cont=yes
+       ;;
+*)
+       [ -n "$cont" ] && {
+               xdump="$(echo $i | grep '^[[:xdigit:]<>[:space:]]\+$')"
+               if [ -n "$xdump" ]; then
+                       code="$code $xdump"
+               else
+                       cont=
+               fi
+       }
        ;;
 esac