[tip:perf/core] tools lib traceevent: Man page for tep_read_number_field()

tip-bot for Tzvetomir Stoyanov
2019-05-18T09:14:21Z

Commit-ID: 95ec2822a976af27c9cb77cdc01c650a3640adfa
Gitweb: https://git.kernel.org/tip/95ec2822a976af27c9cb77cdc01c650a3640adfa
Author: Tzvetomir Stoyanov <tstoyanov@vmware.com>
AuthorDate: Fri, 10 May 2019 15:56:27 -0400
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 15 May 2019 16:36:48 -0300

tools lib traceevent: Man page for tep_read_number_field()

Create man page for libtraceevent API tep_read_number_field().

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: linux-trace-devel@vger.kernel.org
Link: http://lore.kernel.org/linux-trace-devel/20190503091119.23399-21-tstoyanov@vmware.com
Link: http://lkml.kernel.org/r/20190510200109.219394901@goodmis.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
...ndian_read.txt => libtraceevent-field_read.txt} | 27 ++++++++++++----------
1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/tools/lib/traceevent/Documentation/libtraceevent-endian_read.txt b/tools/lib/traceevent/Documentation/libtraceevent-field_read.txt
similarity index 54%
copy from tools/lib/traceevent/Documentation/libtraceevent-endian_read.txt
copy to tools/lib/traceevent/Documentation/libtraceevent-field_read.txt
index e64851b6e189..64e9e25d3fd9 100644
--- a/tools/lib/traceevent/Documentation/libtraceevent-endian_read.txt
+++ b/tools/lib/traceevent/Documentation/libtraceevent-field_read.txt
@@ -3,7 +3,7 @@ libtraceevent(3)

NAME
----
-tep_read_number - Reads a number from raw data.
+tep_read_number_field - Reads a number from raw data.

SYNOPSIS
--------
@@ -11,20 +11,20 @@ SYNOPSIS
--
*#include <event-parse.h>*

-unsigned long long *tep_read_number*(struct tep_handle pass:[*]_tep_, const void pass:[*]_ptr_, int _size_);
+int *tep_read_number_field*(struct tep_format_field pass:[*]_field_, const void pass:[*]_data_, unsigned long long pass:[*]_value_);
--

DESCRIPTION
-----------
-The _tep_read_number()_ function reads an integer from raw data, taking into
-account the endianness of the raw data and the current host. The _tep_ argument
-is the trace event parser context. The _ptr_ is a pointer to the raw data, where
-the integer is, and the _size_ is the size of the integer.
+The _tep_read_number_field()_ function reads the value of the _field_ from the
+raw _data_ and stores it in the _value_. The function sets the _value_ according
+to the endianness of the raw data and the current machine and stores it in
+_value_.

RETURN VALUE
------------
-The _tep_read_number()_ function returns the integer in the byte order of
-the current host. In case of an error, 0 is returned.
+The _tep_read_number_field()_ function retunrs 0 in case of success, or -1 in
+case of an error.

EXAMPLE
-------
@@ -34,16 +34,19 @@ EXAMPLE
...
struct tep_handle *tep = tep_alloc();
...
+struct tep_event *event = tep_find_event_by_name(tep, "timer", "hrtimer_start");
+...
void process_record(struct tep_record *record)
{
- int offset = 24;
- int data = tep_read_number(tep, record->data + offset, 4);
+ unsigned long long pid;
+ struct tep_format_field *field_pid = tep_find_common_field(event, "common_pid");

- /* Read the 4 bytes at the offset 24 of data as an integer */
+ if (tep_read_number_field(field_pid, record->data, &pid) != 0) {
+ /* Failed to get "common_pid" value */
+ }
}
...
--
-
FILES
-----
[verse]