@@ -70,6 +70,14 @@ Synopsis of fprobe-events
7070
7171For the details of TYPE, see :ref: `kprobetrace documentation <kprobetrace_types >`.
7272
73+ Function arguments at exit
74+ --------------------------
75+ Function arguments can be accessed at exit probe using $arg<N> fetcharg. This
76+ is useful to record the function parameter and return value at once, and
77+ trace the difference of structure fields (for debuging a function whether it
78+ correctly updates the given data structure or not)
79+ See the :ref: `sample<fprobetrace_exit_args_sample> ` below for how it works.
80+
7381BTF arguments
7482-------------
7583BTF (BPF Type Format) argument allows user to trace function and tracepoint
@@ -218,3 +226,26 @@ traceprobe event, you can trace that field as below.
218226 <idle>-0 [000] d..3. 5606.690317: sched_switch: (__probestub_sched_switch+0x4/0x10) comm="kworker/0:1" usage=1 start_time=137000000
219227 kworker/0:1-14 [000] d..3. 5606.690339: sched_switch: (__probestub_sched_switch+0x4/0x10) comm="swapper/0" usage=2 start_time=0
220228 <idle>-0 [000] d..3. 5606.692368: sched_switch: (__probestub_sched_switch+0x4/0x10) comm="kworker/0:1" usage=1 start_time=137000000
229+
230+ .. _fprobetrace_exit_args_sample :
231+
232+ The return probe allows us to access the results of some functions, which returns
233+ the error code and its results are passed via function parameter, such as an
234+ structure-initialization function.
235+
236+ For example, vfs_open() will link the file structure to the inode and update
237+ mode. You can trace that changes with return probe.
238+ ::
239+
240+ # echo 'f vfs_open mode=file->f_mode:x32 inode=file->f_inode:x64' >> dynamic_events
241+ # echo 'f vfs_open%%return mode=file->f_mode:x32 inode=file->f_inode:x64' >> dynamic_events
242+ # echo 1 > events/fprobes/enable
243+ # cat trace
244+ sh-131 [006] ...1. 1945.714346: vfs_open__entry: (vfs_open+0x4/0x40) mode=0x2 inode=0x0
245+ sh-131 [006] ...1. 1945.714358: vfs_open__exit: (do_open+0x274/0x3d0 <- vfs_open) mode=0x4d801e inode=0xffff888008470168
246+ cat-143 [007] ...1. 1945.717949: vfs_open__entry: (vfs_open+0x4/0x40) mode=0x1 inode=0x0
247+ cat-143 [007] ...1. 1945.717956: vfs_open__exit: (do_open+0x274/0x3d0 <- vfs_open) mode=0x4a801d inode=0xffff888005f78d28
248+ cat-143 [007] ...1. 1945.720616: vfs_open__entry: (vfs_open+0x4/0x40) mode=0x1 inode=0x0
249+ cat-143 [007] ...1. 1945.728263: vfs_open__exit: (do_open+0x274/0x3d0 <- vfs_open) mode=0xa800d inode=0xffff888004ada8d8
250+
251+ You can see the `file::f_mode ` and `file::f_inode ` are upated in `vfs_open() `.
0 commit comments