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

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



   perf-script-python    ( 1 )

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

SCRIPT LAYOUT

Every perf script Python script should start by setting up a Python module search path and 'import'ing a few support modules (see module descriptions below):

.ft C import os import sys

sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')

from perf_trace_context import * from Core import * .ft

The rest of the script can contain handler functions and support functions in any order.

Aside from the event handler functions discussed above, every script can implement a set of optional functions:

trace_begin, if defined, is called before any event is processed and gives scripts a chance to do setup tasks:

.ft C def trace_begin(): pass .ft

trace_end, if defined, is called after all events have been processed and gives scripts a chance to do end-of-script tasks, such as display results:

.ft C def trace_end(): pass .ft

trace_unhandled, if defined, is called after for any event that doesn't have a handler explicitly defined for it. The standard set of common arguments are passed into it:

.ft C def trace_unhandled(event_name, context, event_fields_dict): pass .ft

process_event, if defined, is called for any non-tracepoint event

.ft C def process_event(param_dict): pass .ft

context_switch, if defined, is called for any context switch

.ft C def context_switch(ts, cpu, pid, tid, np_pid, np_tid, machine_pid, out, out_preempt, *x): pass .ft

auxtrace_error, if defined, is called for any AUX area tracing error

.ft C def auxtrace_error(typ, code, cpu, pid, tid, ip, ts, msg, cpumode, *x): pass .ft

The remaining sections provide descriptions of each of the available built-in perf script Python modules and their associated functions.