linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tzvetomir Stoyanov <tstoyanov@vmware.com>
To: "rostedt@goodmis.org" <rostedt@goodmis.org>
Cc: "linux-trace-devel@vger.kernel.org" <linux-trace-devel@vger.kernel.org>
Subject: [PATCH v3 14/46] tools/lib/traceevent: Man pages for tep_register_event_handler() and tep_unregister_event_handler()
Date: Tue, 27 Nov 2018 15:42:24 +0000	[thread overview]
Message-ID: <20181127154153.11315-15-tstoyanov@vmware.com> (raw)
In-Reply-To: <20181127154153.11315-1-tstoyanov@vmware.com>

Create man pages for tep_register_event_handler() and tep_unregister_event_handler()
as part of the libtraceevent APIs.

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
---
 .../libtraceevent-reg_event_handler.txt       | 129 ++++++++++++++++++
 1 file changed, 129 insertions(+)
 create mode 100644 tools/lib/traceevent/Documentation/libtraceevent-reg_event_handler.txt

diff --git a/tools/lib/traceevent/Documentation/libtraceevent-reg_event_handler.txt b/tools/lib/traceevent/Documentation/libtraceevent-reg_event_handler.txt
new file mode 100644
index 000000000000..ee9aa3a4151b
--- /dev/null
+++ b/tools/lib/traceevent/Documentation/libtraceevent-reg_event_handler.txt
@@ -0,0 +1,129 @@
+libtraceevent(3)
+================
+
+NAME
+----
+tep_register_event_handler,tep_unregister_event_handler -  Register / unregisters
+a callback function to parse an event information.
+
+SYNOPSIS
+--------
+[verse]
+--
+*#include <event-parse.h>*
+
+enum *tep_reg_handler* {
+	_TEP_REGISTER_SUCCESS_,
+	_TEP_REGISTER_SUCCESS_OVERWRITE_,
+};
+
+int *tep_register_event_handler*(struct tep_handle pass:[*]_tep_, int _id_, const char pass:[*]_sys_name_, const char pass:[*]_event_name_, tep_event_handler_func _func_, void pass:[*]_context_);
+int *tep_unregister_event_handler*(struct tep_handle pass:[*]tep, int id, const char pass:[*]sys_name, const char pass:[*]event_name, tep_event_handler_func func, void pass:[*]_context_);
+
+typedef int (*pass:[*]tep_event_handler_func*)(struct trace_seq pass:[*]s, struct tep_record pass:[*]record, struct tep_event pass:[*]event, void pass:[*]context);
+--
+
+DESCRIPTION
+-----------
+The _tep_register_event_handler()_ function registers a handler function, 
+which is going to be called to parse the information for a given event. 
+The _tep_ argument is the trace event parser context. The _id_ argument is 
+the id of the event. The _sys_name_ argument is the name of the system, 
+the event belongs to. The _event_name_ argument is the name of the event.
+If _id_ is >= 0, it is used to find the event, otherwise _sys_name_ and 
+_event_name_ are used. The _func_ is a pointer to the function, which is going 
+to be called to parse the event information. The _context_ argument is a pointer
+to the context data, which will be passed to the _func_. If a handler function 
+for the same event is already registered, it will be overridden with the new 
+one. This mechanism allows a developer to override the parsing of a given event.
+If for some reason the default print format is not sufficient, the developer 
+can register a function for an event to be used to parse the data instead.
+
+The _tep_unregister_event_handler()_ function unregisters the handler function,
+previously registered with _tep_register_event_handler()_. The _tep_ argument 
+is the trace event parser context. The _id_, _sys_name_, _event_name_, _func_,
+and _context_ are the same arguments, as when the callback function _func_ was
+registered.
+
+The _tep_event_handler_func_ is the type of the custom event handler 
+function. The _s_ argument is the trace sequence, it can be used to create a 
+custom string, describing the event. A _record_  to get the event from is passed 
+as input parameter and also the _event_ - the handle to the record's event. The 
+_context_ is custom context, set when the custom event handler is registered. 
+ 
+RETURN VALUE
+------------
+The _tep_register_event_handler()_ function returns _TEP_REGISTER_SUCCESS_
+if the new handler is registered successfully or _TEP_REGISTER_SUCCESS_OVERWRITE_ if
+an existing handler is overwritten. If there is not  enough memory to complete 
+the registration, TEP_ERRNO__MEM_ALLOC_FAILED is returned. 
+
+The _tep_unregister_event_handler()_ function returns 0 if _func_ was removed 
+successful or, -1 if the event was not found.
+
+The _tep_event_handler_func_ should return -1 in case of an error, or 0 otherwise.
+
+EXAMPLE
+-------
+[source,c]
+--
+#include <event-parse.h>
+#include <trace-seq.h>
+...
+struct tep_handle *tep = tep_alloc();
+...
+int custom_event_handler(struct trace_seq *s, struct tep_record *record,
+			 struct tep_event *event, void *context) 
+{
+	trace_seq_printf(s, "kvm_exit event");
+	return 0;
+}
+...
+	if (tep_register_event_handler(tep, -1, "kvm", "kvm_exit",
+				   custom_event_handler, NULL)) {
+	/* Failed to register the handler for event "kvm_exit" from "kvm" system */
+	}
+...
+	if (tep_unregister_event_handler(pevent, -1, "kvm", "kvm_exit",
+				     custom_event_handler, NULL) != ) {
+	/* Failed to unregister the handler for event "kvm_exit" from "kvm" system */
+	}
+
+--
+
+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* <rostedt@goodmis.org>, author of *libtraceevent*.
+*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page.
+--
+REPORTING BUGS
+--------------
+Report bugs to  <linux-trace-devel@vger.kernel.org>
+
+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
-- 
2.19.1

  parent reply	other threads:[~2018-11-28  2:40 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-27 15:42 [PATCH v3 00/46] Libtraceevent MAN pages Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 01/46] tools/lib/traceevent: Implement libtraceevent man pages Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 02/46] tools/lib/traceevent: Fix libtraceevent/Documentation Makefile Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 03/46] tools/lib/traceevent: Add support for man pages with multiple names Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 04/46] tools/lib/traceevent: libtraceevent Makefile "help" target Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 05/46] tools/lib/traceevent: libtraceevent man pages for tep_handler related APIs Tzvetomir Stoyanov
