Skip to content

Commit 0f6214d

Browse files
amscannejordalgo
authored andcommitted
docs: add example for output parameters
The `tests/runtime/variable` happens to provide a good example of capturing output parameters. Incorporate this as an example into the documentation in a suitable spot. Fixes bpftrace#233
1 parent 9a95dbf commit 0f6214d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

man/adoc/bpftrace.adoc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,24 @@ kretprobe:do_nanosleep /has_key(@start, tid)/ {
10441044
*/
10451045
----
10461046

1047+
This style of map may also be useful for capturing output parameters, or other context, between two different probes. For example:
1048+
1049+
----
1050+
tracepoint:syscalls:sys_enter_wait4
1051+
{
1052+
@out[tid] = args.ru;
1053+
}
1054+
1055+
tracepoint:syscalls:sys_exit_wait4
1056+
{
1057+
$ru = @out[tid];
1058+
delete(@out, tid);
1059+
if ($ru != 0) {
1060+
printf("got usage ...", ...);
1061+
}
1062+
}
1063+
----
1064+
10471065
== Builtins
10481066

10491067
Builtins are special variables built into the language.

0 commit comments

Comments
 (0)