libtracecmd(3)

# libtracecmd(3) Manual Page

## NAME

tracecmd_get_first_ts, tracecmd_add_ts_offset, tracecmd_get_tsc2nsec - Handle time stamps from a trace file.

## SYNOPSIS

    #include <trace-cmd.h>

    unsigned long long tracecmd_get_first_ts(struct tracecmd_input *handle);
    void tracecmd_add_ts_offset(struct tracecmd_input *handle, long long offset);
    int tracecmd_get_tsc2nsec(struct tracecmd_input *handle, int *mult, int pass[*]shift, unsigned long long *offset);

## DESCRIPTION

This set of APIs can be used to read tracing data from a trace file opened with tracecmd_open()(3), tracecmd_open_fd()(3) or tracecmd_open_head()(3).

The tracecmd_get_first_ts() function returns the time stamp of the first record in the handle.

The tracecmd_add_ts_offset() function adds an offset to each of the records in the handle that represents a trace file. This is useful for associating two different tracing files by their offset (for example a trace file from a host and a trace file from a guest that were not synchronized when created).

The tracecmd_get_tsc2nsec returns the calculation values that convert the raw timestamp into nanoseconds. The parameters are pointers to the storage to save the values, or NULL to ignore them. The multiplier will be saved in mult, the shift value will be saved in shift, and the offset value will be saved in offset, if the corresponding parameters are not NULL.

## RETURN VALUE

The tracecmd_get_first_ts() function returns the timestamp of the first record in a trace file for the given handle.

The tracecmd_get_tsc2nsec() returns 0 if the tracing clock supports the shift values and -1 otherwise. Note, that if the trace file has the TSC2NSEC option, the values returned in the parameters may still be valid even if the function itself returns -1. The return value only notes if the values will be used in the calculations of the given clock.

## EXAMPLE

## FILES

    trace-cmd.h
            Header file to include in order to have access to the library APIs.
    -ltracecmd
            Linker switch to add when building a program that uses the library.

## SEE ALSO

libtracefs(3), libtraceevent(3), trace-cmd(1) trace-cmd.dat(5)

## AUTHOR

    Steven Rostedt <rostedt@goodmis.org>
    Tzvetomir Stoyanov <tz.stoyanov@gmail.com>

## REPORTING BUGS

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

## LICENSE

libtracecmd is Free Software licensed under the GNU LGPL 2.1

## RESOURCES

https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/

## COPYING

Copyright (C) 2020 VMware, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).