From mboxrd@z Thu Jan 1 00:00:00 1970 From: Namhyung Kim Subject: Re: Accessing sample data (like period) for trace events from python scripts Date: Fri, 19 Aug 2016 10:51:01 +0900 Message-ID: <20160819015101.GB22968@sejong> References: <12483222.2TZrqxLJ8H@agathebauer> <20160817030553.GB8981@sejong> <8086607.n4B18LBsdA@milian-kdab2> <20160819013549.GA22968@sejong> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Return-path: Received: from LGEAMRELO12.lge.com ([156.147.23.52]:55713 "EHLO lgeamrelo12.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754131AbcHSBxD (ORCPT ); Thu, 18 Aug 2016 21:53:03 -0400 In-Reply-To: <20160819013549.GA22968@sejong> Content-Disposition: inline Sender: linux-perf-users-owner@vger.kernel.org List-ID: To: Milian Wolff Cc: linux-perf-users@vger.kernel.org On Fri, Aug 19, 2016 at 10:35:49AM +0900, Namhyung Kim wrote: > On Wed, Aug 17, 2016 at 10:48:31AM +0200, Milian Wolff wrote: > > On Wednesday, August 17, 2016 12:05:53 PM CEST Namhyung Kim wrote: > > > Hi Milian, > > > > > > On Tue, Aug 16, 2016 at 08:42:01PM +0200, Milian Wolff wrote: > > > > Hey all, > > > > > > > > It doesn't seem to be possible to access the period, tid and various other > > > > sample fields from a python (and perl?) script using `perf script`. My > > > > use- > > > > case would be analyzing a perf data file created by perf inject > > > > --sched-stat. > > > > > > I think you can access param_dict["sample"]["period"]. > > > > No, that is not possible, but would be a viable solution as well. > > Sorry for late reply. Oh, you wanted to access period of tracepoint > but I guess it's always 1, no? OK, it seems sched_stat events have periods bigger than 1. But you can access it using 'runtime' or 'delay' field in the event too. I think sample data of tracepoint event is mostly meaningless and you should access to the event fields for useful information. That's why it doesn't provide the info for tracepoint events, I guess. What do you specifically want to know from sample data? Thanks, Namhyung > > > > > ~~~~~~~~~~~~~~~~~~ > > /tmp$ cat perf-script.py > > > > 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 * > > > > def trace_unhandled(event_name, context, event_fields_dict): > > print event_fields_dict['sample']['period'] > > > > /tmp$ perf script -s perf-script.py > > Traceback (most recent call last): > > File "perf-script.py", line 11, in trace_unhandled > > print event_fields_dict['sample']['period'] > > KeyError: 'sample' > > Fatal Python error: problem in Python trace event handler > > Aborted (core dumped) > > ~~~~~~~~~~~~~~~~~~ > > > > Cheers > > -- > > Milian Wolff | milian.wolff@kdab.com | Software Engineer > > KDAB (Deutschland) GmbH&Co KG, a KDAB Group company > > Tel: +49-30-521325470 > > KDAB - The Qt Experts > >