global switch=-1

#begin probe
probe begin if (switch==-1) {
	printf("begin1 probed: %s\n", module_name());
}

probe begin if (switch==0) {
	log("begin2 probed");
}

#dwarf probe (return)
#
# Note that we were originally probing
# kernel.function("vfs_write").return here. However, on some kernels
# (like 3.10.0-327.el7.ppc64), vfs_write() could be inlined, so we'd
# miss the return. 
probe syscall.write.return if (switch == 1) {
	log("function return probed")
	switch = 0
}

#dwarf probe (entry)
probe syscall.write if (switch == 2) {
	log("function entry probed")
	switch = 0
}

#timer probe
probe timer.ms(100) if (switch == 3) {
	log("timer probed")
	switch = 0
}

#profile probe
probe timer.profile if (switch == 4) {
	log("profile probed")
	switch = 0
}

# aliasess
probe alias.one.a  = timer.ms(150) if (switch == 5) { print("alias.one.a and") }
probe alias.one.b  = timer.ms(200) if (switch == 6) { print("alias.one.b and") }
probe alias.one = alias.one.* if (switch >= 5 && switch < 7) { print(" alias.one and") }
probe alias.two = timer.ms(250) if (switch == 7) { print("alias.two and") }
probe alias.* if (switch) { log(" alias.* probed") }

probe procfs("switch").write {
	switch = strtol($value, 10)
	if (switch > 7) {
		exit()
	}
}