rosenberg: fix a crashing bug
[smatch.git] / smatch_scripts / gen_unwind_functions.sh
blobae850490201841d2c6de2a40595a63fd7def1039
1 #!/bin/bash
3 file=$1
4 project=$(echo "$2" | cut -d = -f 2)
6 if [[ "$file" = "" ]] ; then
7 echo "Usage: $0 <file with smatch messages> -p=<project>"
8 exit 1
9 fi
11 if [[ "$project" != "kernel" ]] ; then
12 exit 0
15 outfile="kernel.unwind_functions"
16 bin_dir=$(dirname $0)
17 remove=$(echo ${bin_dir}/../smatch_data/${outfile}.remove)
18 tmp=$(mktemp /tmp/smatch.XXXX)
19 tmp2=$(mktemp /tmp/smatch.XXXX)
21 echo "// list of unwind functions." > $outfile
22 echo '// generated by `gen_unwind_functions.sh`' >> $outfile
23 grep "is unwind function" $file | cut -d ' ' -f 2 | cut -d '(' -f 1 >> $tmp
24 cat $tmp | sort -u > $tmp2
25 mv $tmp2 $tmp
26 cat $tmp $remove $remove 2> /dev/null | sort | uniq -u >> $outfile
27 rm $tmp
28 echo "Done. List saved as '$outfile'"