2018-12-12 17:48   ` Steven Rostedt
2018-11-27 15:42 ` [PATCH v3 06/46] tools/lib/traceevent: Man page for tep_get_header_page_size() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 07/46] tools/lib/traceevent: Man page for tep_get_cpus() and tep_set_cpus() Tzvetomir Stoyanov
2019-01-16 16:32   ` Steven Rostedt
2018-11-27 15:42 ` [PATCH v3 08/46] tools/lib/traceevent: Man page for tep_is_file_bigendian() and tep_set_file_bigendian() Tzvetomir Stoyanov
2019-01-16 16:37   ` Steven Rostedt
2018-11-27 15:42 ` [PATCH v3 09/46] tools/lib/traceevent: Man page for tep_is_host_bigendian() and tep_set_host_bigendian() Tzvetomir Stoyanov
2019-01-16 16:41   ` Steven Rostedt
2018-11-27 15:42 ` [PATCH v3 10/46] tools/lib/traceevent: Man page for tep_is_latency_format() and tep_set_latency_format() Tzvetomir Stoyanov
2019-01-16 17:45   ` Steven Rostedt
2018-11-27 15:42 ` [PATCH v3 11/46] tools/lib/traceevent: Man page for tep_get_page_size() and tep_set_page_size() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 12/46] tools/lib/traceevent: Man page for tep_strerror() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 13/46] tools/lib/traceevent: Man page for tep_register_trace_clock() Tzvetomir Stoyanov
2018-11-27 15:42 ` Tzvetomir Stoyanov [this message]
2018-11-27 15:42 ` [PATCH v3 15/46] tools/lib/traceevent: Man pages for tep_register_function() and tep_register_print_string() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 16/46] tools/lib/traceevent: Man pages for tep_register_print_function() and tep_unregister_print_function() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 17/46] tools/lib/traceevent: Man page for tep_read_number() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 18/46] tools/lib/traceevent: Man pages for tep_find_event(), tep_find_event_by_name() and tep_find_event_by_record() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 19/46] tools/lib/traceevent: Man page for tep_list_events() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 20/46] tools/lib/traceevent: Man pages for tep_print_event(), tep_print_event_data(), tep_event_info(), tep_print_event_task() and tep_print_event_time() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 21/46] tools/lib/traceevent: Man pages tep_get_first_event() and tep_get_events_count() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 22/46] tools/lib/traceevent: Man pages tep_find_common_field(), tep_find_field() and tep_find_any_field() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 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() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 24/46] tools/lib/traceevent: Man pages for tep_print_field(), tep_print_fields(), tep_print_num_field() and tep_print_func_field() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 25/46] tools/lib/traceevent: Man page for tep_read_number_field() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 26/46] tools/lib/traceevent: Man pages for tep_event_common_fields() and tep_event_fields() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 27/46] tools/lib/traceevent: Man pages for tep_filter_alloc(), tep_filter_free() and tep_filter_reset() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 28/46] tools/lib/traceevent: Man page for tep_filter_add_filter_str() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 29/46] tools/lib/traceevent: Man page for tep_filter_strerror() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 30/46] tools/lib/traceevent: Man pages for tep_event_filtered() and tep_filter_remove_event() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 31/46] tools/lib/traceevent: Man page for tep_filter_match() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 32/46] tools/lib/traceevent: Man pages for tep_filter_copy() and tep_filter_compare() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 33/46] tools/lib/traceevent: Man page for tep_filter_make_string() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 34/46] tools/lib/traceevent: Man pages for tep_filter_event_has_trivial(), tep_update_trivial() and tep_filter_clear_trivial() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 35/46] tools/lib/traceevent: Man pages for tep_find_function() and tep_find_function_address() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 36/46] tools/lib/traceevent: Man pages for tep_set_function_resolver() and tep_reset_function_resolver() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 37/46] tools/lib/traceevent: Man pages for tep_parse_event() and tep_parse_format() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 38/46] tools/lib/traceevent: Man page for tep_parse_header_page() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 39/46] tools/lib/traceevent: Man pages for tep_load_plugins() and tep_unload_plugin() Tzvetomir Stoyanov
2018-11-27 15:42 ` [PATCH v3 40/46] tools/lib/traceevent: Man page for tep_data_lat_fmt() Tzvetomir Stoyanov
2018-11-27 15:43 ` [PATCH v3 41/46] tools/lib/traceevent: Man pages for tep_data_type(), tep_data_pid(), tep_data_preempt_count() and tep_data_flags() Tzvetomir Stoyanov
2018-11-27 15:43 ` [PATCH v3 42/46] tools/lib/traceevent: Man pages for trace_seq_init() and trace_seq_destroy() Tzvetomir Stoyanov
2018-11-27 15:43 ` [PATCH v3 43/46] tools/lib/traceevent: Man pages for trace_seq_do_fprintf() and trace_seq_do_printf() Tzvetomir Stoyanov
2018-11-27 15:43 ` [PATCH v3 44/46] tools/lib/traceevent: Man pages for trace_seq_printf() and trace_seq_vprintf() Tzvetomir Stoyanov
2018-11-27 15:43 ` [PATCH v3 45/46] tools/lib/traceevent: Man pages for trace_seq_putc() and trace_seq_puts() Tzvetomir Stoyanov
2018-11-27 15:43 ` [PATCH v3 46/46] tools/lib/traceevent: Man pages for trace_seq_reset() and trace_seq_terminate() Tzvetomir Stoyanov
2019-02-01 11:21 ` [PATCH v3 00/46] Libtraceevent MAN pages Claudio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181127154153.11315-15-tstoyanov@vmware.com \
    --to=tstoyanov@vmware.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).