1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3# description: Generic dynamic event - add/remove tracepoint probe events on module 4# requires: dynamic_events "t[:[<group>/][<event>]] <tracepoint> [<args>]":README 5 6rmmod trace-events-sample ||: 7if ! modprobe trace-events-sample ; then 8 echo "No trace-events sample module - please make CONFIG_SAMPLE_TRACE_EVENTS=m" 9 exit_unresolved; 10fi 11trap "rmmod trace-events-sample" EXIT 12 13echo 0 > events/enable 14echo > dynamic_events 15 16TRACEPOINT1=foo_bar 17TRACEPOINT2=foo_bar_with_cond 18 19echo "t:myevent1 $TRACEPOINT1" >> dynamic_events 20echo "t:myevent2 $TRACEPOINT2" >> dynamic_events 21 22grep -q myevent1 dynamic_events 23grep -q myevent2 dynamic_events 24test -d events/tracepoints/myevent1 25test -d events/tracepoints/myevent2 26 27echo "-:myevent2" >> dynamic_events 28 29grep -q myevent1 dynamic_events 30! grep -q myevent2 dynamic_events 31 32echo > dynamic_events 33 34clear_trace 35 36:;: "Try to put a probe on a tracepoint in non-loaded module" ;: 37rmmod trace-events-sample 38 39echo "t:myevent1 $TRACEPOINT1" >> dynamic_events 40echo "t:myevent2 $TRACEPOINT2" >> dynamic_events 41 42grep -q myevent1 dynamic_events 43grep -q myevent2 dynamic_events 44test -d events/tracepoints/myevent1 45test -d events/tracepoints/myevent2 46 47echo 1 > events/tracepoints/enable 48 49modprobe trace-events-sample 50 51sleep 2 52 53grep -q "myevent1" trace 54grep -q "myevent2" trace 55 56rmmod trace-events-sample 57trap "" EXIT 58 59echo 0 > events/tracepoints/enable 60echo > dynamic_events 61clear_trace 62