Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1209339ybt; Thu, 9 Jul 2020 01:10:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz61x7RDqbwjnHD+JMvYGU2S5QNWuPcu6Js95jKMLO086qJB4xMryVC6LAIIwRtCHc5dImM X-Received: by 2002:a50:f392:: with SMTP id g18mr48045821edm.151.1594282203577; Thu, 09 Jul 2020 01:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594282203; cv=none; d=google.com; s=arc-20160816; b=QyB1nZLXNYIh35zDKv/6qvwcilZ+ekFREy24Xyqbj3zVCyHL5uNyGDzY+AUVaiXmIF j32yp0/IIRkeEzfTkQ2QqXGPBg8M5Go3DHZzE2JDALNR2xfVd5EhYTMZ/iXMPlE3bUjz qBdME/UQ/tvfBSKTI8/4I8VO3WR1yf/NIJtc9SmYhcWRAWTZE3LXichdpZs5IhC7GWHA iP7I5i6bd8syq3rbJ0OJhMPk21lL4XRusViZ89me/vK3cj+7ktkSJq+lkNyUUNXHMh6j Fd4tkjrGZuuY+IUgvJq5/2ZgLa9I8GKJEdHpUJ3L/2NvvQttYuxuV8ToVgxh/n/sePoe pPMw== 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=GcEePmr0X/DY6nntfyEiMQEQWcn6ByMolSI8OBQmgiY=; b=YenE0kezHDZ4U9okIL/Ywklgdp3quwHJxVvQK5jDhguif/FHWAaNEK0kc6cAI1ELsM urDqtXkSi8ecnuf6eFxC0qJTpFyF2AVwk7Feplusdc4OCnYYyBd6uXCKDjAwYdMd41Nd fNegnxe6SL3pXfgOZ2tUzggjDqQzfdg2U8LQrafTJpwCBg+JxPlKCpVCZvYIOvesacWp EQDfgvCwMVCymtEtAi4yZ2VXbXssTAuIYOYAsbc/4DThXdsJDHeSEGJcfFD5p3tHwgVX p9F5EzYR7r+kyEqUDSEgbDs5ynJFr5gI/UnM70OuEZBs0CNYN8iboWAlohtKD6kIW6v7 Qmrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YhL9QPAC; 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 qh22si1381341ejb.553.2020.07.09.01.09.41; Thu, 09 Jul 2020 01:10:03 -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=default header.b=YhL9QPAC; 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 S1726319AbgGIIHR (ORCPT + 99 others); Thu, 9 Jul 2020 04:07:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:58570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726139AbgGIIHR (ORCPT ); Thu, 9 Jul 2020 04:07:17 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 96C8720720; Thu, 9 Jul 2020 08:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594282036; bh=uuIItKbVy/ksvMT/I7W0t4Mekqy5bWcYvM2MBH5LKig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YhL9QPACO1f/+mRvgP5tGHS6fQfp1FickFwiz01aQaiuLz0CNwr4rGVEEWMTR5lTx v/sj4pgBae4mPAoATIZhy8oiB4Us6mYUBS9gCQyk0SBLoeJe0czvOxLsS+kDeexm1O juMD6vxhNw9XVyusGQSYHMfv7REgtiRR91/HdbUM= From: Masami Hiramatsu To: Arnaldo Carvalho de Melo , Arnaldo Carvalho de Melo Cc: Oleg Nesterov , Srikar Dronamraju , linux-kernel@vger.kernel.org, mhiramat@kernel.org, Andi Kleen , Andi Kleen Subject: [PATCH 2/4] perf-probe: Fix wrong variable warning when the probe point is not found Date: Thu, 9 Jul 2020 17:07:12 +0900 Message-Id: <159428203219.56570.8289435784233418736.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <159428201109.56570.3802208017109058146.stgit@devnote2> References: <159428201109.56570.3802208017109058146.stgit@devnote2> User-Agent: StGit/0.19 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 Fix a wrong "variable not found" warning when the probe point is not found in the debuginfo. Since the debuginfo__find_probes() can return 0 even if it does not find given probe point in the debuginfo, fill_empty_trace_arg() can be called with tf.ntevs == 0 and it can warn a wrong warning. To fix this, reject ntevs == 0 in fill_empty_trace_arg(). E.g. without this patch; # perf probe -x /lib64/libc-2.30.so -a "memcpy arg1=%di" Failed to find the location of the '%di' variable at this address. Perhaps it has been optimized out. Use -V with the --range option to show '%di' location range. Added new events: probe_libc:memcpy (on memcpy in /usr/lib64/libc-2.30.so with arg1=%di) probe_libc:memcpy (on memcpy in /usr/lib64/libc-2.30.so with arg1=%di) You can now use it in all perf tools, such as: perf record -e probe_libc:memcpy -aR sleep 1 With this; # perf probe -x /lib64/libc-2.30.so -a "memcpy arg1=%di" Added new events: probe_libc:memcpy (on memcpy in /usr/lib64/libc-2.30.so with arg1=%di) probe_libc:memcpy (on memcpy in /usr/lib64/libc-2.30.so with arg1=%di) You can now use it in all perf tools, such as: perf record -e probe_libc:memcpy -aR sleep 1 Reported-by: Andi Kleen Fixes: cb4027308570 ("perf probe: Trace a magic number if variable is not found") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu --- tools/perf/util/probe-finder.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 55924255c535..9963e4e8ea20 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -1408,6 +1408,9 @@ static int fill_empty_trace_arg(struct perf_probe_event *pev, char *type; int i, j, ret; + if (!ntevs) + return -ENOENT; + for (i = 0; i < pev->nargs; i++) { type = NULL; for (j = 0; j < ntevs; j++) {