hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
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
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: Kprobes event arguments with types
 
[ -f kprobe_events ] || exit_unsupported # this is configurable
 
grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue
 
echo 0 > events/enable
echo > kprobe_events
enable_tracing
 
echo 'p:testprobe _do_fork $stack0:s32 $stack0:u32 $stack0:x32 $stack0:b8@4/32' > kprobe_events
grep testprobe kprobe_events
test -d events/kprobes/testprobe
 
echo 1 > events/kprobes/testprobe/enable
( echo "forked")
echo 0 > events/kprobes/testprobe/enable
ARGS=`tail -n 1 trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'`
 
check_types() {
  X1=`printf "%x" $1 | tail -c 8`
  X2=`printf "%x" $2`
  X3=`printf "%x" $3`
  test $X1 = $X2
  test $X2 = $X3
  test 0x$X3 = $3
 
  B4=`printf "%02x" $4`
  B3=`echo -n $X3 | tail -c 3 | head -c 2`
  test $B3 = $B4
}
check_types $ARGS
 
echo "-:testprobe" >> kprobe_events
clear_trace
test -d events/kprobes/testprobe && exit_fail || exit_pass