.\" Automatically generated by Pandoc 2.9.2.1 .\" .TH "UFTRACE-REPLAY" "1" "Sep, 2018" "Uftrace User Manuals" "" .hy .SH NAME .PP uftrace-replay - Print recorded function trace .SH SYNOPSIS .PP uftrace replay [\f[I]options\f[R]] .SH DESCRIPTION .PP This command prints trace data recorded using the \f[C]uftrace-record\f[R](1) command. The traced functions are printed like a C program in time order. .SH REPLAY OPTIONS .TP -f \f[I]FIELD\f[R], --output-fields=\f[I]FIELD\f[R] Customize field in the output. Possible values are: duration, tid, addr, time, delta, elapsed, task and module. Multiple fields can be set by using comma. Special field of `none' can be used (solely) to hide all fields. Default is `duration,tid'. See \f[I]FIELDS\f[R]. .TP --flat Print flat format rather than C-like format. This is usually for debugging and testing purpose. .TP --column-view Show each task in separate column. This makes easy to distinguish functions in different tasks. .TP --column-offset=\f[I]DEPTH\f[R] When \f[C]--column-view\f[R] option is used, this option specifies the amount of offset between each task. Default is 8. .TP --task-newline Interleave a new line when task is changed. This makes easy to distinguish functions in different tasks. .TP --no-comment Do not show comments of returned functions. .TP --libname Show libname name along with function name. .TP --format=\f[I]TYPE\f[R] Show format style output. Currently, normal and html styles are supported. .SH COMMON OPTIONS .TP -F \f[I]FUNC\f[R], --filter=\f[I]FUNC\f[R] Set filter to trace selected functions and their children functions. This option can be used more than once. See \f[I]FILTERS\f[R]. .TP -N \f[I]FUNC\f[R], --notrace=\f[I]FUNC\f[R] Set filter not to trace selected functions and their children functions. This option can be used more than once. See \f[I]FILTERS\f[R]. .TP -C \f[I]FUNC\f[R], --caller-filter=\f[I]FUNC\f[R] Set filter to trace callers of selected functions only. This option can be used more than once. See \f[I]FILTERS\f[R]. .TP -T \f[I]TRG\f[R], --trigger=\f[I]TRG\f[R] Set trigger on selected functions. This option can be used more than once. See \f[I]TRIGGERS\f[R]. .TP -D \f[I]DEPTH\f[R], --depth \f[I]DEPTH\f[R] Set trace limit in nesting level. See \f[I]FILTERS\f[R]. .TP -t \f[I]TIME\f[R], --time-filter=\f[I]TIME\f[R] Do not show functions which run under the time threshold. If some functions explicitly have the `trace' trigger applied, those are always traced regardless of execution time. See \f[I]FILTERS\f[R]. .TP --no-libcall Do not show library calls. .TP --no-event Do not show any events. Implies \f[C]--no-sched\f[R]. .TP --no-sched Do not show schedule events. .TP --match=\f[I]TYPE\f[R] Use pattern match using TYPE. Possible types are \f[C]regex\f[R] and \f[C]glob\f[R]. Default is \f[C]regex\f[R]. .TP --disable Start replay with tracing disabled. This is only meaningful when used with a \f[C]trace_on\f[R] trigger. .SH COMMON ANALYSIS OPTIONS .TP -H \f[I]FUNC\f[R], --hide=\f[I]FUNC\f[R] Set filter not to trace selected functions. It doesn\[cq]t affect their subtrees, but hides only the given functions. This option can be used more than once. See \f[I]FILTERS\f[R]. .TP --kernel-full Show all kernel functions and events occurred outside of user functions. .TP --kernel-only Show kernel functions only without user functions. .TP --event-full Show all (user) events outside of user functions. .TP --tid=\f[I]TID\f[R][,\f[I]TID\f[R],\&...] Only print functions called by the given tasks. To see the list of tasks in the data file, you can use \f[C]uftrace report --task\f[R] or \f[C]uftrace info\f[R]. This option can also be used more than once. .TP --demangle=\f[I]TYPE\f[R] Use demangled C++ symbol names for filters, triggers, arguments and/or return values. Possible values are \[lq]full\[rq], \[lq]simple\[rq] and \[lq]no\[rq]. Default is \[lq]simple\[rq] which ignores function arguments and template parameters. .TP -r \f[I]RANGE\f[R], --time-range=\f[I]RANGE\f[R] Only show functions executed within the time RANGE. The RANGE can be \[ti] (separated by \[lq]\[ti]\[rq]) and one of and can be omitted. The and are timestamp or elapsed time if they have postfix, for example `100us'. The timestamp or elapsed time can be shown with \f[C]-f time\f[R] or \f[C]-f elapsed\f[R] option respectively. See \f[I]FILTERS\f[R]. .SH FILTERS .PP The uftrace tool supports filtering out uninteresting functions. When uftrace is called it receives two types of function filter; an opt-in filter with \f[C]-F\f[R]/\f[C]--filter\f[R] and an opt-out filter with \f[C]-N\f[R]/\f[C]--notrace\f[R]. These filters can be applied either at record time or replay time. .PP The first one is an opt-in filter. By default, it doesn\[cq]t show anything. But when one of the specified functions is met, printing is started. When the function returns, printing is stopped again. .PP For example, consider a simple program which calls \f[C]a()\f[R], \f[C]b()\f[R] and \f[C]c()\f[R] in turn. .IP .nf \f[C] $ cat abc.c void c(void) { /* do nothing */ } void b(void) { c(); } void a(void) { b(); } int main(void) { a(); return 0; } $ gcc -pg -o abc abc.c \f[R] .fi .PP Normally uftrace replay will show all the functions from \f[C]main()\f[R] to \f[C]c()\f[R]. .IP .nf \f[C] $ uftrace ./abc # DURATION TID FUNCTION 138.494 us [ 1234] | __cxa_atexit(); [ 1234] | main() { [ 1234] | a() { [ 1234] | b() { 3.880 us [ 1234] | c(); 5.475 us [ 1234] | } /* b */ 6.448 us [ 1234] | } /* a */ 8.631 us [ 1234] | } /* main */ \f[R] .fi .PP But when the \f[C]-F b\f[R] filter option is used, it will not show \f[C]main()\f[R] or \f[C]a()\f[R] but only \f[C]b()\f[R] and \f[C]c()\f[R]. Note that the filter was set on \f[C]uftrace replay\f[R], not at record time. .IP .nf \f[C] $ uftrace record ./abc $ uftrace replay -F b # DURATION TID FUNCTION [ 1234] | b() { 3.880 us [ 1234] | c(); 5.475 us [ 1234] | } /* b */ \f[R] .fi .PP The second type of filter is opt-out. When used, everything is shown by default, but printing stops once one of the specified functions is met. When the given function returns, printing is started again. .PP In the above example, you can omit the function \f[C]b()\f[R] and all calls it makes with the \f[C]-N\f[R] option. .IP .nf \f[C] $ uftrace record ./abc $ uftrace replay -N b # DURATION TID FUNCTION 138.494 us [ 1234] | __cxa_atexit(); [ 1234] | main() { 6.448 us [ 1234] | a(); 8.631 us [ 1234] | } /* main */ \f[R] .fi .PP You can hide the function \f[C]b()\f[R] only without affecting the calls it makes in its subtree functions with \f[C]-H\f[R] option. .IP .nf \f[C] $ uftrace record ./abc $ uftrace replay -H b # DURATION TID FUNCTION 138.494 us [ 1234] | __cxa_atexit(); [ 1234] | main() { [ 1234] | a() { 3.880 us [ 1234] | c(); 6.448 us [ 1234] | } /* a */ 8.631 us [ 1234] | } /* main */ \f[R] .fi .PP The above \f[C]-H\f[R] option is especially useful when hiding std namespace functions in C++ programs by using \f[C]-H \[ha]std::\f[R] option setting. .PP If users only care about specific functions and want to know how they are called, one can use the caller filter. It makes the function as leaf and prints the parent functions to the function. .IP .nf \f[C] $ uftrace record ./abc $ uftrace replay -C b # DURATION TID FUNCTION [ 1234] | main() { [ 1234] | a() { 5.475 us [ 1234] | b(); 6.448 us [ 1234] | } /* a */ 8.631 us [ 1234] | } /* main */ \f[R] .fi .PP In the above example, functions not in the calling path were not shown. Also the function `c' - which is a child of the function `b' - is also hidden. .PP In addition, you can limit the print nesting level with -D option. .IP .nf \f[C] $ uftrace record ./abc $ uftrace replay -D 3 # DURATION TID FUNCTION 138.494 us [ 1234] | __cxa_atexit(); [ 1234] | main() { [ 1234] | a() { 5.475 us [ 1234] | b(); 6.448 us [ 1234] | } /* a */ 8.631 us [ 1234] | } /* main */ \f[R] .fi .PP In the above example, uftrace only prints functions up to a depth of 3, so leaf function \f[C]c()\f[R] was omitted. Note that the \f[C]-D\f[R] option also works with \f[C]-F\f[R]. .PP Sometimes it\[cq]s useful to see long-running functions only. This is good because there are usually many tiny functions that are not interesting. The \f[C]-t\f[R]/\f[C]--time-filter\f[R] option implements the time-based filter that only records functions which run longer than the given threshold. In the above example, the user might want to see functions running more than 5 microseconds like below: .IP .nf \f[C] $ uftrace record ./abc $ uftrace replay -t 5us # DURATION TID FUNCTION 138.494 us [ 1234] | __cxa_atexit(); [ 1234] | main() { [ 1234] | a() { 5.475 us [ 1234] | b(); 6.448 us [ 1234] | } /* a */ 8.631 us [ 1234] | } /* main */ \f[R] .fi .PP You can also see replay output with different time threshold for the same recorded data. .IP .nf \f[C] $ uftrace replay -t 6us # DURATION TID FUNCTION 138.494 us [ 1234] | __cxa_atexit(); [ 1234] | main() { 6.448 us [ 1234] | a(); 8.631 us [ 1234] | } /* main */ \f[R] .fi .PP In addition, The \f[C]-r\f[R] option can show functions executed within the given time range. When using this option, you can see TIMESTAMP or ELAPSED fields as well as DURATION and TID. .IP .nf \f[C] $ uftrace replay -r 502716.387320101\[ti]502716.387322389 # TIMESTAMP DURATION TID FUNCTION 502716.387320101 0.289 us [ 6126] | fgets(); 502716.387320584 [ 6126] | get_values_from() { 502716.387320709 0.245 us [ 6126] | strdup(); 502716.387321172 0.144 us [ 6126] | strsep(); 502716.387321542 0.223 us [ 6126] | atoi(); 502716.387321983 0.239 us [ 6126] | atoi(); 502716.387322389 1.805 us [ 6126] | } /* get_values_from */ $ uftrace replay -r 40us\[ti] | head -10 # ELAPSED DURATION TID FUNCTION 40.141 us [ 6126] | get_values_from() { 40.269 us 0.249 us [ 6126] | strdup(); 40.756 us 0.149 us [ 6126] | strsep(); 41.119 us 0.235 us [ 6126] | atoi(); 41.578 us 0.211 us [ 6126] | atoi(); 41.957 us 1.816 us [ 6126] | } /* get_values_from */ 42.124 us 0.220 us [ 6126] | fgets(); 42.529 us [ 6126] | get_values_from() { 42.645 us 0.236 us [ 6126] | strdup(); \f[R] .fi .PP You can also set triggers on filtered functions. See \f[I]TRIGGERS\f[R] section below for details. .SH TRIGGERS .PP The uftrace tool supports triggering actions on selected function calls with or without filters. Currently supported triggers are \f[C]depth\f[R], \f[C]backtrace\f[R], \f[C]trace_on\f[R] and \f[C]trace_off\f[R]. The BNF for trigger specifications is like below: .IP .nf \f[C] := \[dq]\[at]\[dq] := | \[dq],\[dq] := \[dq]depth=\[dq] | \[dq]backtrace\[dq] | \[dq]trace_on\[dq] | \[dq]trace_off\[dq] | \[dq]color=\[dq] | \[dq]time=\[dq] | \[dq]filter\[dq] | \[dq]notrace\[dq] | \[dq]hide\[dq] := [ ] := \[dq]ns\[dq] | \[dq]nsec\[dq] | \[dq]us\[dq] | \[dq]usec\[dq] | \[dq]ms\[dq] | \[dq]msec\[dq] | \[dq]s\[dq] | \[dq]sec\[dq] | \[dq]m\[dq] | \[dq]min\[dq] \f[R] .fi .PP The \f[C]depth\f[R] trigger is to change filter depth during execution of the function. It can be used to apply different filter depths for different functions. And the \f[C]backtrace\f[R] trigger is used to print a stack backtrace at replay time. .PP The color trigger is to change the color of the function in replay output. The supported colors are \f[C]red\f[R], \f[C]green\f[R], \f[C]blue\f[R], \f[C]yellow\f[R], \f[C]magenta\f[R], \f[C]cyan\f[R], \f[C]bold\f[R], and \f[C]gray\f[R]. .PP The following example shows how triggers work. We set a filter on function \f[C]b()\f[R] with the \f[C]backtrace\f[R] action and change the maximum filter depth under \f[C]b()\f[R] to 2. .IP .nf \f[C] $ uftrace record ./abc $ uftrace replay -T \[aq]b\[at]filter,backtrace,depth=2\[aq] # DURATION TID FUNCTION backtrace [ 1234] | /* [ 0] main */ backtrace [ 1234] | /* [ 1] a */ [ 1234] | b() { 3.880 us [ 1234] | c(); 5.475 us [ 1234] | } /* b */ \f[R] .fi .PP The \f[C]trace_on\f[R] and \f[C]trace_off\f[R] actions (the \f[C]_\f[R] can be omitted as \f[C]traceon\f[R] and \f[C]traceoff\f[R]) control whether uftrace shows functions or not. The trigger runs at replay time, not run time, so it can handle kernel functions as well. Contrast this with triggers used under \f[C]uftrace record\f[R]. .PP The \f[C]time\f[R] trigger is to change time filter setting during execution of the function. It can be used to apply different time filter for different functions. .PP The \f[C]filter\f[R] and \f[C]notrace\f[R] triggers have same effect as \f[C]-F\f[R]/\f[C]--filter\f[R] and \f[C]-N\f[R]/\f[C]--notrace\f[R] options respectively. .PP The \f[C]hide\f[R] trigger has the same effect as \f[C]-H\f[R]/\f[C]--hide\f[R] option that hides the given functions, but do not affect to the functions in their subtree unlike the \f[C]notrace\f[R] trigger. .SH FIELDS .PP The uftrace allows for user to customize the replay output with a couple of fields. Here the field means info on the left side of the pipe (|) character. By default it uses duration and tid fields, but you can use other fields in any order like: .IP .nf \f[C] $ uftrace replay -f time,delta,duration,addr # TIMESTAMP TIMEDELTA DURATION ADDRESS FUNCTION 74469.340757350 1.583 us 4004d0 | __monstartup(); 74469.340762221 4.871 us 0.766 us 4004f0 | __cxa_atexit(); 74469.340764847 2.626 us 4006b1 | main() { 74469.340765061 0.214 us 400656 | a() { 74469.340765195 0.134 us 400669 | b() { 74469.340765344 0.149 us 40067c | c() { 74469.340765524 0.180 us 0.742 us 4004b0 | getpid(); 74469.340766935 1.411 us 1.591 us 40067c | } /* c */ 74469.340767195 0.260 us 2.000 us 400669 | } /* b */ 74469.340767372 0.177 us 2.311 us 400656 | } /* a */ 74469.340767541 0.169 us 2.694 us 4006b1 | } /* main */ \f[R] .fi .PP Each field has following meaning: .IP \[bu] 2 tid: task id (obtained by gettid(2)) .IP \[bu] 2 duration: function execution time .IP \[bu] 2 time: timestamp at the execution .IP \[bu] 2 delta: difference between two timestamp in a task .IP \[bu] 2 elapsed: elapsed time from the first timestamp .IP \[bu] 2 addr: address of the function .IP \[bu] 2 task: task name (comm) .IP \[bu] 2 module: library or executable name of the function .PP The default value is `duration,tid'. If given field name starts with \[lq]+\[rq], then it\[cq]ll be appended to the default fields. So \[lq]-f +time\[rq] is as same as \[lq]-f duration,tid,time\[rq]. And it also accepts a special field name of `none' which disables the field display and shows function output only. .SH SEE ALSO .PP \f[C]uftrace\f[R](1), \f[C]uftrace-record\f[R](1), \f[C]uftrace-report\f[R](1), \f[C]uftrace-info\f[R](1) .SH AUTHORS Namhyung Kim .