Received: by 10.223.185.116 with SMTP id b49csp1480631wrg; Fri, 16 Feb 2018 21:52:14 -0800 (PST) X-Google-Smtp-Source: AH8x225oT0gYdf2y9DmMCl5OUiJhcgxL8x4/BrVGZsyt67s9mra8mpWqexKFsei6CYy/YZijoFBa X-Received: by 2002:a17:902:f83:: with SMTP id 3-v6mr8027997plz.287.1518846734318; Fri, 16 Feb 2018 21:52:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518846734; cv=none; d=google.com; s=arc-20160816; b=JU7dF7uq62kU4uyN4pLwWz9c4Dnwc/Y5BS+Nn7+Rt5HV4IOxslp8onEanZx1HMqevc HgFMQxT7Y3i9/GmXHGtMIh3tehnbyMPz7LmB3N72Sgl5+0zHo7uKVj5L7ru+qKSCzp5n QJDiCl55JWNMT3ZkvMU2YuXV6SUj3trF3edO/m00Oi2AN2JcPEaRmWG992wHTGpZaTMg Yov02zO6hUzJGErShKuOse/IldB9K99xi2LqHU3Zf+L4PBdvhMLSTA4n77Ef6FDMA3Jp aVUSEPOMtbHdKmumSDNoOntAhNYVbUoUxGdydxUjjGqnMkD0r1XsCmJFGJNn/bCHVNcy xgGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=xw5V/L6ahZ/zIkKmxxqXAZtuCaYs7cOoiiUBTu9VnAk=; b=KZbatt29SLWhAIr75H2xDjTdEix4Zl6qWdCNIEJmckoO/NerIhiMtEXZ/eYzML1VJo DE8zj1TR4CFgDPKt1VxCi3Lh70K2tI9xDzVFqVpMjioltkk/rkOkl5COezbBQX9uR2Su hA4aGOAu4unL06UNJfvhLQ49xGYTDxneUW6T0w4zrhjEib6Ydvxzrv7Xr3bT2qg1ZjRk +TZvqQfmbuI13hnpdp/kY5968NMDz8XOFL7otcxsf3dfzsFiIh54n/qdt5kvIAjZ9TH5 tLGZBLRhgYQnaKFDdYh+gCxOTnsf8s2S73cecccLiUjD9DANkhjYWArzHYgkIjRUqbxl DPsA== ARC-Authentication-Results: i=1; mx.google.com; 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 l64si2379841pfi.388.2018.02.16.21.51.49; Fri, 16 Feb 2018 21:52:14 -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; 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 S1751213AbeBQFtZ (ORCPT + 99 others); Sat, 17 Feb 2018 00:49:25 -0500 Received: from mga18.intel.com ([134.134.136.126]:1059 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751132AbeBQFtL (ORCPT ); Sat, 17 Feb 2018 00:49:11 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Feb 2018 21:49:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,523,1511856000"; d="scan'208";a="20863353" Received: from gvt-dell.bj.intel.com (HELO gvt-dell-host.bj.intel.com) ([10.238.154.59]) by fmsmga002.fm.intel.com with ESMTP; 16 Feb 2018 21:49:09 -0800 From: changbin.du@intel.com To: corbet@lwn.net, rostedt@goodmis.org Cc: mingo@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Changbin Du Subject: [PATCH 07/17] trace doc: convert trace/uprobetracer.txt to rst format Date: Sat, 17 Feb 2018 13:39:40 +0800 Message-Id: <1518845990-20733-8-git-send-email-changbin.du@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518845990-20733-1-git-send-email-changbin.du@intel.com> References: <1518845990-20733-1-git-send-email-changbin.du@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Changbin Du This converts the plain text documentation to reStructuredText format and add it into Sphinx TOC tree. No essential content change. Cc: Steven Rostedt Signed-off-by: Changbin Du --- Documentation/trace/index.rst | 1 + .../trace/{uprobetracer.txt => uprobetracer.rst} | 44 +++++++++++++--------- 2 files changed, 27 insertions(+), 18 deletions(-) rename Documentation/trace/{uprobetracer.txt => uprobetracer.rst} (86%) diff --git a/Documentation/trace/index.rst b/Documentation/trace/index.rst index c8e2130..353fb8a 100644 --- a/Documentation/trace/index.rst +++ b/Documentation/trace/index.rst @@ -10,3 +10,4 @@ Linux Tracing Technologies ftrace ftrace-uses kprobetrace + uprobetracer diff --git a/Documentation/trace/uprobetracer.txt b/Documentation/trace/uprobetracer.rst similarity index 86% rename from Documentation/trace/uprobetracer.txt rename to Documentation/trace/uprobetracer.rst index bf526a7c..98d3f69 100644 --- a/Documentation/trace/uprobetracer.txt +++ b/Documentation/trace/uprobetracer.rst @@ -1,7 +1,8 @@ - Uprobe-tracer: Uprobe-based Event Tracing - ========================================= +========================================= +Uprobe-tracer: Uprobe-based Event Tracing +========================================= - Documentation written by Srikar Dronamraju +:Author: Srikar Dronamraju Overview @@ -19,6 +20,8 @@ user to calculate the offset of the probepoint in the object. Synopsis of uprobe_tracer ------------------------- +:: + p[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] : Set a uprobe r[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] : Set a return uprobe (uretprobe) -:[GRP/]EVENT : Clear uprobe or uretprobe event @@ -57,7 +60,7 @@ x86-64 uses x64). String type is a special type, which fetches a "null-terminated" string from user space. Bitfield is another special type, which takes 3 parameters, bit-width, bit- -offset, and container-size (usually 32). The syntax is; +offset, and container-size (usually 32). The syntax is:: b@/ @@ -74,28 +77,28 @@ the third is the number of probe miss-hits. Usage examples -------------- * Add a probe as a new uprobe event, write a new definition to uprobe_events -as below: (sets a uprobe at an offset of 0x4245c0 in the executable /bin/bash) + as below (sets a uprobe at an offset of 0x4245c0 in the executable /bin/bash):: echo 'p /bin/bash:0x4245c0' > /sys/kernel/debug/tracing/uprobe_events - * Add a probe as a new uretprobe event: + * Add a probe as a new uretprobe event:: echo 'r /bin/bash:0x4245c0' > /sys/kernel/debug/tracing/uprobe_events - * Unset registered event: + * Unset registered event:: echo '-:p_bash_0x4245c0' >> /sys/kernel/debug/tracing/uprobe_events - * Print out the events that are registered: + * Print out the events that are registered:: cat /sys/kernel/debug/tracing/uprobe_events - * Clear all events: + * Clear all events:: echo > /sys/kernel/debug/tracing/uprobe_events Following example shows how to dump the instruction pointer and %ax register -at the probed text address. Probe zfree function in /bin/zsh: +at the probed text address. Probe zfree function in /bin/zsh:: # cd /sys/kernel/debug/tracing/ # cat /proc/`pgrep zsh`/maps | grep /bin/zsh | grep r-xp @@ -103,24 +106,27 @@ at the probed text address. Probe zfree function in /bin/zsh: # objdump -T /bin/zsh | grep -w zfree 0000000000446420 g DF .text 0000000000000012 Base zfree - 0x46420 is the offset of zfree in object /bin/zsh that is loaded at - 0x00400000. Hence the command to uprobe would be: +0x46420 is the offset of zfree in object /bin/zsh that is loaded at +0x00400000. Hence the command to uprobe would be:: # echo 'p:zfree_entry /bin/zsh:0x46420 %ip %ax' > uprobe_events - And the same for the uretprobe would be: +And the same for the uretprobe would be:: # echo 'r:zfree_exit /bin/zsh:0x46420 %ip %ax' >> uprobe_events -Please note: User has to explicitly calculate the offset of the probe-point -in the object. We can see the events that are registered by looking at the -uprobe_events file. +.. note:: User has to explicitly calculate the offset of the probe-point + in the object. + +We can see the events that are registered by looking at the uprobe_events file. +:: # cat uprobe_events p:uprobes/zfree_entry /bin/zsh:0x00046420 arg1=%ip arg2=%ax r:uprobes/zfree_exit /bin/zsh:0x00046420 arg1=%ip arg2=%ax -Format of events can be seen by viewing the file events/uprobes/zfree_entry/format +Format of events can be seen by viewing the file events/uprobes/zfree_entry/format. +:: # cat events/uprobes/zfree_entry/format name: zfree_entry @@ -139,16 +145,18 @@ Format of events can be seen by viewing the file events/uprobes/zfree_entry/form print fmt: "(%lx) arg1=%lx arg2=%lx", REC->__probe_ip, REC->arg1, REC->arg2 Right after definition, each event is disabled by default. For tracing these -events, you need to enable it by: +events, you need to enable it by:: # echo 1 > events/uprobes/enable Lets disable the event after sleeping for some time. +:: # sleep 20 # echo 0 > events/uprobes/enable And you can see the traced information via /sys/kernel/debug/tracing/trace. +:: # cat trace # tracer: nop -- 2.7.4