Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1728684ioo; Fri, 27 May 2022 15:46:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqWl+B+UVl0SeO2lF11at0hLeADM+DQ77+ktzP46rtBRJEDQ0uJCTSoLNlpQxwcMbfy9mk X-Received: by 2002:a05:6a00:2d0:b0:518:95f8:d00a with SMTP id b16-20020a056a0002d000b0051895f8d00amr29427648pft.8.1653691585986; Fri, 27 May 2022 15:46:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653691585; cv=none; d=google.com; s=arc-20160816; b=PVXUkOljOyt6eRkJxY6+mhXyNrpLoIvkTG7/vZFw/wvKs5Hfw5ooNoPsjjtVBGJYQU /s8NFp1sN7ySEVYOv31E4EP4an6W7KN671v7tzXw2OccEs3QTKAZMtxIq7dMkSpCIUku S+YydAuUPuf63AJX6b6ZoZqtuUeOnJ6GmcCbTSWGvMUms64PIi7WAuBF0SaPKeHcBMTu CGponPNHCn5v3q6jl0ZupBZywKvd1sgeREhXYTDnLr4K4DBho6vUz16P/qpsepuZpaw8 qUGoYBVShJiyO75iR2Ys0vfmZWn9UYJKl+youPykwA+K0QN41XJxv2XJfU/eoQrnA7P8 C3Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=eVa9yb4fEARCqXnZc1fgQJTcdQczF4ISA6keKtwzumY=; b=nx41JZATFTP9q16qlR//+PXImPvINoirjiWx7kUzrLweEJTgmWYCFAGm8Lecma8yIk x8H53+dqNRHahBI+Ho87SvShO3jfgty2qR4BphuhIkPZfHN1jQ989j8rqP11FAXTOh9H yEx+O2wvhk92CFHVIwVctky+p4wB/dQBfAp6vo8F03TmbTLpEuWxCQ5GZx7jWwMSDsyJ 4dCF9an3g3kQWZX0urZL6fJA0eOpvK4PKUBH0seFpmrYjv4+1u/j8S86HNbzjkcbLCsP Ql5+sIlJ1C5k4nKWXI5iiZ8QlMJfKA0wLMdvzSFE2kTjhLWgVtlglb7w4EK6AALbb2v3 iK2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XS2jyPL+; 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 w24-20020a63fb58000000b003fa218db292si7601821pgj.682.2022.05.27.15.46.14; Fri, 27 May 2022 15:46:25 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XS2jyPL+; 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 S1345489AbiEZPni (ORCPT + 99 others); Thu, 26 May 2022 11:43:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241189AbiEZPne (ORCPT ); Thu, 26 May 2022 11:43:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28B48CFE14; Thu, 26 May 2022 08:43:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8AB5761C5D; Thu, 26 May 2022 15:43:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FF43C385A9; Thu, 26 May 2022 15:43:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653579812; bh=pFghZH5p3iCT67+6+qFAycKoXgf4wVflFH4Pzv1Zafg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XS2jyPL+qEzQ2AGzNMdt+HVvmW9X4FKi09Q4984DWRc/B8tYjMNSoDaImK243LIVI sCGUIz1NmcO5WOigq3gHyZ28djV7pWYR6RSMf3Qfng2t8BZyvGKoDOIh0/KFY3QiDV GtabaZtQ1yx4v8LBvW6TBsYHxSlhvVzFKJJtUrJAcBvmaAkRhsFz8jdqxYh7KFzQYD d8CityTroJ8r8lfPjjMZXYX0BOtxtNayOoFWVsnhHQVzGc5i2u6CjNg15a6fLsIhup WymQx36hDU0eSWOFb2/u14sreiLKBY8FN2PoRjnMokW6bUUxzkTwrqR8LgvHLx0San 93+IHvfahNeOQ== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id A289D4036D; Thu, 26 May 2022 12:43:29 -0300 (-03) Date: Thu, 26 May 2022 12:43:29 -0300 From: Arnaldo Carvalho de Melo To: Leo Yan Cc: James Clark , German Gomez , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Ian Rogers , Eelco Chaudron , Stephen Brennan , Tanmay Jagdale , "zengshun . wu" , Al Grant , coresight@lists.linaro.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH v6 1/2] perf scripting python: Expose dso and map information Message-ID: References: <20220521130446.4163597-1-leo.yan@linaro.org> <20220521130446.4163597-2-leo.yan@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220521130446.4163597-2-leo.yan@linaro.org> X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Em Sat, May 21, 2022 at 09:04:45PM +0800, Leo Yan escreveu: > This change adds dso build_id and corresponding map's start and end > address. The info of dso build_id can be used to find dso file path, > and we can validate if a branch address falls into the range of map's > start and end addresses. > > In addition, the map's start address can be used as an offset for > disassembly. > > Signed-off-by: Leo Yan > Acked-by: Adrian Hunter Thanks, applied both patches. - Arnaldo > --- > .../scripting-engines/trace-event-python.c | 21 +++++++++++++++---- > 1 file changed, 17 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c > index 659eb4e4b34b..adba01b7d9dd 100644 > --- a/tools/perf/util/scripting-engines/trace-event-python.c > +++ b/tools/perf/util/scripting-engines/trace-event-python.c > @@ -755,12 +755,22 @@ static void set_regs_in_dict(PyObject *dict, > } > > static void set_sym_in_dict(PyObject *dict, struct addr_location *al, > - const char *dso_field, const char *sym_field, > - const char *symoff_field) > + const char *dso_field, const char *dso_bid_field, > + const char *dso_map_start, const char *dso_map_end, > + const char *sym_field, const char *symoff_field) > { > + char sbuild_id[SBUILD_ID_SIZE]; > + > if (al->map) { > pydict_set_item_string_decref(dict, dso_field, > _PyUnicode_FromString(al->map->dso->name)); > + build_id__sprintf(&al->map->dso->bid, sbuild_id); > + pydict_set_item_string_decref(dict, dso_bid_field, > + _PyUnicode_FromString(sbuild_id)); > + pydict_set_item_string_decref(dict, dso_map_start, > + PyLong_FromUnsignedLong(al->map->start)); > + pydict_set_item_string_decref(dict, dso_map_end, > + PyLong_FromUnsignedLong(al->map->end)); > } > if (al->sym) { > pydict_set_item_string_decref(dict, sym_field, > @@ -840,7 +850,8 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample, > (const char *)sample->raw_data, sample->raw_size)); > pydict_set_item_string_decref(dict, "comm", > _PyUnicode_FromString(thread__comm_str(al->thread))); > - set_sym_in_dict(dict, al, "dso", "symbol", "symoff"); > + set_sym_in_dict(dict, al, "dso", "dso_bid", "dso_map_start", "dso_map_end", > + "symbol", "symoff"); > > pydict_set_item_string_decref(dict, "callchain", callchain); > > @@ -856,7 +867,9 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample, > if (addr_al) { > pydict_set_item_string_decref(dict_sample, "addr_correlates_sym", > PyBool_FromLong(1)); > - set_sym_in_dict(dict_sample, addr_al, "addr_dso", "addr_symbol", "addr_symoff"); > + set_sym_in_dict(dict_sample, addr_al, "addr_dso", "addr_dso_bid", > + "addr_dso_map_start", "addr_dso_map_end", > + "addr_symbol", "addr_symoff"); > } > > if (sample->flags) > -- > 2.25.1 -- - Arnaldo