Commit 846442c8ddc02e378e7b981f0928449ed1ff1e1f

Authored by Arjan van de Ven
Committed by Sam Ravnborg
1 parent c39dd50240

scripts: improve the decodecode script

kerneloops.org has been using an improved "decodecode" script,
specifically it has a special marker that shows which line in the assembly
the oops happened at, like this:

  20:	83 e0 03             	and    $0x3,%eax
  23:	09 d8                	or     %ebx,%eax
  25:	85 db                	test   %ebx,%ebx
  27:	89 02                	mov    %eax,(%edx)
  29:	74 0f                	je     0x3a
  2b:*	3b 73 04             	cmp    0x4(%ebx),%esi     <-- trapping instruction
  2e:	75 05                	jne    0x35
  30:	89 53 04             	mov    %edx,0x4(%ebx)
  33:	eb 07                	jmp    0x3c
  35:	89 53 08             	mov    %edx,0x8(%ebx)

this patch updates the kernel copy to also have this functionality.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Reviewed-by: WANG Cong <wangcong@zeuux.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

Showing 1 changed file with 22 additions and 10 deletions Side-by-side Diff

... ... @@ -7,7 +7,7 @@
7 7 # AFLAGS=--32 decodecode < 386.oops
8 8  
9 9 cleanup() {
10   - rm -f $T $T.s $T.o
  10 + rm -f $T $T.s $T.o $T.oo $T.aa $T.aaa
11 11 exit 1
12 12 }
13 13  
14 14  
15 15  
16 16  
17 17  
... ... @@ -44,22 +44,34 @@
44 44 marker=`expr index "$code" "\("`
45 45 fi
46 46  
  47 +touch $T.oo
47 48 if [ $marker -ne 0 ]; then
48   - beforemark=`echo "$code" | cut -c-$((${marker} - 1))`
  49 + echo All code >> $T.oo
  50 + echo ======== >> $T.oo
  51 + beforemark=`echo "$code"`
49 52 echo -n " .byte 0x" > $T.s
50   - echo $beforemark | sed -e 's/ /,0x/g' >> $T.s
51   - as $AFLAGS -o $T.o $T.s
52   - objdump -S $T.o
53   - rm $T.o $T.s
  53 + echo $beforemark | sed -e 's/ /,0x/g' | sed -e 's/<//g' | sed -e 's/>//g' >> $T.s
  54 + as $AFLAGS -o $T.o $T.s &> /dev/null
  55 + objdump -S $T.o | grep -v "/tmp" | grep -v "Disassembly" | grep -v "\.text" | grep -v "^$" &> $T.ooo
  56 + cat $T.ooo >> $T.oo
  57 + rm -f $T.o $T.s $T.ooo
54 58  
55 59 # and fix code at-and-after marker
56 60 code=`echo "$code" | cut -c$((${marker} + 1))-`
57 61 fi
58   -
  62 +echo Code starting with the faulting instruction > $T.aa
  63 +echo =========================================== >> $T.aa
59 64 code=`echo $code | sed -e 's/ [<(]/ /;s/[>)] / /;s/ /,0x/g'`
60 65 echo -n " .byte 0x" > $T.s
61 66 echo $code >> $T.s
62   -as $AFLAGS -o $T.o $T.s
63   -objdump -S $T.o
64   -rm $T $T.s $T.o
  67 +as $AFLAGS -o $T.o $T.s &> /dev/null
  68 +objdump -S $T.o | grep -v "Disassembly" | grep -v "/tmp" | grep -v "\.text" | grep -v "^$" &> $T.aaa
  69 +cat $T.aaa >> $T.aa
  70 +
  71 +faultline=`cat $T.aaa | head -1 | cut -d":" -f2`
  72 +
  73 +cat $T.oo | sed -e "s/\($faultline\)/\*\1 <-- trapping instruction/g"
  74 +echo
  75 +cat $T.aa
  76 +cleanup