summaryrefslogtreecommitdiffstats
path: root/rtems/gen_warnings_report
blob: 9c456bcba371439668ea96c6148f4067ab9e9f3a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#! /bin/sh
#
# Generate a summary report

if [ $# -eq 0 ] ; then
  echo "Takes at least one argument (usually a date)"
  exit 1
fi

handle=$1
include_net="yes"

#    -e '/warning: .rtems_clock_get. is deprecated/d'
#    -e '/warning: .rtems_task_get_note. is deprecated/d'
#    -e '/warning: .rtems_task_set_note. is deprecated/d'
#    -e '/warning: .notepad. is deprecated/d'
#    -e '/warning: .Notepads. is deprecated/d'
#    -e '/warning: .rtems_task_variable_add. is deprecated/d'
#    -e '/warning: .rtems_task_variable_dtor. is deprecated/d'
#    -e '/warning: .rtems_task_variable_get. is deprecated/d'
#    -e '/warning: ._RTEMS_Tasks_Invoke_task_variable_dtor. is deprecated/d'

#    -e '/hexdump-conv.c:149:/d' 
#    -e '/rtl-mdreloc-mips.c:/d' 

filter_net_warnings()
{
  if [ ${include_net} = "no" ] ; then
    sed \
      -e '/cpukit\/libnetworking.*warning: /d' \
      -e '/cpukit\/librpc.*warning: /d' \
      -e '/cpukit\/telnetd.*warning: /d' \
      -e '/cpukit\/pppd.*warning: /d' \
      -e '/cpukit\/libfs\/src\/nfs.*warning: /d' \
      -e '/libchip\/network.*warning: /d' \
      -e '/erc32\/erc32sonicn.*warning: /d' \
      -e '/warning .implement a proper /d'
   else
     cat
   fi
}

filter_warnings()
{
  # libtests/math/domath.h FP printf() warning with gcc 4.8.x not >= 4.9
  #    -e '/testsuites/libtests/math/domath.h:/d'
  #    -e '/testsuites/libtests/complex/docomplex.h:/d'
  # known: m68k _CPU_Context_Restart_self restoring FPU context not implemented
  # known: sparc/sparcv8-atomic.c:111:
  # known: cc1plus command line options not valid for C
  # known: notepads deprecated in confdefs.h
  # known: task variables deprecated in confdefs.h
  # known: Clock skew detected (issue in distributed builds)
  
  # what was this pattern for?
  #  -e 's/^log.*\.\.\/rtems\///'

  grep warning $* | sed \
    -e '/Makefile:/d' \
    -e '/libtests\/math\/domath.h/d' \
    -e '/libtests\/complex\/docomplex.h/d' \
    -e '/_CPU_Context_Restart_self restoring FPU context not implemented/d' \
    -e '/sparc\/sparcv8-atomic.c:111:/d' \
    -e '/cc1plus: warning: command line option.* is valid for C\/ObjC/d' \
    -e '/Classic API Notepads are deprecated and will be removed/d' \
    -e '/Per-Task Variables are deprecated and will be removed/d' \
    -e '/is deprecated (declared at /d' \
    -e '/warning:  Clock skew detected./d' \
    -e '/log\/avr-/d' \
    -e '/log\/h8300-/d' \
    -e '/log\/m32c-/d' \
   | filter_net_warnings
}

summary()
{
  echo "Unique Warnings         : " ${unique}
  echo "BSPs                    : " ${bsps}
  echo "BSPs with Zero          : " ${no_warnings}
  echo "BSPs with only in shared: " ${shared_only}

  echo
  echo "===================================="
  echo "         Warnings by Class"
  echo "===================================="
  cat ${wdir}/warnings-by-class-${handle}.txt

  echo
  echo "===================================="
  echo "     Top Ten BSPs with Warnings"
  echo "===================================="

  cat ${wdir}/warnings-per-bsp-${handle}.txt | \
    grep -v "shared" | sort -n -k 2 -t '=' | tail -10
}

warnings_per_bsp()
{
  for i in $*
  do
    BSP=`echo $i | sed -e "s/^....//" -e "s/....$//"`

    count=`filter_warnings ${i} | sed -e 's/^log.*\.\.\/rtems\///' | wc -l`
    in_bsp=`filter_warnings ${i} | grep /libbsp/ | wc -l`
    in_libcpu=`filter_warnings ${i} | grep /libcpu/ | wc -l`
    #in_tests=`filter_warnings ${i} | grep /testsuites/ | wc -l`

    # where="(inBSP=${in_bsp} inLibCPU=${in_libcpu} inTests=${in_tests})"
    where="(inBSP=${in_bsp} inLibCPU=${in_libcpu})"
    if [ ${in_bsp} -eq 0 -a ${in_libcpu} -eq 0 ] ; then
      if [ ${count} -eq 0 ] ; then
        where="(none)"
      else
        where="(only shared)"
      fi
    fi

    echo ${count} ${BSP} " ${where}"

  done | sort -n
}

if [ -r $1 ] ; then
  filter_warnings $*
  exit 0
fi

wdir=warnings/warnings-${handle}
if [ ! -d warnings ] ; then
  echo "warnings top directory does not exist"
  exit 1
fi

if [ -d ${wdir} ] ; then
  echo "${wdir} directory DOES exist."
  echo "Remove it or pick another directory."
  exit 1
fi

mkdir ${wdir}

# -l and -v do not appear to work togheter. :(
#logs=`grep -l -v ^ERROR log/*`

logs=""
for f in log/*
do
  grep ^ERROR ${f} >/dev/null
  if [ $? -ne 0 ] ; then
    logs="${logs} ${f}"
  fi
done


filter_warnings ${logs} >${wdir}/warnings-all-${handle}.txt

filter_warnings ${logs} | cut -d':' -f2- | sort | uniq -c | \
    sort -n -r >${wdir}/warnings-${handle}.txt


warnings_per_bsp ${logs} >${wdir}/warnings-per-bsp-${handle}.txt

grep "\[-W" ${wdir}/warnings-${handle}.txt | \
  sed -e 's/^.*\[-W//' -e 's/\]//' | sort  | \
  uniq -c >${wdir}/warnings-by-class-${handle}.txt

bsps=`cat ${wdir}/warnings-per-bsp-${handle}.txt | wc -l`
unique=`cat ${wdir}/warnings-${handle}.txt | wc -l`
shared_only=`grep shared ${wdir}/warnings-per-bsp-${handle}.txt | wc -l`
no_warnings=`grep none ${wdir}/warnings-per-bsp-${handle}.txt | wc -l`

summary >${wdir}/warnings-summary-${handle}.txt
cat ${wdir}/warnings-summary-${handle}.txt

exit 0