--- /dev/null
+set test_name "process_by_pid"
+
+if {! [installtest_p]} {
+ untested $test_name
+ return
+}
+
+# building the test program
+set compile_result [target_compile $srcdir/$subdir/$test_name.c ./$test_name executable "additional_flags=-g [sdt_includes]"]
+
+proc sleep_twenty_secs {} {
+ wait_n_secs 20;
+ return 0;
+}
+
+# expected output
+set output_string "pass"
+
+# running multiple instances of the test program
+# the idea behind this is that in the stap script, it will check the pid it is
+# probing against the one that we told it to probe. if all goes well, then we
+# know that process(PID).* probes will probe processes based on their PID and
+# not the program it is runnning.
+set pid1 [exec ./$test_name &]
+set pid2 [exec ./$test_name &]
+set pid3 [exec ./$test_name &]
+
+# running the script
+foreach runtime [get_runtime_list] {
+ verbose -log "starting the stap script"
+ if {$runtime != ""} {
+ set cur_test_name "$test_name ($runtime)"
+ stap_run $cur_test_name sleep_twenty_secs $output_string --runtime=$runtime $srcdir/$subdir/$test_name.stp $pid2
+ } elseif {[uprobes_p]} {
+ stap_run $test_name sleep_twenty_secs $output_string $srcdir/$subdir/$test_name.stp $pid2
+ } else {
+ untested $test_name
+ continue
+ }
+}
+
+# kill all the instances of the test program.
+kill -INT $pid1 2
+kill -INT $pid2 2
+kill -INT $pid3 2
+
+# remove the executable
+exec rm -f ./$test_name
--- /dev/null
+global probed
+
+probe begin {
+ probed["function"] = 0;
+ probed["statement"] = 0;
+ probed["plt"] = 0;
+ probed["provider"] = 0;
+ probed["mark"] = 0;
+ printf("systemtap starting probe\n");
+}
+
+probe process($1).function("*") {
+ if ($1 != pid()) {
+ error("failed in process(PID).function(\"*\")");
+ } else if (!probed["function"]){
+ probed["function"] ++;
+ }
+}
+
+probe process($1).function("main").label("marker_here") ? {
+ if ($1 != pid())
+ error("failed in process(PID).function(main).label(marker_here)");
+ // gcc may not provide enough information to for stap to see this point, hence
+ // why it's optional. since it's optional, don't keep track of whether it's
+ // been seen.
+}
+
+probe process($1).statement("*") {
+ if ($1 != pid()) {
+ error("failed in process(PID).statement\"*\")");
+ } else if (!probed["statement"]){
+ probed["statement"]++;
+ }
+}
+
+probe process($1).plt {
+ if ($1 != pid()) {
+ error("failed in process(PID).plt");
+ } else if (!probed["plt"]){
+ probed["plt"] ++;
+ }
+}
+
+probe process($1).provider("*").mark("*") {
+ if ($1 != pid()) {
+ error("failed in process(PID).provider(\"*\").mark(\"*\")");
+ } else if (!probed["provider"]){
+ probed["provider"] ++;
+ }
+}
+
+probe process($1).mark("*") {
+ if ($1 != pid()) {
+ error("failed in process(PID).mark(\"*\")");
+ } else if (!probed["mark"]){
+ probed["mark"] ++;
+ }
+}
+
+probe end {
+ printf("systemtap ending probe\n");
+ if (probed["function"] > 0 && probed["plt"] > 0 && probed["mark"] > 0
+ && probed["statement"] > 0 && probed["provider"] > 0)
+ printf("pass\n");
+ else
+ printf("fail: did not hit all probe points successfully.\n");
+}