def post_process(args, conn): decoders = get_decoders().get('db', []) if not decoders: return [] tree = default_tree(args) tree['ring_buffer'] = True args.no_left_overs = True with Callbacks(args, tree) as callbacks: if callbacks.is_empty(): return callbacks.get_result() for decoder in get_decoders().get('db', []): decoder(args, callbacks).handle_db(conn) return callbacks.get_result()
def __init__(self, args, callbacks): self.args, self.callbacks = args, callbacks self.decoders = [] decoders = get_decoders() if 'log' in decoders: for decoder in decoders['log']: self.decoders.append(decoder(args, callbacks))
def __init__(self, args, gt, callbacks): GPUQueue.__init__(self, args, callbacks) self.cs = None self.ignore_gpu = True # workaround for incomplete dtrace ring self.cpu_packets = {} self.gpu_packets = {} self.thread_names = {} self.gpu_transition = {} self.gpu_frame = {'catch': [0, 0], 'task': None} self.prepares = {} self.pid_names = {} self.tid_map = {} self.event_tracker = { } # key is ring+channel => key is tracking stamp => [events] self.contexts = {u'0': 'System'} # id to type map for callback in self.callbacks.callbacks: if 'ContextSwitch' in dir(callback): self.cs = callback.ContextSwitch(callback, args.input + '.ftrace') self.callbacks( "metadata_add", { 'domain': 'GPU', 'str': '__process__', 'pid': -1, 'tid': -1, 'data': 'GPU Contexts', 'time': 0, 'delta': -2 }) self.decoders = [] decoders = get_decoders() if 'dtrace' in decoders: for decoder in decoders['dtrace']: self.decoders.append(decoder(args, callbacks))
def start(self): # spawn dtrace tracers and exit, all means to stop it must be saved to self members: # launch command line with dtrace script and remember pid script = os.path.join(self.args.output, 'script.d') self.files = [ os.path.join( self.args.output, 'data-%s.dtrace' % (self.args.cuts[0] if self.args.cuts else '0')) ] if os.path.exists(self.files[0]): os.remove(self.files[0]) cmd = 'sudo -A dtrace -Z -q -o "%s" -s "%s"' % (self.files[0], script) dtrace_script = [] if self.args.ring: dtrace_script.append( self.gen_options([('bufpolicy', 'ring'), ('bufresize', 'auto'), ('bufsize', '%dm' % (self.args.ring * 10))])) dtrace_script.append(dtrace_context_switch) dtrace_script.append(fbt_dtrace_hooks) (probes, err) = self.execute( 'sudo -A dtrace -l -m *com.apple.driver.AppleIntel*Graphics*', env=os.environ) if probes: dtrace_script.append(self.gen_gpu_hooks(probes)) if self.args.target: dtrace_script.append(pid_dtrace_hooks) cmd += " -p %s" % self.args.target decoders = get_decoders() if 'dtrace' in decoders: for decoder in decoders['dtrace']: hooks = decoder.get_hooks(self.args) if hooks: dtrace_script.append(hooks) dtrace_script = '\n'.join(dtrace_script) if self.args.stacks: dtrace_script = dtrace_script.replace('/*{OFF_CPU}*/', OFF_CPU_STACKS) with open(script, 'w') as file: file.write(dtrace_script) proc = subprocess.Popen(cmd, shell=True, stdin=None, stdout=self.output, stderr=self.output, env=os.environ) self.pid = proc.pid self.log(cmd) self.log("pid: %d" % proc.pid)
def __init__(self, args): Collector.__init__(self, args) self.processes = {} self.files = [] self.subcollectors = set() self.attached = set() decoders = get_decoders() for decoder_group in decoders.values(): for decoder_class in decoder_group: if any('Subcollector' in str(name) for name in decoder_class.__bases__): self.subcollectors.add(decoder_class) if 'SUDO_ASKPASS' not in os.environ: get_original_env()['SUDO_ASKPASS'] = self.create_ask_pass() assert 'DYLD_INSERT_LIBRARIES' not in os.environ self.sudo_execute('pkill dtrace') self.script = None if args.follow: self.fifo_reader = FifoReader( self, os.path.join(self.args.output, 'follow_child.fifo')) self.prepare() self.times = [] self.attach_by_pid = True
def __init__(self, args, gt, callbacks): GPUQueue.__init__(self, args, callbacks) self.cs = None self.ignore_gpu = True # workaround for incomplete dtrace ring self.cpu_packets = {} self.gpu_packets = {} self.thread_names = {} self.gpu_transition = {} self.prepares = {} self.pid_names = {} self.tid_map = {} self.event_tracker = { } # key is ring+channel => key is tracking stamp => [events] self.contexts = {u'0': 'System'} # id to type map callbacks.set_process_name(-1, 'GPU Contexts') self.stat = {} self.decoders = [] decoders = get_decoders() if 'dtrace' in decoders: for decoder in decoders['dtrace']: self.decoders.append(decoder(args, callbacks)) importers = get_importers() self.read_system_info() self.collected_domains = set()
def __init__(self, args, callbacks): self.callbacks = callbacks self.args = args self.decoders = [] decoders = get_decoders() if 'json' in decoders: for decoder in decoders['json'] + [OwnDecoder]: self.decoders.append(decoder(args, callbacks))
def __init__(self, args, callbacks): self.callbacks = callbacks self.args = args self.last_record = None self.decoders = [] decoders = get_decoders() if 'perf' in decoders: for decoder in decoders['perf']: self.decoders.append(decoder(args, callbacks))
def __init__(self, args, callbacks): self.callbacks = callbacks self.args = args self.tid_map = {} self.decoders = [] if hasattr(self.args, 'user_input') and os.path.isdir(self.args.user_input): self.tid_map = build_tid_map(self.args, self.args.user_input) decoders = get_decoders() if 'ftrace' in decoders: for decoder in decoders['ftrace']: self.decoders.append(decoder(args, callbacks))
def __init__(self, args, callbacks): self.callbacks = callbacks self.args = args self.tid_map = {} self.decoders = [] if hasattr(self.args, 'user_input') and os.path.isdir(self.args.user_input): self.build_tid_map(self.args.user_input) decoders = get_decoders() if 'ftrace' in decoders: for decoder in decoders['ftrace']: self.decoders.append(decoder(callbacks))
def __init__(self, args): Collector.__init__(self, args) self.pid = None self.files = [] self.subcollectors = set() decoders = get_decoders() for decoder_group in itervalues(decoders): for decoder_class in decoder_group: if any('Subcollector' in str(name) for name in decoder_class.__bases__): self.subcollectors.add(decoder_class) if 'SUDO_ASKPASS' not in os.environ: os.environ['SUDO_ASKPASS'] = self.create_ask_pass() if 'DYLD_INSERT_LIBRARIES' in os.environ: del os.environ['DYLD_INSERT_LIBRARIES'] self.execute('sudo -A pkill dtrace', env=os.environ) self.start()