Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13336358ybl; Sun, 29 Dec 2019 09:34:23 -0800 (PST) X-Google-Smtp-Source: APXvYqyO9hjAScMzM4PVdxOLsck9w6wA1iqJ/Mlk0+028RdZ9s/TEyNO8xWxHjI3Pe2qwGjSa2q9 X-Received: by 2002:a9d:4d86:: with SMTP id u6mr47060680otk.42.1577640863020; Sun, 29 Dec 2019 09:34:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577640863; cv=none; d=google.com; s=arc-20160816; b=KsMcu4jzp0ckQAlXCEH0wGEQjVrnVjJ5eZ5kAhCdTnasUUUW6lrLK4YIlVPA0/rsx0 BY5Zv7EbsHM7cBoX5nzZRIj6t2IAPFSQYxePCbwXigsN3+n5zNlh7KnmUG+qrfu3PTPU 9D5xvCE3H1N76xDK+1+5aJmBh1hwXRCmL6YinclXSzhiQCmRVj4CuZM/SuHfe3WGzQn9 TNmGAnwEUKpFJx7rN6pG4dKAD9w8vdMN+FT88gmc/gBTS3ECV5szJyyok1UlbzxNfppI isvHWupe1d5fQAESacu94zNzlIf6t7Wyr/u+BmDI207x66Geoh+s+XhgNi3W7DuVwJeV txOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Xhtt52qldjFy/9VNidjVwCCh1BXqr4hTthx0I3lf2q0=; b=jbEhxASzw+HJlTpSVLLpJonqx+++jL6HFkZ+mfNTMAsdHzhvAfzSl7Fzh7hdTdJzxr vjeBqfZaKvYnDCbbToCf8l6JJov4Pk5QUMrdi9nhn541QK878eIQVaxYSfAXrIhoGmVQ h5rQgPGM6EjHdf7zPLSKthlxi2paHjzJob0NHYKezIU81kHdFiuRFdN42wNwPuVfFPY7 popAqiEmb94AQ7I67fpGY9/5upV51Fs8v8IpVb/BnUk7vFZttKYs6DlYF9bKe59znxrM p228Ef8dRqHBDE71yfbfHATW0uOwuxf3Ii0Zm9zyaCCmMsc8hcPco702KeSodbXUwTyv WWuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="sGusZ/oW"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u21si21579542otq.137.2019.12.29.09.34.12; Sun, 29 Dec 2019 09:34:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="sGusZ/oW"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728864AbfL2RdI (ORCPT + 99 others); Sun, 29 Dec 2019 12:33:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:34304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729385AbfL2RdE (ORCPT ); Sun, 29 Dec 2019 12:33:04 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C9772207FF; Sun, 29 Dec 2019 17:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640784; bh=fk/bpJc3oyczkzYIq5bTkw4LdLXZn3tqEoE5eM/qZe4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sGusZ/oWdKiS9jn3XUpmS/IYF2IQ3TJe4BxQyiSW1hPC08J5coQo9lIcm9QwayL8G d8P/MP1rnSc+BkLsWQCvQ2RpS3LQZq5pq59C8dtXY20nYiz/R/5e1KRZVkby2eNOLZ y7/Ebd9+eJzJ2dXxb1B9Ax1i0jXrMZL+L8R/inl4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Arnaldo Carvalho de Melo , Namhyung Kim , Ravi Bangoria , "Steven Rostedt (VMware)" , Tom Zanussi , Sasha Levin Subject: [PATCH 4.19 138/219] perf probe: Return a better scope DIE if there is no best scope Date: Sun, 29 Dec 2019 18:19:00 +0100 Message-Id: <20191229162529.362736852@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162508.458551679@linuxfoundation.org> References: <20191229162508.458551679@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu [ Upstream commit c701636aeec4c173208697d68da6e4271125564b ] Make find_best_scope() returns innermost DIE at given address if there is no best matched scope DIE. Since Gcc sometimes generates intuitively strange line info which is out of inlined function address range, we need this fixup. Without this, sometimes perf probe failed to probe on a line inside an inlined function: # perf probe -D ksys_open:3 Failed to find scope of probe point. Error: Failed to add events. With this fix, 'perf probe' can probe it: # perf probe -D ksys_open:3 p:probe/ksys_open _text+25707308 p:probe/ksys_open_1 _text+25710596 p:probe/ksys_open_2 _text+25711114 p:probe/ksys_open_3 _text+25711343 p:probe/ksys_open_4 _text+25714058 p:probe/ksys_open_5 _text+2819653 p:probe/ksys_open_6 _text+2819701 Signed-off-by: Masami Hiramatsu Tested-by: Arnaldo Carvalho de Melo Cc: Namhyung Kim Cc: Ravi Bangoria Cc: Steven Rostedt (VMware) Cc: Tom Zanussi Link: http://lore.kernel.org/lkml/157291300887.19771.14936015360963292236.stgit@devnote2 Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/probe-finder.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 946b027b45e8..7ccabb891e5a 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -764,6 +764,16 @@ static int find_best_scope_cb(Dwarf_Die *fn_die, void *data) return 0; } +/* Return innermost DIE */ +static int find_inner_scope_cb(Dwarf_Die *fn_die, void *data) +{ + struct find_scope_param *fsp = data; + + memcpy(fsp->die_mem, fn_die, sizeof(Dwarf_Die)); + fsp->found = true; + return 1; +} + /* Find an appropriate scope fits to given conditions */ static Dwarf_Die *find_best_scope(struct probe_finder *pf, Dwarf_Die *die_mem) { @@ -775,8 +785,13 @@ static Dwarf_Die *find_best_scope(struct probe_finder *pf, Dwarf_Die *die_mem) .die_mem = die_mem, .found = false, }; + int ret; - cu_walk_functions_at(&pf->cu_die, pf->addr, find_best_scope_cb, &fsp); + ret = cu_walk_functions_at(&pf->cu_die, pf->addr, find_best_scope_cb, + &fsp); + if (!ret && !fsp.found) + cu_walk_functions_at(&pf->cu_die, pf->addr, + find_inner_scope_cb, &fsp); return fsp.found ? die_mem : NULL; } -- 2.20.1