trappy.dynamic module

The idea is to create a wrapper class that returns a Type of a Class dynamically created based on the input parameters. Similar to a factory design pattern

class trappy.dynamic.DynamicTypeFactory(name, bases, dct)[source]

Bases: type

Override the type class to create a dynamic type on the fly. This Factory class is used internally by trappy.dynamic.register_dynamic_ftrace

trappy.dynamic.default_init(self)[source]

Default Constructor for the Dynamic MetaClass. This is used for the dynamic object creation in trappy.dynamic.DynamicTypeFactory

trappy.dynamic.register_dynamic_ftrace(class_name, unique_word, scope='all', parse_raw=False, pivot=None)[source]

Create a Dynamic FTrace parser and register it with any FTrace parsing classes

Parameters:
  • class_name (str) – The name of the class to be registered (Should be in CamelCase)
  • unique_word (str) – The unique_word to be matched in the trace
  • scope (str) – Registry Scope (Can be used to constrain the parsing of events and group them together)
  • parse_raw (bool) – If, true, raw trace output (-R flag) will be used
  • pivot (str) – The data column about which the data can be grouped

For example if a new unique word my_unique_word has to be registered with TRAPpy:

import trappy
custom_class = trappy.register_dynamic_ftrace("MyEvent", "my_unique_word")
trace = trappy.FTrace("/path/to/trace_file")

# New data member created in the ftrace object
trace.my_event

Note

The name of the member is my_event from MyEvent

Returns:A class object of type trappy.base.Base
trappy.dynamic.register_ftrace_parser(cls, scope='all')[source]

Register a new FTrace parser class implementation

Should be used when the class has complex helper methods and does not expect to use the default constructor.

Parameters:
  • cls (trappy.base.Base) – The class to be registered for enabling the parsing of an event in trace
  • scope (string) – scope of this parser class. The scope can be used to restrict the parsing done on an individual file. Currently the only scopes available are “sched”, “thermal” or “all”
trappy.dynamic.unregister_ftrace_parser(ftrace_parser)[source]

Unregister an ftrace parser

Parameters:ftrace_parser (class derived from trappy.base.Base) – An ftrace parser class that was registered with register_ftrace_parser() or register_dynamic_ftrace(). If done with the latter, the cls parameter is the return value of register_dynamic_ftrace()