Documentation for new libtracefs APIs
cover Documentation for new libtracefs APIs
Documented recently added APIs for trace instances and trace options.
Tzvetomir Stoyanov (VMware) (2):
libtracefs: Document new instance APIs
libtracefs: Document APIs for trace options
Documentation/libtracefs-instances-manage.txt | 34 +++- Documentation/libtracefs-instances-utils.txt | 16 +- Documentation/libtracefs-option-bits.txt | 90 ++++++++++ Documentation/libtracefs-option-get.txt | 123 ++++++++++++++ Documentation/libtracefs-option-misc.txt | 100 +++++++++++ Documentation/libtracefs-options.txt | 159 ++++++++++++++++++ 6 files changed, 513 insertions(+), 9 deletions(-) create mode 100644 Documentation/libtracefs-option-bits.txt create mode 100644 Documentation/libtracefs-option-get.txt create mode 100644 Documentation/libtracefs-option-misc.txt create mode 100644 Documentation/libtracefs-options.txt
Signature · 1 line
2.29.2
PATCH 1/2 libtracefs: Document new instance APIs
Added documentation for these new APIs:
tracefs_instance_alloc()
tracefs_instance_get_trace_dir()
--- Documentation/libtracefs-instances-manage.txt | 34 +++++++++++++++---- Documentation/libtracefs-instances-utils.txt | 16 +++++++-- 2 files changed, 41 insertions(+), 9 deletions(-)
Documentation/libtracefs-instances-manage.txt +28 -6
@@ -3,7 +3,7 @@ libtracefs(3) NAME ---- -tracefs_instance_create, tracefs_instance_destroy, tracefs_instance_free, +tracefs_instance_create, tracefs_instance_destroy, tracefs_instance_alloc, tracefs_instance_free, tracefs_instance_is_new - Manage trace instances. SYNOPSIS
@@ -14,6 +14,7 @@ SYNOPSIS struct tracefs_instance pass:[*]*tracefs_instance_create*(const char pass:[*]_name_); int *tracefs_instance_destroy*(struct tracefs_instance pass:[*]_instance_); +struct tracefs_instance pass:[*]*tracefs_instance_alloc*(const char pass:[*]_tracing_dir_, const char pass:[*]_name_); void *tracefs_instance_free*(struct tracefs_instance pass:[*]_instance_); bool *tracefs_instance_is_new*(struct tracefs_instance pass:[*]_instance_);
@@ -28,12 +29,22 @@ system, nor other instances, as events enabled in the main tracing system or other instances do not affect the given instance. The _tracefs_instance_create()_ function allocates and initializes a new -tracefs_instance structure and returns it. If the instance does not yet -exist in the system, it will be created. +tracefs_instance structure and returns it. If the instance with _name_ does +not yet exist in the system, it will be created. The _name_ could be NULL, +then the new tracefs_instance structure is initialised for the top instance. +Note that the top instance cannot be created in the system, if it does not +exist. The _tracefs_instance_destroy()_ frees the _instance_ structure, and will also remove the trace instance from the system. +The _tracefs_instance_alloc()_ function allocates a new tracefs_instance structure +for existing trace instance. If the instance does not exist in the system, the function +fails. The _tracing_dir_ parameter points to the system trace directory. It can be +NULL, then default system trace directory is used. This parameter is useful to allocate +instances to trace directories, copied from another machine. The _name_ is the name of +the instance, or NULL for the top instance in the given _tracing_dir_. + The _tracefs_instance_free()_ function frees the tracefs_instance structure, without removing the trace instance from the system.
@@ -43,8 +54,8 @@ before that. RETURN VALUE ------------ -The _tracefs_instance_create()_ function returns a pointer to a newly allocated -tracefs_instance structure. It must be freed with _tracefs_instance_destroy()_ or +The _tracefs_instance_create()_ and _tracefs_instance_alloc()_ functions return a pointer to +a newly allocated tracefs_instance structure. It must be freed with _tracefs_instance_destroy()_ or _tracefs_instance_free()_. The _tracefs_instance_destroy()_ function returns -1 in case of an error,
@@ -54,7 +65,7 @@ The _tracefs_instance_is_new()_ function returns true if the _tracefs_instance_create()_ that allocated _instance_ also created the trace instance in the system, or false if the trace instance already existed in the system when _instance_ was allocated by -_tracefs_instance_create()_. +_tracefs_instance_create()_ or _tracefs_instance_alloc()_. EXAMPLE -------
@@ -74,6 +85,17 @@ struct tracefs_instance *inst = tracefs_instance_create("foo"); tracefs_instance_destroy(inst); else tracefs_instance_free(inst); +... + +struct tracefs_instance *inst = tracefs_instance_alloc(NULL, "bar"); + if (!inst) { + /* Error allocating 'bar' trace instance */ + ... + } + + ... + + tracefs_instance_free(inst); -- FILES -----
Documentation/libtracefs-instances-utils.txt +13 -3
@@ -3,7 +3,8 @@ libtracefs(3) NAME ---- -tracefs_instance_get_name, tracefs_instances_walk, tracefs_instance_exists - +tracefs_instance_get_name, tracefs_instance_get_trace_dir, +tracefs_instances_walk, tracefs_instance_exists - Helper functions for working with tracing instances. SYNOPSIS
@@ -13,6 +14,7 @@ SYNOPSIS *#include <tracefs.h>* const char pass:[*]*tracefs_instance_get_name*(struct tracefs_instance pass:[*]_instance_); +const char pass:[*]*tracefs_instance_get_trace_dir*(struct tracefs_instance pass:[*]_instance_); int *tracefs_instances_walk*(int (pass:[*]_callback_)(const char pass:[*], void pass:[*]), void pass:[*]_context)_; bool *tracefs_instance_exists*(const char pass:[*]_name_);
@@ -25,6 +27,9 @@ Helper functions for working with trace instances. The _tracefs_instance_get_name()_ function returns the name of the given _instance_. Note that the top instance has no name, the function returns NULL for it. +The _tracefs_instance_get_trace_dir()_ function returns the tracing directory, where +the given _instance_ is configured. + The _tracefs_instances_walk()_ function walks through all configured tracing instances in the system and calls _callback_ for each one of them. The _context_ argument is passed to the _callback_, together with the instance name. If the
@@ -39,6 +44,9 @@ RETURN VALUE The _tracefs_instance_get_name()_ returns a string or NULL in case of the top instance. The returned string must _not_ be freed. +The _tracefs_instance_get_trace_dir()_ returns a string or NULL in case of an error. +The returned string must _not_ be freed. + The _tracefs_instances_walk()_ function returns 0, if all instances were iterated, 1 if the iteration was stopped by the _callback_, or -1 in case of an error.
@@ -54,11 +62,13 @@ EXAMPLE struct tracefs_instance *inst; .... char *name = tracefs_instance_get_name(inst); - if(name) { /* Got name of the instance */ } - +char *dir = tracefs_instance_get_trace_dir(inst); + if(dir) { + /* Got tracing directory of the instance */ + } ... static int instance_walk(char *name, void *context) {
Signature · 1 line
2.29.2
PATCH 2/2 libtracefs: Document APIs for trace options
In reply to Tzvetomir Stoyanov (VMware)Added documentation for libtracefs APIs realated to ftrace options:
enum tracefs_option - short description of each option
tracefs_option_set()
tracefs_option_clear()
qtracefs_option_is_set()
tracefs_options_get_supported()
tracefs_option_is_supported()
tracefs_options_get_enabled()
qtracefs_option_is_enabled()
tracefs_option_enable()
tracefs_option_diasble()
tracefs_option_name()
--- Documentation/libtracefs-option-bits.txt | 90 +++++++++++++ Documentation/libtracefs-option-get.txt | 123 ++++++++++++++++++ Documentation/libtracefs-option-misc.txt | 100 ++++++++++++++ Documentation/libtracefs-options.txt | 159 +++++++++++++++++++++++ 4 files changed, 472 insertions(+) create mode 100644 Documentation/libtracefs-option-bits.txt create mode 100644 Documentation/libtracefs-option-get.txt create mode 100644 Documentation/libtracefs-option-misc.txt create mode 100644 Documentation/libtracefs-options.txt
Documentation/libtracefs-option-bits.txt new file +90 -0
@@ -0,0 +1,90 @@ +libtracefs(3) +============= + +NAME +---- +tracefs_option_set, tracefs_option_clear, tracefs_option_is_set - +Set, clear, check option in a bitmask. + +SYNOPSIS +-------- +[verse] +-- +*#include <tracefs.h>* + +void *tracefs_option_set*(struct tracefs_options_mask pass:[*]_options_, enum tracefs_option_id _id_); +void *tracefs_option_clear*(struct tracefs_options_mask pass:[*]_options_, enum tracefs_option_id _id_); +bool *tracefs_option_is_set*(struct tracefs_options_mask _options_, enum tracefs_option_id _id_); +-- + +DESCRIPTION +----------- +This set of APIs can be used to manipulate a bitmask with option IDs. + +The _tracefs_option_set()_ function sets the bit, corresponding to the option with _id_ in the +_options_ bitmask. + +The _tracefs_option_clear()_ function clears the bit, corresponding to the option with _id_ in the +_options_ bitmask. + +The _tracefs_option_is_set()_ function checks if the bit, corresponding to the option with _id_ is +set in the _options_ bitmask. + +RETURN VALUE +------------ +The _tracefs_option_is_set()_ function returns true if the bit is set, false otherwise. + +EXAMPLE +------- +[source,c] +-- +#include <tracefs.h> +... +struct tracefs_options_mask options; +memset(&options, 0, sizeof(options)); +... +tracefs_option_set(&options, TRACEFS_OPTION_EVENT_FORK | TRACEFS_OPTION_FUNCTION_FORK); +... +if (tracefs_option_is_set(options, TRACEFS_OPTION_EVENT_FORK)) + tracefs_option_clear(&options, TRACEFS_OPTION_EVENT_FORK); +... +-- +FILES +----- +[verse] +-- +*tracefs.h* + Header file to include in order to have access to the library APIs. +*-ltracefs* + Linker switch to add when building a program that uses the library. +-- + +SEE ALSO +-------- +_libtracefs(3)_, +_libtraceevent(3)_, +_trace-cmd(1)_ + +AUTHOR +------ +[verse] +-- +*Steven Rostedt* <[email protected]> +*Tzvetomir Stoyanov* <[email protected]> +-- +REPORTING BUGS +-------------- +Report bugs to <[email protected]> + +LICENSE +------- +libtracefs is Free Software licensed under the GNU LGPL 2.1 + +RESOURCES +--------- +https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/ + +COPYING +------- +Copyright \(C) 2020 VMware, Inc. Free use of this software is granted under +the terms of the GNU Public License (GPL).
Documentation/libtracefs-option-get.txt new file +123 -0
123 lines not on this page · raw message
Documentation/libtracefs-option-misc.txt new file +100 -0
100 lines not on this page · raw message
Documentation/libtracefs-options.txt new file +159 -0
159 lines not on this page · raw message
Signature · 1 line
2.29.2