/usr/share/pyshared/timechart/backends/perf.py is in pytimechart 1.0.0~rc1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | import os
from timechart.model import tcProject
from timechart.window import tcWindow
class Event():
def __init__(self,name,kw):
self.__dict__=kw
self.event = name
self.timestamp = self.common_s*1000000+self.common_ns/1000
self.linenumber = 0
def get_partial_text(fn,start,end):
return "text trace unsupported with perf backend"
def trace_begin():
global proj
proj = tcProject()
proj.start_parsing(get_partial_text)
def trace_end():
proj.finish_parsing()
# Create and open the main window.
window = tcWindow(project = proj)
window.configure_traits()
def trace_unhandled(event_name, context, field_dict):
event_name = event_name[event_name.find("__")+2:]
proj.handle_trace_event(Event(event_name,field_dict))
def load_perf(filename):
dotpy = __file__
# perf python wants a .py file and not .pyc...
if dotpy.endswith("pyc"):
dotpy = dotpy[:-1]
perf = "perf"
if "PERF" in os.environ:
perf = os.environ["PERF"]
os.execlp(perf, perf, "trace", "-i", filename, "-s", dotpy)
return None
def detect_perf(filename):
name, ext = os.path.splitext(os.path.basename(filename))
if ext == ".data":
return load_perf
return None
|