Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13470494ybl; Sun, 29 Dec 2019 12:40:26 -0800 (PST) X-Google-Smtp-Source: APXvYqyasZiqOiKMmuVFDXXb5M4VmpgqLTnD1yZUu5heLu8cg3z8G44RteFYK1k3e6Gqm+6zNP40 X-Received: by 2002:a9d:7e8a:: with SMTP id m10mr66886756otp.27.1577652026746; Sun, 29 Dec 2019 12:40:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652026; cv=none; d=google.com; s=arc-20160816; b=DC+FyO1tVXfnZ5OMIHeJUcgy11ArEaM08YrVYl25cV1GV8LH0ud6xpC5AQ94bfRQvA rhxnYJm9WymJF2fPFMoLDvpVJQSRLu9ylwhVD1NrJyAQlHPih/20eTR+nbAlCzNtWLmH qoCdRpQ060J7T2mMEL8Mfs0f3SAjXSN+X1NckE+aeHaJ+YYNhCb5JFMgV1ngMSSQmuy8 4xjxYIp9RF3tZKMBK/XpUYVH2F3qwotLLLOe6esMRMwcKKkYzEK+bMpb+tgJhbPi2RdD 6yDGgEGZwCZLWVNNvwHDE3f/EeMvb9+U+exxD+lCoovxTLJd7J0xLCYYE6xktoSi1Q+k epzg== 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=ZcRHrxijZlGurE7N2EmrAjj199qWn6BSe77ys5S6wGk=; b=LpldGh7poq0gPLYQE4OmsWkx0Nt7im65+nYt38ToFJRovQd2oBJoQ/I3D/pudyRh16 LV4h3o5b5KHxRQRfXVTZiL6I/G1Ylgt9mIoTIrwCZF4XuCe1lcWDViHLjVVBxjQ/I/IT ixelXrMlH9lSqlKYV7sHSvXbUGBtkXkz2v9I6jy6kealMcE7uYMitvgpSX9zmztwIHQL p5SvMm1PpyjUYRuhzKv/8DY4ONxAbO6Sz9SbisZlNpvCw9i2wQoozcmJQ1nn1GZwCtMh FEyr6Uyl6o9Jr249XB6imPvPx2iFkBZSJ7mXzjEx2xNANVJU2dspTJG1UFZNAfpoGcKy /mbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cRCxHrjv; 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 m4si22314257otn.281.2019.12.29.12.40.15; Sun, 29 Dec 2019 12:40:26 -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=cRCxHrjv; 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 S1730014AbfL2Rjo (ORCPT + 99 others); Sun, 29 Dec 2019 12:39:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:33420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729132AbfL2Rcn (ORCPT ); Sun, 29 Dec 2019 12:32:43 -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 138E320409; Sun, 29 Dec 2019 17:32:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640762; bh=2jOFA/EcI9XpLsFOShqa+RuEEn1vjHh6cnG2QZFxjhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cRCxHrjv1KeHxSbYpA2OI8YP+RpDa9K6lP+JcRYsjd4djcbaP8gWGyk6hfISPbPCq pwNuVUbE1wHbJpyvsPnQThjii2QvZO3MSjVcQIBoD2+mQoeBhLeYmx9Yek1F2K55Ey MY+Jc+2mOsEyUXEI9Gd9PtC5VMcR4/4HhyDXMUVY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Jiri Olsa , Namhyung Kim , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.19 126/219] perf probe: Walk function lines in lexical blocks Date: Sun, 29 Dec 2019 18:18:48 +0100 Message-Id: <20191229162527.445057256@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 acb6a7047ac2146b723fef69ee1ab6b7143546bf ] Since some inlined functions are in lexical blocks of given function, we have to recursively walk through the DIE tree. Without this fix, perf-probe -L can miss the inlined functions which is in a lexical block (like if (..) { func() } case.) However, even though, to walk the lines in a given function, we don't need to follow the children DIE of inlined functions because those do not have any lines in the specified function. We need to walk though whole trees only if we walk all lines in a given file, because an inlined function can include another inlined function in the same file. Fixes: b0e9cb2802d4 ("perf probe: Fix to search nested inlined functions in CU") Signed-off-by: Masami Hiramatsu Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lore.kernel.org/lkml/157190836514.1859.15996864849678136353.stgit@devnote2 Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/dwarf-aux.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 5bbb87f63ecb..6e7cb3537ce0 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -691,10 +691,9 @@ static int __die_walk_funclines_cb(Dwarf_Die *in_die, void *data) if (lw->retval != 0) return DIE_FIND_CB_END; } + if (!lw->recursive) + return DIE_FIND_CB_SIBLING; } - if (!lw->recursive) - /* Don't need to search recursively */ - return DIE_FIND_CB_SIBLING; if (addr) { fname = dwarf_decl_file(in_die); @@ -741,6 +740,10 @@ static int __die_walk_culines_cb(Dwarf_Die *sp_die, void *data) { struct __line_walk_param *lw = data; + /* + * Since inlined function can include another inlined function in + * the same file, we need to walk in it recursively. + */ lw->retval = __die_walk_funclines(sp_die, true, lw->callback, lw->data); if (lw->retval != 0) return DWARF_CB_ABORT; @@ -830,8 +833,9 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data) */ if (rt_die != cu_die) /* - * Don't need walk functions recursively, because nested - * inlined functions don't have lines of the specified DIE. + * Don't need walk inlined functions recursively, because + * inner inlined functions don't have the lines of the + * specified function. */ ret = __die_walk_funclines(rt_die, false, callback, data); else { -- 2.20.1