Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2434171pxv; Sat, 3 Jul 2021 08:36:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCb/+fpUtv8kw3BaclqMf6+DaGXTNRWCup1XKNSXznJwMMP8AKVa3IlLEbPReWavzOXy/w X-Received: by 2002:a17:906:144e:: with SMTP id q14mr5303083ejc.19.1625326608054; Sat, 03 Jul 2021 08:36:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625326608; cv=none; d=google.com; s=arc-20160816; b=z3cw0MG/gi+MJ9xMHkstHcYrVjlKfW8GDgJ20D0wcau/ALkovlIvBpFbE/eDiJIIQU xEqSAhrECPl+BJg4v6JB5EzzgploaD3QJo78iiJLucW+sT3ooRtUes9tyGaJiCUUr8D9 9lCpxGN8jrL8lmPbx5tqWe9DYDxB5XNMir0/40czQdvECas3qjcFvYIyf5L+lFmC/YvS z8/FTf1JZ/dWZkrAjUupJhe5J+o3uPHFxMOMe1twNuaQO0Of1qW8HkLrv80aSWxmi2I/ CDurVHdyt1ELRLCBQJm+DXzzNN4Xw724AvReQfj79g62H+hk/mKg7N0vxasQhqXTrDFD skMg== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=s21EMw4BcuLGu5kneCSV4x5XMFKUqPtU77zMb2YqhaM=; b=PAvO5LhRhg6oPYu9P3CoCZmEWZZfEK03UYMNWY5s9UbO69MHH+4nb2r4goRaLE687V 5MKH1xbdPtyX4+1lvoXgweLfFNSkeECCIYGCZwCvKnVepZ+DFJgoP2QFe3z+DC/KCSd0 9pV/C/3KbL9csr7PoA0RlLggr2Au7O8OuTT1kO3wXR4MGmonM0/nyE8XZn5gyW0vHI1R MQGa047GztCSQOLkbd/A1vyEP6qhb4Xtv7qsxl/OIvN9pMZmo3Cq0C8xoZ6jxBRpjvC4 BQNfsDYJFg90jVYoCVtV6qlNJZ4HtJYLzrmeJIrBdxPMK29o2AODdJfD9jx9O6uvwsQK HceQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u6Uo402u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y8si7135171edw.54.2021.07.03.08.36.25; Sat, 03 Jul 2021 08:36:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u6Uo402u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230001AbhGCPh6 (ORCPT + 99 others); Sat, 3 Jul 2021 11:37:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:35966 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbhGCPhz (ORCPT ); Sat, 3 Jul 2021 11:37:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 477DA6161E; Sat, 3 Jul 2021 15:35:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625326521; bh=v12eb72egTXGRlWePIt6/447N/jAOeFwRe4l3/n4s4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u6Uo402ut0NQfNvNx3Kkb/41rXOyumsg8PmLzOXxidW+RD87QOi2JRkZ/iZjbW4WL KZqwpupmAfS7ymtzKUbyLiwuib5BfBixecE5qapTXxAHrdEgD6ukzwPP1j0zyi44ZN LACa0oW8PPY6Kki6Y7n+T97p0zw4jHzJK4dzAlN0RVuaV7qa7qSICW34xkFt1qd4P9 twypupb2S/w76YyaLvlq9Xaa43/1QCHTX8eJHPX66OWV7+woWTahoKfWLO2128S6tM zQZ5cO9f1lXdT6sp5UVvNkyMsaUg/QHMgxXvA3GUJNAzt/be+SmRDkFLz6Qy0+Ga/B STNyM5UPXAlmA== From: Masami Hiramatsu To: Arnaldo Carvalho de Melo Cc: linux-perf-users@vger.kernel.org, Masami Hiramatsu , Sven Schnelle , Heiko Carstens , Stefan Liebler , Thomas Richter , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] perf-probe: Fix debuginfo__new() to enable build-id based debuginfo Date: Sun, 4 Jul 2021 00:35:18 +0900 Message-Id: <162532651863.393143.11692691321219235810.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <162532651032.393143.4602033845482295575.stgit@devnote2> References: <162532651032.393143.4602033845482295575.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu Fix debuginfo__new() to set the build-id to dso before dso__read_binary_type_filename() so that it can find DSO_BINARY_TYPE__BUILDID_DEBUGINFO debuginfo correctly. However, this may not change the result, because elfutils (libdwfl) has its own debuginfo finder. With/without this patch, the perf probe correctly find the debuginfo file. This is just a failsafe and keep code's sanity (if you use dso__read_binary_type_filename(), you must set the build-id to the dso.) Reported-by: Thomas Richter Signed-off-by: Masami Hiramatsu --- tools/perf/util/probe-finder.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index b029c29ce227..02ef0d78053b 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -118,12 +118,17 @@ struct debuginfo *debuginfo__new(const char *path) char buf[PATH_MAX], nil = '\0'; struct dso *dso; struct debuginfo *dinfo = NULL; + struct build_id bid; /* Try to open distro debuginfo files */ dso = dso__new(path); if (!dso) goto out; + /* Set the build id for DSO_BINARY_TYPE__BUILDID_DEBUGINFO */ + if (is_regular_file(path) && filename__read_build_id(path, &bid) > 0) + dso__set_build_id(dso, &bid); + for (type = distro_dwarf_types; !dinfo && *type != DSO_BINARY_TYPE__NOT_FOUND; type++) {