Skip to content

Commit c519ba7

Browse files
committed
gh-158294: Avoid relying on SystemTap probe handler ordering
Merge the tracing state and filter output in a single probe handler as SystemTap does not guarantee the execution order of handlers sharing a probe point.
1 parent 1e03154 commit c519ba7

1 file changed

Lines changed: 7 additions & 19 deletions

File tree

‎Lib/test/dtracedata/call_stack.stp‎

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,21 @@ function basename:string(path:string)
1010
return last_token;
1111
}
1212

13-
probe @PYTHON_SYSTEMTAP_PROBE@("function__entry")
14-
{
15-
funcname = user_string($arg2);
16-
17-
if (funcname == "start") {
18-
tracing = 1;
19-
}
20-
}
21-
2213
probe @PYTHON_SYSTEMTAP_PROBE@("function__entry"),
2314
@PYTHON_SYSTEMTAP_PROBE@("function__return")
2415
{
2516
filename = user_string($arg1);
2617
funcname = user_string($arg2);
2718
lineno = $arg3;
2819

29-
if (tracing) {
20+
if (funcname == "start") {
21+
if ($$name == "function__entry") {
22+
tracing = 1;
23+
} else {
24+
tracing = 0;
25+
}
26+
} else if (tracing) {
3027
printf("%d\t%s:%s:%s:%d\n", gettimeofday_us(), $$name,
3128
basename(filename), funcname, lineno);
3229
}
3330
}
34-
35-
probe @PYTHON_SYSTEMTAP_PROBE@("function__return")
36-
{
37-
funcname = user_string($arg2);
38-
39-
if (funcname == "start") {
40-
tracing = 0;
41-
}
42-
}

0 commit comments

Comments
 (0)