From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99C9EC04AAF for ; Sat, 18 May 2019 09:13:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 614E720848 for ; Sat, 18 May 2019 09:13:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b="RXxvKxRE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729736AbfERJNg (ORCPT ); Sat, 18 May 2019 05:13:36 -0400 Received: from terminus.zytor.com ([198.137.202.136]:39869 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbfERJNg (ORCPT ); Sat, 18 May 2019 05:13:36 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x4I9DCm11737536 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 18 May 2019 02:13:12 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x4I9DCm11737536 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019041745; t=1558170793; bh=EZREwiiEtVIvqGcJAVBAq0v3MlB0lCjT9hNcbGN29i0=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=RXxvKxREe34Qxjqf50IazK99kyYTP4PwTkjYcPmYE7PVftrUrVQc7hyRUcG8g/Cpy +I0o8TMLW/3jaO9vfqCJbIaryMWjTleJ5L598IDUcbPBMaLobAetfQYjDlddN/aUxI 7hTXyVrngPb2Zcm7Towq6gYctOQ9xjOCEvKOOMSIbM5kWHYs/nCaDwasbaM5LvlhvM H5APGaX4z9oSMzT7q7yiGii9xFJFI3lkE/HU42UV3Jx6Ud2ea4v3GvvuUWh35WbAo+ 5epKIgPo2ime7n/HWhATClI0LcSkE3miOUyXW6PA8urL9rOXzwY0QeEzpEW1JiUDf4 xHXtTwYafk2qQ== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x4I9DBeU1737533; Sat, 18 May 2019 02:13:11 -0700 Date: Sat, 18 May 2019 02:13:11 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Tzvetomir Stoyanov Message-ID: Cc: akpm@linux-foundation.org, tglx@linutronix.de, namhyung@kernel.org, rostedt@goodmis.org, jolsa@redhat.com, tstoyanov@vmware.com, linux-kernel@vger.kernel.org, acme@redhat.com, hpa@zytor.com, mingo@kernel.org Reply-To: tglx@linutronix.de, akpm@linux-foundation.org, namhyung@kernel.org, hpa@zytor.com, acme@redhat.com, mingo@kernel.org, tstoyanov@vmware.com, jolsa@redhat.com, rostedt@goodmis.org, linux-kernel@vger.kernel.org In-Reply-To: <20190510200109.054708419@goodmis.org> References: <20190510200109.054708419@goodmis.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] tools lib traceevent: Man pages for print field APIs Git-Commit-ID: 6dfe6849b6ee69975eb82181e0afb03fbd8b578f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 6dfe6849b6ee69975eb82181e0afb03fbd8b578f Gitweb: https://git.kernel.org/tip/6dfe6849b6ee69975eb82181e0afb03fbd8b578f Author: Tzvetomir Stoyanov AuthorDate: Fri, 10 May 2019 15:56:26 -0400 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 15 May 2019 16:36:48 -0300 tools lib traceevent: Man pages for print field APIs Create man pages for libtraceevent APIs: tep_print_field(), tep_print_fields(), tep_print_num_field(), tep_print_func_field() Signed-off-by: Tzvetomir Stoyanov Cc: Andrew Morton Cc: Jiri Olsa Cc: Namhyung Kim Cc: linux-trace-devel@vger.kernel.org Link: http://lore.kernel.org/linux-trace-devel/20190503091119.23399-20-tstoyanov@vmware.com Link: http://lkml.kernel.org/r/20190510200109.054708419@goodmis.org Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Arnaldo Carvalho de Melo --- .../Documentation/libtraceevent-field_print.txt | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/tools/lib/traceevent/Documentation/libtraceevent-field_print.txt b/tools/lib/traceevent/Documentation/libtraceevent-field_print.txt new file mode 100644 index 000000000000..9a9df98ac44d --- /dev/null +++ b/tools/lib/traceevent/Documentation/libtraceevent-field_print.txt @@ -0,0 +1,126 @@ +libtraceevent(3) +================ + +NAME +---- +tep_print_field, tep_print_fields, tep_print_num_field, tep_print_func_field - +Print the field content. + +SYNOPSIS +-------- +[verse] +-- +*#include * +*#include * + +void *tep_print_field*(struct trace_seq pass:[*]_s_, void pass:[*]_data_, struct tep_format_field pass:[*]_field_); +void *tep_print_fields*(struct trace_seq pass:[*]_s_, void pass:[*]_data_, int _size_, struct tep_event pass:[*]_event_); +int *tep_print_num_field*(struct trace_seq pass:[*]_s_, const char pass:[*]_fmt_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, int _err_); +int *tep_print_func_field*(struct trace_seq pass:[*]_s_, const char pass:[*]_fmt_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, int _err_); +-- + +DESCRIPTION +----------- +These functions print recorded field's data, according to the field's type. + +The _tep_print_field()_ function extracts from the recorded raw _data_ value of +the _field_ and prints it into _s_, according to the field type. + +The _tep_print_fields()_ prints each field name followed by the record's field +value according to the field's type: +[verse] +-- +"field1_name=field1_value field2_name=field2_value ..." +-- +It iterates all fields of the _event_, and calls _tep_print_field()_ for each of +them. + +The _tep_print_num_field()_ function prints a numeric field with given format +string. A search is performed in the _event_ for a field with _name_. If such +field is found, its value is extracted from the _record_ and is printed in the +_s_, according to the given format string _fmt_. If the argument _err_ is +non-zero, and an error occures - it is printed in the _s_. + +The _tep_print_func_field()_ function prints a function field with given format +string. A search is performed in the _event_ for a field with _name_. If such +field is found, its value is extracted from the _record_. The value is assumed +to be a function address, and a search is perform to find the name of this +function. The function name (if found) and its address are printed in the _s_, +according to the given format string _fmt_. If the argument _err_ is non-zero, +and an error occures - it is printed in _s_. + +RETURN VALUE +------------ +The _tep_print_num_field()_ and _tep_print_func_field()_ functions return 1 +on success, -1 in case of an error or 0 if the print buffer _s_ is full. + +EXAMPLE +------- +[source,c] +-- +#include +#include +... +struct tep_handle *tep = tep_alloc(); +... +struct trace_seq seq; +trace_seq_init(&seq); +struct tep_event *event = tep_find_event_by_name(tep, "timer", "hrtimer_start"); +... +void process_record(struct tep_record *record) +{ + struct tep_format_field *field_pid = tep_find_common_field(event, "common_pid"); + + trace_seq_reset(&seq); + + /* Print the value of "common_pid" */ + tep_print_field(&seq, record->data, field_pid); + + /* Print all fields of the "hrtimer_start" event */ + tep_print_fields(&seq, record->data, record->size, event); + + /* Print the value of "expires" field with custom format string */ + tep_print_num_field(&seq, " timer expires in %llu ", event, "expires", record, 0); + + /* Print the address and the name of "function" field with custom format string */ + tep_print_func_field(&seq, " timer function is %s ", event, "function", record, 0); + } + ... +-- + +FILES +----- +[verse] +-- +*event-parse.h* + Header file to include in order to have access to the library APIs. +*trace-seq.h* + Header file to include in order to have access to trace sequences related APIs. + Trace sequences are used to allow a function to call several other functions + to create a string of data to use. +*-ltraceevent* + Linker switch to add when building a program that uses the library. +-- + +SEE ALSO +-------- +_libtraceevent(3)_, _trace-cmd(1)_ + +AUTHOR +------ +[verse] +-- +*Steven Rostedt* , author of *libtraceevent*. +*Tzvetomir Stoyanov* , author of this man page. +-- +REPORTING BUGS +-------------- +Report bugs to + +LICENSE +------- +libtraceevent is Free Software licensed under the GNU LGPL 2.1 + +RESOURCES +--------- +https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git