Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30015958rwd; Wed, 5 Jul 2023 22:53:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlF6I2p6kjwCibQ6YGLfYaBZ2Jbgc2JgZVRTSZE5DvagG6Ydi+2k+Lw3F+zzwlulFNfiRmRO X-Received: by 2002:ac8:5a82:0:b0:3f9:cb01:9dae with SMTP id c2-20020ac85a82000000b003f9cb019daemr1007747qtc.50.1688622785704; Wed, 05 Jul 2023 22:53:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688622785; cv=none; d=google.com; s=arc-20160816; b=GRZDbrXgk+LWRNGSpHqkCCZ8hKEE6K3TaDEc/GKxLA58RJr+KR8HX1DbWGfAWm8yAT LXZrSbA0R+lYNzdi3+4f5S6Ov2ZeloX6RddPyoBjYHvu42ySodU34iP20gUwYFHWvtXG TUAnb0Cx12CmFeOsH+GBD4HXLnXe3bifvgnCs0SbQ4hDZ2eig9UzB26R1DsJoda6+Vu7 7rp8tdxv1u0mvCXbJnOMHKy/vujwOXtM/+5GzSB2BBYhmKFa7Hg+eOITME0WCd6f3lc9 q2eIUZDuvNmFEp4htzG99vYAwTrtVL118Yt+UtZzP0PGgKRwMZk3mX3nUcenHELsQzgh DzFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=MhPuWcvihIMDjCNk0fIZRUbOgmOGfLhksG1MMYl9aQM=; fh=M2Wb7ZmVzwfcnR5Fu72cJwECOoQLLjUEn+j0vvab/TY=; b=Px0EaW2VObOduLYPBGY8YNV+szjubDnSU13B376QXZ+1jFVH2dESawtbmOOPbH2fVJ 7PfZR9ipZMC+udYNvru3lgkXyh5h5jX4gDWANsO6PcSwhAS99fl/MFyeNlWCsZjPno0A 9VVmzVNpXNmLU1YUBIl/BNrS58TgvNTHeaMkBOf4pEpbacRdSHesMM/f6+gdmEBxy4xH LJhdDa8QWg5mJ4hr508y501yN+xD23Ldskhq3f9IurIkYnJnQSOV6jfJazeIGTGETaZr zedWxBOuwhaCAO4FWf8s4EorZT2zX6fGIskJpr/E0rrBl+JfxirayKl14AZ92vLH+INb k+bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j190-20020a6380c7000000b0055bca9b4e20si703828pgd.878.2023.07.05.22.52.50; Wed, 05 Jul 2023 22:53:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233061AbjGFFfT convert rfc822-to-8bit (ORCPT + 99 others); Thu, 6 Jul 2023 01:35:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbjGFFfS (ORCPT ); Thu, 6 Jul 2023 01:35:18 -0400 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F26931BD6; Wed, 5 Jul 2023 22:35:16 -0700 (PDT) Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-4f95bf5c493so262332e87.3; Wed, 05 Jul 2023 22:35:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688621715; x=1691213715; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V1PlvNNiTnUdsZiP/Cax+GwYe1YLGfv4AkH8z3c/IKA=; b=c5lfu9A7ZU1c8bnSk2y8juJ2iLVlEj2nYhr503GcnWDNEOJhD2veGn2APeZMZ8FE8a 3RCFCXmTnCo0XFk21AmrVTyhtNWwtCNpKt/Qnl1Qwang2Lej1X9xIgvuqh4nhitJpk7L H7IrFsLzFBisWdbcJ652sT1kMpzEJVy1ETD3PnU4NxW7qhwlUbfFwE9cCuF6dfayDJhc jJkiyi59qntJs0lmnb8QjBWq+JBe91IRYQHolrE1TwsethrHyuaOnrczzUf0aR3dSCbF hGLF890VO5JizhVrKVnJfV/T33x7taiJIv8ugpfshukgMc12kTkqUi0rgmBf6LP7BQFV IQJg== X-Gm-Message-State: ABy/qLYDCpNGu5HvJU+TICUwYw3zWtU4LkRBpjznY6RIuwjmDRjgrdlL mEEc0tSHbX7HsDNB4F0u5hmhQ00V81B+hZZEmSVlTiLh X-Received: by 2002:a19:7114:0:b0:4f9:56aa:26c5 with SMTP id m20-20020a197114000000b004f956aa26c5mr636564lfc.25.1688621714815; Wed, 05 Jul 2023 22:35:14 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Namhyung Kim Date: Wed, 5 Jul 2023 22:35:02 -0700 Message-ID: Subject: Re: [PATCH v2 1/7] scripts: python: Extact necessary information from process event To: Anup Sharma Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Anup, On Wed, Jul 5, 2023 at 12:42 PM Anup Sharma wrote: > > The script takes in a sample event dictionary(param_dict) and retrieves > relevant data such as time stamp, PID, TID, thread name, and call stack > information. If available, the call stack is parsed to include function > names and the associated DSO, which are requires for creating json schema. > Also few libaries has been included which will be used in later commit. > > Signed-off-by: Anup Sharma > --- > .../scripts/python/firefox-gecko-converter.py | 37 +++++++++++++++++++ > 1 file changed, 37 insertions(+) > create mode 100644 tools/perf/scripts/python/firefox-gecko-converter.py > > diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/perf/scripts/python/firefox-gecko-converter.py > new file mode 100644 > index 000000000000..ce663840d212 > --- /dev/null > +++ b/tools/perf/scripts/python/firefox-gecko-converter.py > @@ -0,0 +1,37 @@ > +#!/usr/bin/env python3 > +# SPDX-License-Identifier: GPL-2.0 > +# > +# Usage: > +# > +# perf record -a -g -F 99 sleep 1 > +# perf script firefox-gecko-converter.py > + > +from __future__ import print_function Is this needed for python3? > +import os > +import sys > +import json > +from functools import reduce > + > +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 process_event(param_dict): > + time_stamp = (param_dict['sample']['time'] // 1000) / 1000 > + pid = param_dict['sample']['pid'] > + tid = param_dict['sample']['tid'] > + thread_name = param_dict['comm'] > + start_time = time_stamp if not start_time else start_time > + if param_dict['callchain']: > + stack = [] > + for call in param_dict['callchain']: > + if 'sym' not in call: > + continue > + stack.append(call['sym']['name'] + f' (in {call["dso"]})') > + if len(stack) != 0: > + stack = stack[::-1] > + else: > + mod = param_dict['symbol'] if 'symbol' in param_dict else '[unknown]' Why is it 'mod' instead of 'sym' or 'func'? Thanks, Namhyung > + dso = param_dict['dso'] if 'dso' in param_dict else '[unknown]' > -- > 2.34.1 >