From patchwork Sat Nov 5 03:01:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 15878 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp786186wru; Fri, 4 Nov 2022 20:45:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6DMqK/709euUDn0M+v0IYwHmxSDNyP7LYNbZZB90uMHlvOO2vdggaWumwJQlOzC0je9ATB X-Received: by 2002:a05:6402:2949:b0:451:fabf:d88a with SMTP id ed9-20020a056402294900b00451fabfd88amr37508448edb.324.1667619939932; Fri, 04 Nov 2022 20:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667619939; cv=none; d=google.com; s=arc-20160816; b=hjlPxXWj9ongUcoB+oH7/el3eqm1xi9qqPT7WDNUE0YM2pSGsUJsrb20UMj8xM4mKS +3bnPeUbKFqUFL03QNPLbmjk+dgXCgdhMSGRU2d3WE9eEAPI5+KhzcPRPpkU3GyKV+ax x+SKd5MxJoQRfHoBdqJ4AH8lXhaFof73wQq+xWNWRBdGyjN0SN+D10aut0osZxjADa4G FHKtiP3BDafjoMAO9f/tvcvsnt5FOqEUlpW7zib6D5BGH/dKSdHzLcFP0YZRAt1fOg3g 7XW8Xq0RULKxSbK/bI2rM+lPjHHpuhALuONn/oAnTP1XLo2NUQDU6JEMNMkHZp98gUne SQ/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:date:subject:cc:to:from:dkim-signature; bh=mHHS3I9aMqhSj5PTPwYVVebwVwqOdRfsSybYgYxuK4E=; b=Mb5lytvoULhgb2JDgWryX3L51v5d7+Alsa5D1vdqHjyVESKxKTLlHfjAjEQT9LBbgZ qKQvHWQBWcwTF6wdYDZTNMMEtqVqp5Vwdk+R91h4CkYAJMe0A9VrMGROaQLUQzatNzcO k8J+r/7fdt+Jx5v+Atcm1/ZVaz8q8NLnoMbomU0I9iHdRiaY7vxv4rf7+MhMPepdGqZm N0zg0Iv2an2T8qvWqrSVHBy/7jcpQF39XlAIXKh5sT70w/LIpMULZB85BUEF41LksSgO 01x6vGJ09O2clQbw9uHJxIKwXIcyF0wAlDncNXCS1V24HsimftuyZDCzX+xnEHHamqC8 x+Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pJLO5YjH; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wu10-20020a170906eeca00b007986956bd8esi947073ejb.472.2022.11.04.20.45.13; Fri, 04 Nov 2022 20:45:39 -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=pJLO5YjH; 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 S229677AbiKEDBY (ORCPT + 99 others); Fri, 4 Nov 2022 23:01:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbiKEDBU (ORCPT ); Fri, 4 Nov 2022 23:01:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97ECA419BA; Fri, 4 Nov 2022 20:01:19 -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 3EA8662337; Sat, 5 Nov 2022 03:01:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A22A2C433D6; Sat, 5 Nov 2022 03:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667617278; bh=XWBTGLGkXGLU+mCSt2cLIm7GsobSKxeFBJJ1G4ny2WA=; h=From:To:Cc:Subject:Date:From; b=pJLO5YjHw8ouJzmGFDcAsrpsp5fV2ZA8bc1w6djo1w/vhlPhSrpQbjQ45ChpGJJoW bwxmk6QobTDpSPZZNSad6ROf9CQNd4cwqBRTsOGUsdxrkRBhc9uM1+W99JrnKa7HSO CJ4wU3dFKsOQBnBnkR+krZ80Hf9oUK9JlO6BKoQjWDH8Uld4Cmb8+FiMZNGvm0NALR emPaPy5yMGk80Yr7ni2DCXJGKi3JpnCWRXMgb8V2qSXE7uhq9XbNrXp+YIUyJjO5pj zy6f8tXRDN96sBIZXoylugFmJgFiCUEPigGeiSxNQ3IJtuZog2in38QUw6zlELMZSk GPuiDx4IRe3mw== From: "Masami Hiramatsu (Google)" To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Masami Hiramatsu , Steven Rostedt Subject: [PATCH] tools/perf: Fix to get the DW_AT_decl_file and DW_AT_call_file as unsinged data Date: Sat, 5 Nov 2022 12:01:14 +0900 Message-Id: <166761727445.480106.3738447577082071942.stgit@devnote3> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-8.1 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748626246359396596?= X-GMAIL-MSGID: =?utf-8?q?1748626246359396596?= From: Masami Hiramatsu (Google) Dwarf version 5 standard Sec 2.14 says that Any debugging information entry representing the declaration of an object, module, subprogram or type may have DW_AT_decl_file, DW_AT_decl_line and DW_AT_decl_column attributes, each of whose value is an unsigned integer constant. So it should be an unsigned integer data. Also, even though the standard doesn't clearly say the DW_AT_call_file is signed or unsigned, the elfutils (eu-readelf) interprets it as unsigned integer data and it is natural to handle it as unsigned integer data as same as DW_AT_decl_file. This changes the DW_AT_call_file as unsigned integer data too. Fixes: 3f4460a28fb2 ("perf probe: Filter out redundant inline-instances") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu (Google) Acked-by: Namhyung Kim --- tools/perf/util/dwarf-aux.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 30b36b525681..b07414409771 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -315,19 +315,6 @@ static int die_get_attr_udata(Dwarf_Die *tp_die, unsigned int attr_name, return 0; } -/* Get attribute and translate it as a sdata */ -static int die_get_attr_sdata(Dwarf_Die *tp_die, unsigned int attr_name, - Dwarf_Sword *result) -{ - Dwarf_Attribute attr; - - if (dwarf_attr_integrate(tp_die, attr_name, &attr) == NULL || - dwarf_formsdata(&attr, result) != 0) - return -ENOENT; - - return 0; -} - /** * die_is_signed_type - Check whether a type DIE is signed or not * @tp_die: a DIE of a type @@ -467,9 +454,9 @@ int die_get_data_member_location(Dwarf_Die *mb_die, Dwarf_Word *offs) /* Get the call file index number in CU DIE */ static int die_get_call_fileno(Dwarf_Die *in_die) { - Dwarf_Sword idx; + Dwarf_Word idx; - if (die_get_attr_sdata(in_die, DW_AT_call_file, &idx) == 0) + if (die_get_attr_udata(in_die, DW_AT_call_file, &idx) == 0) return (int)idx; else return -ENOENT; @@ -478,9 +465,9 @@ static int die_get_call_fileno(Dwarf_Die *in_die) /* Get the declared file index number in CU DIE */ static int die_get_decl_fileno(Dwarf_Die *pdie) { - Dwarf_Sword idx; + Dwarf_Word idx; - if (die_get_attr_sdata(pdie, DW_AT_decl_file, &idx) == 0) + if (die_get_attr_udata(pdie, DW_AT_decl_file, &idx) == 0) return (int)idx; else return -ENOENT;