File: add-debug-flag

package info (click to toggle)
pcp 6.3.8-1
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 235,180 kB
  • sloc: ansic: 1,253,622; sh: 173,998; xml: 160,490; cpp: 83,331; python: 20,482; perl: 18,302; yacc: 6,886; makefile: 2,955; lex: 2,862; fortran: 60; java: 52
file content (128 lines) | stat: -rwxr-xr-x 2,360 bytes parent folder | download
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
#!/bin/sh
#
# Add a new debug flag
#

tmp=/var/tmp/add-debug-option-$$
trap "rm -f $tmp.*; exit 0" 0 1 2 3 15

name=$1
shift
desc="`echo $*`"
if [ -z "$name" -o -z "$desc" ]
then
    echo "Usage: add-debug-flag flag-name flag description ..."
    exit 1
fi

basedir=`pwd`
while true
do
    if [ -d $basedir/.git ]
    then
	break
    fi
    basedir=`echo "$basedir" | sed -e 's@/[^/]*$@@'`
    if [ -z "$basedir" ]
    then
	echo "Error: can't find base of PCP git tree from `pwd`"
	exit 1
    fi
done

#debug# echo "basedir=$basedir"
# pick this block:
# typedef struct {
# ...
# } pmdebugoptions_t;
# from pmapi.h
sed -n  <$basedir/src/include/pcp/pmapi.h >$tmp.struct  \
    -e "`awk <$basedir/src/include/pcp/pmapi.h '
/^typedef struct/	{ s = NR; next }
/^} pmdebugoptions_t;/	{ print s "," NR "p"; exit }'`"

if grep "int[ 	]*$name;" $tmp.struct
then
    echo "Error: $name already defined pmdebugoptions_t in pmapi.h"
    exit 1
fi

awk <$basedir/src/include/pcp/pmapi.h >$tmp.tmp '
/^} pmdebugoptions_t;/	{ print "    int	'"$name"';		/* '"$desc"' */" }
			{ print }'
#debug# diff -u $basedir/src/include/pcp/pmapi.h $tmp.tmp
mv $tmp.tmp $basedir/src/include/pcp/pmapi.h

echo "libpcp ..."
cd $basedir/src/libpcp/src
if make >$tmp.out 2>&1
then
    :
else
    tail -20 $tmp.out
    echo "Arrgh! libpcp make failed"
    exit 1
fi
sudo make install

echo "pmdbg ..."
cd ../../pmdbg
make clean >/dev/null 2>&1
if make >$tmp.out 2>&1
then
    :
else
    tail -20 $tmp.out
    echo "Arrgh! pmdbg make failed"
    exit 1
fi
if ./pmdbg -l | grep -q "^$name  *$desc$" 
then
    :
else
    echo "Error: error not found on pmdbg -l output"
    exit 1
fi
sudo make install

echo "dbpmda ..."
cd ../dbpmda/src
make clean >/dev/null 2>&1
if make >$tmp.out 2>&1
then
    :
else
    tail -20 $tmp.out
    echo "Arrgh! dbpma make failed"
    exit 1
fi
cat <<End-of-File >$tmp.in
debug none
debug $name
status
debug pdu -$name
status
End-of-File
if ./dbpmda <$tmp.in >$tmp.out 2>&1
then
    if sed -e 's/$/ /' <$tmp.out | grep -q " $name "
    then
	:
    else
	echo "Arrgh! $name not found in pmdbg status output"
	exit 1
    fi
    if grep 'Error:' <$tmp.out
    then
	echo "Arrgh! Errors with debug -$name"
	exit 1
    fi
else
    echo "Error: dbpmda failed"
    exit 1
fi
sudo make install

echo "qa ... expect some .out changes here"
cd ../../../qa
./check -g pmdbg