-
-
Save agentzh/afb0ac6a532f982ae503e6986d358143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/runtime/linux/task_finder.c b/runtime/linux/task_finder.c | |
index 1358e36c2..62a872624 100644 | |
--- a/runtime/linux/task_finder.c | |
+++ b/runtime/linux/task_finder.c | |
@@ -1412,11 +1412,10 @@ __stp_utrace_task_finder_target_quiesce(enum utrace_resume_action action, | |
_stp_error("utrace_set_events returned error %d on pid %d", | |
rc, (int)tsk->pid); | |
+ /* NB make sure we run mmap callbacks before other callbacks | |
+ * like 'probe process.begin' handlers so that the vma tracker | |
+ * is already initialized in the latter contexts */ | |
- /* Call the callbacks. Assume that if the thread is a | |
- * thread group leader, it is a process. */ | |
- __stp_call_callbacks(tgt, tsk, 1, (tsk->pid == tsk->tgid)); | |
- | |
/* If this is just a thread other than the thread group leader, | |
don't bother inform map callback clients about its memory map, | |
since they will simply duplicate each other. */ | |
@@ -1424,6 +1423,10 @@ __stp_utrace_task_finder_target_quiesce(enum utrace_resume_action action, | |
__stp_call_mmap_callbacks_for_task(tgt, tsk); | |
} | |
+ /* Call the callbacks. Assume that if the thread is a | |
+ * thread group leader, it is a process. */ | |
+ __stp_call_callbacks(tgt, tsk, 1, (tsk->pid == tsk->tgid)); | |
+ | |
__stp_tf_handler_end(); | |
return UTRACE_RESUME; | |
} | |
diff --git a/runtime/linux/task_finder2.c b/runtime/linux/task_finder2.c | |
index 4fd0dfe56..c0dea2ac2 100644 | |
--- a/runtime/linux/task_finder2.c | |
+++ b/runtime/linux/task_finder2.c | |
@@ -1429,10 +1429,10 @@ __stp_utrace_task_finder_target_quiesce(u32 action, | |
} | |
} | |
else { | |
- /* Call the callbacks. Assume that if the thread is a | |
- * thread group leader, it is a process. */ | |
- __stp_call_callbacks(tgt, tsk, 1, (tsk->pid == tsk->tgid)); | |
- | |
+ /* NB make sure we run mmap callbacks before other callbacks | |
+ * like 'probe process.begin' handlers so that the vma tracker | |
+ * is already initialized in the latter contexts */ | |
+ | |
/* If this is just a thread other than the thread | |
group leader, don't bother inform map callback | |
clients about its memory map, since they will | |
@@ -1440,6 +1440,10 @@ __stp_utrace_task_finder_target_quiesce(u32 action, | |
if (tgt->mmap_events == 1 && tsk->tgid == tsk->pid) { | |
__stp_call_mmap_callbacks_for_task(tgt, tsk); | |
} | |
+ | |
+ /* Call the callbacks. Assume that if the thread is a | |
+ * thread group leader, it is a process. */ | |
+ __stp_call_callbacks(tgt, tsk, 1, (tsk->pid == tsk->tgid)); | |
} | |
__stp_tf_handler_end(); | |
diff --git a/testsuite/systemtap.base/process-begin-user.exp b/testsuite/systemtap.base/process-begin-user.exp | |
index 66c9e8b0e..6cd701ba8 100644 | |
--- a/testsuite/systemtap.base/process-begin-user.exp | |
+++ b/testsuite/systemtap.base/process-begin-user.exp | |
@@ -39,6 +39,9 @@ if {$res ne ""} { | |
set subtest2 "TEST 2: register() in probe process.end" | |
+# NB This test case is expected to fail on CentOS 6 on which registers are | |
+# actually usable in the prcoess.end probe. | |
+ | |
set res [target_compile ${testpath}/${test}_1.c ./a.out executable \ | |
"additional_flags=-O additional_flags=-g"] | |
if {$res ne ""} { | |
@@ -67,7 +70,7 @@ if {$res ne ""} { | |
# --- TEST 3 --- | |
-set subtest3 "TEST 3: @var() in probe process.begin (with vma tracker)" | |
+set subtest3 "TEST 3: @var() in probe process(PATH).begin (with vma tracker)" | |
set res [target_compile ${testpath}/${test}_3.c ./a.out executable \ | |
"additional_flags=-O additional_flags=-g additional_flags=-pie additional_flags=-fpic"] | |
@@ -95,3 +98,34 @@ if {$res ne ""} { | |
} | |
} | |
} | |
+ | |
+# --- TEST 4 --- | |
+ | |
+set subtest4 "TEST 4: @var() in probe process.begin (with vma tracker)" | |
+ | |
+set res [target_compile ${testpath}/${test}_3.c ./a.out executable \ | |
+ "additional_flags=-O additional_flags=-g additional_flags=-pie additional_flags=-fpic"] | |
+if {$res ne ""} { | |
+ verbose "target_compile failed: $res" 2 | |
+ fail "$test: $subtest4: unable to compile ${test}_3.c" | |
+} else { | |
+ if {! [process_template_file "$srcdir/$subdir/${test}_4.stp" \ | |
+ "./${test}_4.stp" "./a.out" nm_err]} { | |
+ fail "$test: $subtest4: $nm_err" | |
+ } else { | |
+ foreach runtime [get_runtime_list] { | |
+ if {$runtime eq ""} { | |
+ set runtime "kernel" | |
+ } | |
+ set test_name "$test: $subtest4 ($runtime)" | |
+ set cmd "stap --runtime=$runtime -c ./a.out './${test}_4.stp'" | |
+ set exit_code [run_cmd_2way $cmd out stderr] | |
+ set exp_out "a: 32\n" | |
+ is "${test_name}: stdout" $out $exp_out | |
+ is "${test_name}: exit code" $exit_code 0 | |
+ if {$stderr ne ""} { | |
+ send_log "stderr:\n$stderr" | |
+ } | |
+ } | |
+ } | |
+} | |
diff --git a/testsuite/systemtap.base/process-begin-user_4.stp b/testsuite/systemtap.base/process-begin-user_4.stp | |
new file mode 100644 | |
index 000000000..45f85e386 | |
--- /dev/null | |
+++ b/testsuite/systemtap.base/process-begin-user_4.stp | |
@@ -0,0 +1,5 @@ | |
+probe process.begin { | |
+ if (&@var("a", "$^PWD/a.out") != 0) { | |
+ printf("a: %d\n", @var("a", "$^PWD/a.out")); | |
+ } | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment