'\" t .\" Title: libtracecmd .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 02/10/2024 .\" Manual: libtracefs Manual .\" Source: libtracefs .\" Language: English .\" .TH "LIBTRACECMD" "3" "02/10/2024" "libtracefs" "libtracefs Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" libtracecmd \- trace\-cmd library APIs .SH "SYNOPSIS" .sp .nf \fB#include \fR Open and close trace file: struct tracecmd_input *\fBtracecmd_open\fR(const char *\fIfile\fR, int \fIflags\fR); struct tracecmd_input *\fBtracecmd_open_fd\fR(int \fIfd\fR, int \fIflags\fR); struct tracecmd_input *\fBtracecmd_open_head\fR(const char *\fIfile\fR, int \fIflags\fR); void \fBtracecmd_close\fR(struct tracecmd_input *\fIhandle\fR); void \fBtracecmd_set_private\fR(struct tracecmd_input *\fIhandle\fR, void *\fIdata\fR); void *\fBtracecmd_get_private\fR(struct tracecmd_input *\fIhandle\fR); Read tracing records from a trace file: int \fBtracecmd_init_data\fR(struct tracecmd_input *\fIhandle\fR); struct tep_record *\fBtracecmd_read_cpu_first\fR(struct tracecmd_input *\fIhandle\fR, int \fIcpu\fR); struct tep_record *\fBtracecmd_read_data\fR(struct tracecmd_input *\fIhandle\fR, int \fIcpu\fR); struct tep_record *\fBtracecmd_read_at\fR(struct tracecmd_input *\fIhandle\fR, unsigned long long \fIoffset\fR, int *\fIcpu\fR); void \fBtracecmd_free_record\fR(struct tep_record *\fIrecord\fR); struct tep_handle *\fBtracecmd_get_tep\fR(struct tracecmd_input *\fIhandle\fR); Iterating over events in a trace file: int \fBtracecmd_iterate_events\fR(struct tracecmd_input *\fIhandle\fR, cpu_set_t *\fIcpus\fR, int \fIcpu_size\fR, int (*\fIcallback\fR)(struct tracecmd_input *, struct tep_record *, int, void *), void *\fIcallback_data\fR); int \fBtracecmd_iterate_events_multi\fR(struct tracecmd_input **\fIhandles\fR, int \fInr_handles\fR, int (*\fIcallback\fR)(struct tracecmd_input *, struct tep_record *, int, void *), void *\fIcallback_data\fR); int \fBtracecmd_follow_event\fR(struct tracecmd_input *\fIhandle\fR, const char *\fIsystem\fR, const char *\fIevent_name\fR, int (*\fIcallback\fR)(struct tracecmd_input *, struct tep_event *, struct tep_record *, int, void *), void *\fIcallback_data\fR); int \fBtracecmd_follow_missed_events\fR(struct tracecmd_input *\fIhandle\fR, int (*\fIcallback\fR)(struct tracecmd_input *, struct tep_event *, struct tep_record *, int, void *), void *\fIcallback_data\fR); struct tracecmd_filter *\fBtracecmd_filter_add\fR(struct tracecmd_input \fB\fIhandle\fR\fR\fB, const char *\fR\fB\fIfilter_str\fR\fR\fB, bool \fR\fB\fIneg\fR\fR\fB); Read tracing instances from a trace file: int *tracecmd_buffer_instances\fR(struct tracecmd_input *\fIhandle\fR); const char *\fBtracecmd_buffer_instance_name\fR(struct tracecmd_input *\fIhandle\fR, int \fIindx\fR); struct tracecmd_input *\fBtracecmd_buffer_instance_handle\fR(struct tracecmd_input *\fIhandle\fR, int \fIindx\fR); Handle time stamps from a trace file: unsigned long long \fBtracecmd_get_first_ts\fR(struct tracecmd_input *\fIhandle\fR); void \fBtracecmd_add_ts_offset\fR(struct tracecmd_input *\fIhandle\fR, long long \fIoffset\fR); int \fBtracecmd_get_tsc2nsec\fR(struct tracecmd_input *\fIhandle\fR, int *\fImult\fR, int pass[\fB]\fR\fB\fIshift\fR\fR\fB, unsigned long long *\fR\fB\fIoffset\fR\fR\fB); Get traceing peer information from a trace file: unsigned long long *tracecmd_get_traceid\fR(struct tracecmd_input *\fIhandle\fR); int \fBtracecmd_get_guest_cpumap\fR(struct tracecmd_input *\fIhandle\fR, unsigned long long \fItrace_id\fR, const char **\fIname\fR, int *\fIvcpu_count\fR, const int **\fIcpu_pid\fR); Mapping host and guest trace files: int \fBtracecmd_map_vcpus\fR(struct tracecmd_input **handles, int nr_handles); struct tracecmd_cpu_map *\fBtracecmd_get_cpu_map\fR(struct tracecmd_input *handle, int cpu); struct tracecmd_cpu_map *\fBtracecmd_map_find_by_host_pid\fR(struct tracecmd_input *handle, int host_pid); int \fBtracecmd_map_get_host_pid\fR(struct tracecmd_cpu_map *map); struct tracecmd_input *\fBtracecmd_map_get_guest\fR(struct tracecmd_cpu_map *map); void \fBtracecmd_map_set_private\fR(struct tracecmd_cpu_map *map, void *priv); void *\fBtracecmd_map_get_private\fR(struct tracecmd_cpu_map *map); Control library logs: int \fBtracecmd_set_loglevel\fR(enum tep_loglevel \fIlevel\fR); .fi .SH "DESCRIPTION" .sp The libtracecmd(3) library provides APIs to read, parse and write \fItrace\-cmd\&.dat(5)\fR files, recorded with \fItrace\-cmd(1)\fR application and containing tracing information from ftrace, the official Linux kernel tracer\&. .SH "FILES" .sp .if n \{\ .RS 4 .\} .nf \fBtrace\-cmd\&.h\fR Header file to include in order to have access to the library APIs\&. \fB\-ltracecmd\fR Linker switch to add when building a program that uses the library\&. .fi .if n \{\ .RE .\} .SH "SEE ALSO" .sp \fBlibtraceevent(3)\fR \fBlibtracefs(3)\fR \fBtrace\-cmd(1)\fR \fBtrace\-cmd\&.dat(5)\fR .SH "AUTHOR" .sp .if n \{\ .RS 4 .\} .nf \fBSteven Rostedt\fR <\m[blue]\fBrostedt@goodmis\&.org\fR\m[]\&\s-2\u[1]\d\s+2> \fBTzvetomir Stoyanov\fR <\m[blue]\fBtz\&.stoyanov@gmail\&.com\fR\m[]\&\s-2\u[2]\d\s+2> .fi .if n \{\ .RE .\} .SH "REPORTING BUGS" .sp Report bugs to <\m[blue]\fBlinux\-trace\-devel@vger\&.kernel\&.org\fR\m[]\&\s-2\u[3]\d\s+2> .SH "LICENSE" .sp libtracecmd is Free Software licensed under the GNU LGPL 2\&.1 .SH "RESOURCES" .sp \m[blue]\fBhttps://git\&.kernel\&.org/pub/scm/utils/trace\-cmd/trace\-cmd\&.git/\fR\m[] .SH "COPYING" .sp Copyright (C) 2020 VMware, Inc\&. Free use of this software is granted under the terms of the GNU Public License (GPL)\&. .SH "NOTES" .IP " 1." 4 rostedt@goodmis.org .RS 4 \%mailto:rostedt@goodmis.org .RE .IP " 2." 4 tz.stoyanov@gmail.com .RS 4 \%mailto:tz.stoyanov@gmail.com .RE .IP " 3." 4 linux-trace-devel@vger.kernel.org .RS 4 \%mailto:linux-trace-devel@vger.kernel.org .RE