Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   perf-script-python    ( 1 )

обработка данных трассировки с помощью скрипта Python (Process trace data with a Python script)

  Name  |  Synopsis  |  Description  |  Examples  |  Starter scripts  |  Event handlers  |  Script layout  |    Available modules and functions    |  Supported fields  |  See also  |

AVAILABLE MODULES AND FUNCTIONS

The following sections describe the functions and variables available via the various perf script Python modules. To use the functions and variables from the given module, add the corresponding from XXXX import line to your perf script script.

Core.py Module These functions provide some essential functions to user scripts.

The flag_str and symbol_str functions provide human-readable strings for flag and symbolic fields. These correspond to the strings and values parsed from the print fmt fields of the event format files:

flag_str(event_name, field_name, field_value) - returns the string representation corresponding to field_value for the flag field field_name of event event_name symbol_str(event_name, field_name, field_value) - returns the string representation corresponding to field_value for the symbolic field field_name of event event_name

The autodict function returns a special kind of Python dictionary that implements Perl's autovivifying hashes in Python i.e. with autovivifying hashes, you can assign nested hash values without having to go to the trouble of creating intermediate levels if they don't exist.

autodict() - returns an autovivifying dictionary instance

perf_trace_context Module Some of the common fields in the event format file aren't all that common, but need to be made accessible to user scripts nonetheless.

perf_trace_context defines a set of functions that can be used to access this data in the context of the current event. Each of these functions expects a context variable, which is the same as the context variable passed into every tracepoint event handler as the second argument. For non-tracepoint events, the context variable is also present as perf_trace_context.perf_script_context .

common_pc(context) - returns common_preempt count for the current event common_flags(context) - returns common_flags for the current event common_lock_depth(context) - returns common_lock_depth for the current event perf_sample_insn(context) - returns the machine code instruction perf_set_itrace_options(context, itrace_options) - set --itrace options if they have not been set already perf_sample_srcline(context) - returns source_file_name, line_number perf_sample_srccode(context) - returns source_file_name, line_number, source_line

Util.py Module Various utility functions for use with perf script:

nsecs(secs, nsecs) - returns total nsecs given secs/nsecs pair nsecs_secs(nsecs) - returns whole secs portion given nsecs nsecs_nsecs(nsecs) - returns nsecs remainder given nsecs nsecs_str(nsecs) - returns printable string in the form secs.nsecs avg(total, n) - returns average given a sum and a total number of values