From patchwork Thu Sep 10 08:55:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 11767157 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87B09618 for ; Thu, 10 Sep 2020 08:58:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65CD820770 for ; Thu, 10 Sep 2020 08:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728281; bh=Usei1xLmvGf2Y8buCZXpy+oUTxiyFNSfzZeT9ewnigs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ihi5zXRC+5IZIMnMbp+18U+NLsBw3AULVCIEoxXFqeVvf491lZFU3sFmh+Xt1ISbd cAzebT6PMyldFQufQNbW06Bt74F9oWmzttmrsB7pcWppP1x2D+tnzjjZJYN61Rpjou JJNNbwj4SASEhMb2JwlKfvB+u/WpCh5X9bxeGchE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730277AbgIJI5w (ORCPT ); Thu, 10 Sep 2020 04:57:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:37146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730268AbgIJIzv (ORCPT ); Thu, 10 Sep 2020 04:55:51 -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 C41522078B; Thu, 10 Sep 2020 08:55:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728150; bh=Usei1xLmvGf2Y8buCZXpy+oUTxiyFNSfzZeT9ewnigs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zgr7WfK9sDVeejvY78RJ+pkCDQOwSqegfMelvnN8fNrZSf6ipnffv0ANSDHqOxXsx Pdz2qRQMHMOM4t3Zg5CpBQjuYTw9VUhBVy6WgtNYLSd/tsVHVU/PHmbWURNMIOmqw3 CoYroNdbbR2ZmyBRbbnOoToIW/NjvFY2wzLaJakQ= From: Masami Hiramatsu To: Steven Rostedt , Jonathan Corbet , Shuah Khan Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Randy Dunlap , Ingo Molnar , linux-kselftest@vger.kernel.org Subject: [PATCH v3 5/8] tracing/uprobes: Support perf-style return probe Date: Thu, 10 Sep 2020 17:55:46 +0900 Message-Id: <159972814601.428528.7641183316212425445.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <159972809455.428528.4737752126800169128.stgit@devnote2> References: <159972809455.428528.4737752126800169128.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Support perf-style return probe ("SYMBOL%return") for uprobe events as same as kprobe events does. Signed-off-by: Masami Hiramatsu --- kernel/trace/trace.c | 2 +- kernel/trace/trace_uprobe.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 2c8c8f7ddef7..faf55f5dd99d 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -5125,7 +5125,7 @@ static const char readme_msg[] = "place (kretprobe): [:][+]%return|\n" #endif #ifdef CONFIG_UPROBE_EVENTS - " place (uprobe): :[(ref_ctr_offset)]\n" + " place (uprobe): :[%return][(ref_ctr_offset)]\n" #endif "\t args: =fetcharg[:type]\n" "\t fetcharg: %, @
, @[+|-],\n" diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index f4286c9bdeb4..fb5ec4e55484 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c @@ -528,7 +528,7 @@ static int register_trace_uprobe(struct trace_uprobe *tu) /* * Argument syntax: - * - Add uprobe: p|r[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] + * - Add uprobe: p|r[:[GRP/]EVENT] PATH:OFFSET[%return][(REF)] [FETCHARGS] */ static int trace_uprobe_create(int argc, const char **argv) { @@ -617,6 +617,19 @@ static int trace_uprobe_create(int argc, const char **argv) } } + /* Check if there is %return suffix */ + tmp = strchr(arg, '%'); + if (tmp) { + if (!strcmp(tmp, "%return")) { + *tmp = '\0'; + is_return = true; + } else { + trace_probe_log_err(tmp - filename, BAD_ADDR_SUFFIX); + ret = -EINVAL; + goto fail_address_parse; + } + } + /* Parse uprobe offset. */ ret = kstrtoul(arg, 0, &offset); if (ret) {