|
6 | 6 |
|
7 | 7 | grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue |
8 | 8 |
|
9 | | -echo 'p:testprobe _do_fork $stack0:s32 $stack0:u32 $stack0:x32 $stack0:b8@4/32' > kprobe_events |
10 | | -grep testprobe kprobe_events |
11 | | -test -d events/kprobes/testprobe |
12 | | - |
13 | | -echo 1 > events/kprobes/testprobe/enable |
14 | | -( echo "forked") |
15 | | -echo 0 > events/kprobes/testprobe/enable |
16 | | -ARGS=`tail -n 1 trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'` |
| 9 | +gen_event() { # Bitsize |
| 10 | + echo "p:testprobe _do_fork \$stack0:s$1 \$stack0:u$1 \$stack0:x$1 \$stack0:b4@4/$1" |
| 11 | +} |
17 | 12 |
|
18 | | -check_types() { |
19 | | - X1=`printf "%x" $1 | tail -c 8` |
| 13 | +check_types() { # s-type u-type x-type bf-type width |
| 14 | + test $# -eq 5 |
| 15 | + CW=$5 |
| 16 | + CW=$((CW / 4)) |
| 17 | + X1=`printf "%x" $1 | tail -c ${CW}` |
20 | 18 | X2=`printf "%x" $2` |
21 | 19 | X3=`printf "%x" $3` |
22 | 20 | test $X1 = $X2 |
23 | 21 | test $X2 = $X3 |
24 | 22 | test 0x$X3 = $3 |
25 | 23 |
|
26 | | - B4=`printf "%02x" $4` |
27 | | - B3=`echo -n $X3 | tail -c 3 | head -c 2` |
| 24 | + B4=`printf "%1x" $4` |
| 25 | + B3=`printf "%03x" 0x$X3 | tail -c 2 | head -c 1` |
28 | 26 | test $B3 = $B4 |
29 | 27 | } |
30 | | -check_types $ARGS |
31 | 28 |
|
32 | | -echo "-:testprobe" >> kprobe_events |
33 | | -clear_trace |
34 | | -test -d events/kprobes/testprobe && exit_fail || exit_pass |
| 29 | +for width in 64 32 16 8; do |
| 30 | + : "Add new event with basic types" |
| 31 | + gen_event $width > kprobe_events |
| 32 | + grep testprobe kprobe_events |
| 33 | + test -d events/kprobes/testprobe |
| 34 | + |
| 35 | + : "Trace the event" |
| 36 | + echo 1 > events/kprobes/testprobe/enable |
| 37 | + ( echo "forked") |
| 38 | + echo 0 > events/kprobes/testprobe/enable |
| 39 | + |
| 40 | + : "Confirm the arguments is recorded in given types correctly" |
| 41 | + ARGS=`grep "testprobe" trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'` |
| 42 | + check_types $ARGS $width |
| 43 | + |
| 44 | + : "Clear event for next loop" |
| 45 | + echo "-:testprobe" >> kprobe_events |
| 46 | + clear_trace |
| 47 | + |
| 48 | +done |
| 49 | + |
| 50 | +exit_pass |
0 commit comments