# libtracefs(3) Manual Page

## NAME

tracefs_dynevent_create, tracefs_dynevent_destroy, tracefs_dynevent_destroy_all, tracefs_dynevent_free, tracefs_dynevent_list_free, tracefs_dynevent_get, tracefs_dynevent_get_all, tracefs_dynevent_info, tracefs_dynevent_get_event - Create, destroy, free and get dynamic events.

## SYNOPSIS

    #include <tracefs.h>

    struct tracefs_dynevent;
    enum tracefs_dynevent_type;
    int tracefs_dynevent_create(struct tracefs_dynevent *devent);
    int tracefs_dynevent_destroy(struct tracefs_dynevent *devent, bool force);
    int tracefs_dynevent_destroy_all(unsigned int types, bool force);
    void tracefs_dynevent_free(struct tracefs_dynevent *devent);
    void tracefs_dynevent_list_free(struct tracefs_dynevent **events);
    struct tracefs_dynevent *tracefs_dynevent_get(enum tracefs_dynevent_type type, const char *system, const char *event);
    struct tracefs_dynevent **tracefs_dynevent_get_all(unsigned int types, const char *system);
    enum tracefs_dynevent_type tracefs_dynevent_info(struct tracefs_dynevent *dynevent, char **system, char **event, char **prefix, char **addr, char **format);
    struct tep_event *tracefs_dynevent_get_event(struct tep_handle *tep, struct tracefs_dynevent *dynevent);

## DESCRIPTION

The tracefs_dynevent_create() function creates dynamic event devent in the system.

The tracefs_dynevent_destroy() function removes dynamic event devent from the system. If force is true, the function will attempt to disable all events in all trace instances, before removing the dynamic event. The devent context is not freed, use tracefs_dynevent_free() to free it.

The tracefs_dynevent_destroy_all() function removes all dynamic events of given types from the system. The types parameter is a type of specific dynamic event, or a bitmask of dynamic events types tracefs_dynevent_type, that will be removed. If types is 0, dynamic events from all types will be removed. If force is true, the function will attempt to disable all events in all trace instances, before removing the dynamic events.

The tracefs_dynevent_get() function allocates and returns a single instance of a dynamic event that matches the given type, system and event that is passed to it. NULL is returned if there is no match. The returned event is what is found in the system, and must be freed with tracefs_dynevent_free(). If system is NULL, then the first event of any system of the given type that has the name of event will be returned.

The tracefs_dynevent_get_all() function allocates and returns an array of pointers to dynamic events of given types that exist in the system. The last element of the array is a NULL pointer. The array must be freed with tracefs_dynevent_list_free(). If there are no events a NULL pointer is returned. The types parameter is a type of specific dynamic event, or a bitmask of dynamic events types tracefs_dynevent_type, that will be retrieved. If types is 0, dynamic events from all types will be retrieved.

The tracefs_dynevent_free() function frees a dynamic event context devent.

The tracefs_dynevent_list_free() function frees an array of pointers to dynamic event, returned by tracefs_dynevent_get_all() API.

The tracefs_dynevent_info() function returns the type and information of a given dynamic event dynevent. If any of the system, event, prefix, addr or format arguments are not NULL, then strings are allocated and returned back via these arguments. The system and event holds the system and the name of the dynamic event. If prefix is non NULL, then it will hold an allocated string that holds the prefix portion of the dynamic event (the content up to the ":", exluding it). If addr is non NULL, it will hold the address or function that the dynamic event is attached to, if relevant for this event type. If format is non NULL, it will hold the format string of the dynamic event. Note, that the content in group, event, prefix, addr, and format must be freed with free(3) if they are set.

The tracefs_dynevent_get_event() function returns a tep event, describing the given dynamic event. The API detects any newly created or removed dynamic events. The returned pointer to tep event is controlled by @tep and must not be freed.

## RETURN VALUE

tracefs_dynevent_create() returns 0 on success, or -1 on error. If a parsing error occurs then tracefs_error_last(3) may be used to retrieve the error message explaining the parsing issue.

tracefs_dynevent_destroy() and tracefs_dynevent_destroy_all() return 0 on success, or -1 on error. If force is enabled, the functions may fail on disabling the events.

tracefs_dynevent_get() function returns an allocated dynamic event from the system that matches the type, system and event given.

tracefs_dynevent_get_all() function returns allocated array of pointers to dynamic events, or NULL in case of an error or in case there are no events in the system. That array must be freed by tracefs_dynevent_list_free().

tracefs_dynevent_info() returns the type of the given dynamic event or TRACEFS_DYNEVENT_UNKNOWN on error. If system, event, prefix, addr, or format are non NULL, they will contain allocated strings that must be freed by free(3).

The tracefs_dynevent_get_event() function returns a pointer to a tep event or NULL in case of an error or if the requested dynamic event is missing. The returned pointer to tep event is controlled by @tep and must not be freed.

## ERRORS

The following errors are for all the above calls:

ENODEV dynamic events of requested type are not configured for the running kernel.

ENOMEM Memory allocation error.

tracefs_dynevent_create() can fail with the following errors:

EINVAL Most likely a parsing error occurred (use tracefs_error_last(3) to possibly see what that error was).

Other errors may also happen caused by internal system calls.

## EXAMPLE

## FILES

    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

    Steven Rostedt <rostedt@goodmis.org>
    Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
    Yordan Karadzhov <y.karadz@gmail.com>

## REPORTING BUGS

Report bugs to <linux-trace-devel@vger.kernel.org>

## 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) 2021 VMware, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).