trappy.base module¶
Base class to parse trace.dat dumps
-
class
trappy.base.
Base
(parse_raw=False)[source]¶ Bases:
object
Base class to parse trace.dat dumps.
Don’t use directly, create a subclass that has a unique_word class variable. unique_word is a string that can uniquely identify lines in the trace that correspond to this event. This is usually the trace_name (optionally followed by a semicolong, e.g. “sched_switch:”) but it can be anything else for trace points generated using trace_printk().
Parameters: parse_raw – If True
, raw trace data (-R option) to trace-cmd will be usedThis class acts as a base class for all TRAPpy events
-
append_data
(time, comm, pid, cpu, data)[source]¶ Append data parsed from a line to the corresponding arrays
The
DataFrame
will be created from this when the whole trace has been parsed.Parameters: - time (float) – The time for the line that was printed in the trace
- comm (str) – The command name or the execname from which the trace line originated
- pid (int) – The PID of the process from which the trace line originated
- data (str) – The data for matching line in the trace
-
-
trappy.base.
trace_parser_explode_array
(string, array_lengths)[source]¶ Explode an array in the trace into individual elements for easy parsing
Basically, turn
load={1 1 2 2}
intoload0=1 load1=1 load2=2 load3=2
.Parameters: - string (str) – Input string from the trace
- array_lengths (dict) – A dictionary of array names and their expected length. If we get array that’s shorter than the expected length, additional keys have to be introduced with value 0 to compensate.
For example:
trace_parser_explode_array(string="load={1 2}", array_lengths={"load": 4}) "load0=1 load1=2 load2=0 load3=0"