1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3# description: Kprobe event string type argument 4 5[ -f kprobe_events ] || exit_unsupported # this is configurable 6 7echo 0 > events/enable 8echo > kprobe_events 9 10case `uname -m` in 11x86_64) 12 ARG2=%si 13 OFFS=8 14;; 15i[3456]86) 16 ARG2=%cx 17 OFFS=4 18;; 19aarch64) 20 ARG2=%x1 21 OFFS=8 22;; 23arm*) 24 ARG2=%r1 25 OFFS=4 26;; 27ppc64*) 28 ARG2=%r4 29 OFFS=8 30;; 31ppc*) 32 ARG2=%r4 33 OFFS=4 34;; 35*) 36 echo "Please implement other architecture here" 37 exit_untested 38esac 39 40: "Test get argument (1)" 41echo "p:testprobe create_trace_kprobe arg1=+0(+0(${ARG2})):string" > kprobe_events 42echo 1 > events/kprobes/testprobe/enable 43! echo test >> kprobe_events 44tail -n 1 trace | grep -qe "testprobe.* arg1=\"test\"" 45 46echo 0 > events/kprobes/testprobe/enable 47: "Test get argument (2)" 48echo "p:testprobe create_trace_kprobe arg1=+0(+0(${ARG2})):string arg2=+0(+${OFFS}(${ARG2})):string" > kprobe_events 49echo 1 > events/kprobes/testprobe/enable 50! echo test1 test2 >> kprobe_events 51tail -n 1 trace | grep -qe "testprobe.* arg1=\"test1\" arg2=\"test2\"" 52 53echo 0 > events/enable 54echo > kprobe_events 55