diff options
-rwxr-xr-x | scripts/decodecode | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/scripts/decodecode b/scripts/decodecode index 235d3938529d..4b00647814bc 100755 --- a/scripts/decodecode +++ b/scripts/decodecode | |||
@@ -7,7 +7,7 @@ | |||
7 | # AFLAGS=--32 decodecode < 386.oops | 7 | # AFLAGS=--32 decodecode < 386.oops |
8 | 8 | ||
9 | cleanup() { | 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 | exit 1 | 11 | exit 1 |
12 | } | 12 | } |
13 | 13 | ||
@@ -44,21 +44,33 @@ if [ $marker -eq 0 ]; then | |||
44 | marker=`expr index "$code" "\("` | 44 | marker=`expr index "$code" "\("` |
45 | fi | 45 | fi |
46 | 46 | ||
47 | touch $T.oo | ||
47 | if [ $marker -ne 0 ]; then | 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 | echo -n " .byte 0x" > $T.s | 52 | echo -n " .byte 0x" > $T.s |
50 | echo $beforemark | sed -e 's/ /,0x/g' >> $T.s | 53 | echo $beforemark | sed -e 's/ /,0x/g' | sed -e 's/<//g' | sed -e 's/>//g' >> $T.s |
51 | as $AFLAGS -o $T.o $T.s | 54 | as $AFLAGS -o $T.o $T.s &> /dev/null |
52 | objdump -S $T.o | 55 | objdump -S $T.o | grep -v "/tmp" | grep -v "Disassembly" | grep -v "\.text" | grep -v "^$" &> $T.ooo |
53 | rm $T.o $T.s | 56 | cat $T.ooo >> $T.oo |
57 | rm -f $T.o $T.s $T.ooo | ||
54 | 58 | ||
55 | # and fix code at-and-after marker | 59 | # and fix code at-and-after marker |
56 | code=`echo "$code" | cut -c$((${marker} + 1))-` | 60 | code=`echo "$code" | cut -c$((${marker} + 1))-` |
57 | fi | 61 | fi |
58 | 62 | echo Code starting with the faulting instruction > $T.aa | |
63 | echo =========================================== >> $T.aa | ||
59 | code=`echo $code | sed -e 's/ [<(]/ /;s/[>)] / /;s/ /,0x/g'` | 64 | code=`echo $code | sed -e 's/ [<(]/ /;s/[>)] / /;s/ /,0x/g'` |
60 | echo -n " .byte 0x" > $T.s | 65 | echo -n " .byte 0x" > $T.s |
61 | echo $code >> $T.s | 66 | echo $code >> $T.s |
62 | as $AFLAGS -o $T.o $T.s | 67 | as $AFLAGS -o $T.o $T.s &> /dev/null |
63 | objdump -S $T.o | 68 | objdump -S $T.o | grep -v "Disassembly" | grep -v "/tmp" | grep -v "\.text" | grep -v "^$" &> $T.aaa |
64 | rm $T $T.s $T.o | 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 | ||