From patchwork Fri Mar 8 13:36:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10844799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A067417E9 for ; Fri, 8 Mar 2019 13:37:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D5CC2E40A for ; Fri, 8 Mar 2019 13:37:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81F892E440; Fri, 8 Mar 2019 13:37:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03AB32E40A for ; Fri, 8 Mar 2019 13:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726721AbfCHNhV (ORCPT ); Fri, 8 Mar 2019 08:37:21 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33258 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726680AbfCHNhV (ORCPT ); Fri, 8 Mar 2019 08:37:21 -0500 Received: by mail-wr1-f66.google.com with SMTP id i12so21393973wrw.0 for ; Fri, 08 Mar 2019 05:37:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2WcUNq91Sa+L9JNqxAv6wVI1ERPpxmfxrgVkMMg/soc=; b=hc322iya/nToF8gwoJS9ajIQwsZJI1OuUiGsEdeDjN7esOKYxNvIZgDCqHhqzjnLgO supJDwKGtVnjLj54FZykS0BQP2NUKFxBGG+eQlde/MTxEgijFIfn8uOx/7UVBHmyVp1H wI31szS8CPHM0yCaP4Jgoenz+OUQMeufnW1cnXRGohvsrkOnsxvlWshqztTc2eGvw/c9 MToIBKexLtdRHO0l2m9YNH+a6uSYwTFrAIcprF40xz3JGfp6qNUsDMEvBz0qLAk/y6J8 z8QNbDZ+zMV4JUm37QK4EmWUyGkjQATxYl8ZVclbMc7UHAjEu9mpmHiChtmaFcP368Cj f4vw== X-Gm-Message-State: APjAAAVxYVSOtMO1s+bfC8e7AvuIdiWLYchlEOzpm5LGoeP7IIHaF1mN kXtNn9YMWBGUxfuuc+KLOfE= X-Google-Smtp-Source: APXvYqx3xGg4fwPVZPndJ3IDaTio9ntxbx+A4he4TYytk4hlkFnalrQx1c/iBdbdt3zIa0KXaa6Ntw== X-Received: by 2002:a5d:6b8f:: with SMTP id n15mr11226205wrx.110.1552052239106; Fri, 08 Mar 2019 05:37:19 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id 132sm19625364wmd.27.2019.03.08.05.37.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 05:37:18 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v4 23/46] tools/lib/traceevent: Man pages tep_get_any_field_val(), tep_get_common_field_val(), tep_get_field_val() and tep_get_field_raw() Date: Fri, 8 Mar 2019 15:36:31 +0200 Message-Id: <20190308133654.21264-24-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308133654.21264-1-tstoyanov@vmware.com> References: <20190308133654.21264-1-tstoyanov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Create man pages for tep_get_any_field_val(), tep_get_common_field_val(), tep_get_field_val() and tep_get_field_raw() as part of the libtraceevent APIs. Signed-off-by: Tzvetomir Stoyanov --- .../libtraceevent-field_get_val.txt | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 tools/lib/traceevent/Documentation/libtraceevent-field_get_val.txt diff --git a/tools/lib/traceevent/Documentation/libtraceevent-field_get_val.txt b/tools/lib/traceevent/Documentation/libtraceevent-field_get_val.txt new file mode 100644 index 000000000000..dbb4875c49fb --- /dev/null +++ b/tools/lib/traceevent/Documentation/libtraceevent-field_get_val.txt @@ -0,0 +1,117 @@ +libtraceevent(3) +================ + +NAME +---- +tep_get_any_field_val,tep_get_common_field_val,tep_get_field_val,tep_get_field_raw - Get value of a field. + +SYNOPSIS +-------- +[verse] +-- +*#include * +*#include * + +int *tep_get_any_field_val*(struct trace_seq pass:[*]_s_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, unsigned long long pass:[*]_val_, int _err_); +int *tep_get_common_field_val*(struct trace_seq pass:[*]_s_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, unsigned long long pass:[*]_val_, int _err_); +int *tep_get_field_val*(struct trace_seq pass:[*]_s_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, unsigned long long pass:[*]_val_, int _err_); +void pass:[*]*tep_get_field_raw*(struct trace_seq pass:[*]_s_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, int pass:[*]_len_, int _err_); +-- + +DESCRIPTION +----------- +These functions can be used to find a field and retrieve its value. + +The _tep_get_any_field_val()_ function searches in the _record_ for a filed with +_name_, part of the _event_. If the field is found, its value is stored in _val_. +In case of an error, an error string is printed into _s_, if _err_ is not 0. + +The _tep_get_common_field_val()_ function does the same as +_tep_get_any_field_val()_, but searches only in the common fields. + +The _tep_get_field_val()_ function does the same as +_tep_get_any_field_val()_, but searches only in the event specific fields. + +The _tep_get_field_raw()_ function searches in the _record_ for a filed with _name_, +part of the _event_. If the field is found, a pointer to its raw data is returned. +The size of the data is stored in _len_. In case of an error, an error string +is printed into _s_, if _err_ is not 0. + +RETURN VALUE +------------ +The _tep_get_any_field_val()_, _tep_get_common_field_val()_ and +_tep_get_field_val()_ functions return 0 on success, or -1 in case of an error. + +The _tep_get_field_raw()_ function returns a pointer to field's raw data, and +places the length of this data in _len_. In case of an error NULL is returned. + +EXAMPLE +------- +[source,c] +-- +#include +#include +... +struct tep_handle *tep = tep_alloc(); +... +struct tep_event *event = tep_find_event_by_name(tep, "kvm", "kvm_exit"); +... +void process_record(struct tep_record *record) +{ + int len; + char *comm; + struct tep_event_format *event; + unsigned long long val; + + event = tep_find_event_by_record(pevent, record); + if (event != NULL) { + if (tep_get_common_field_val(NULL, event, "common_type", record, &val, 0) == 0) { + /* Got the value of common type field */ + } + if (tep_get_field_val(NULL, event, "pid", record, &val, 0) == 0) { + /* Got the value of pid specific field */ + } + comm = tep_get_field_raw(NULL, event, "comm", record, &len, 0); + if (comm != NULL) { + /* Got a pointer to the comm event specific field */ + } + } +} +-- + +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