'\" t .\" Title: libtracefs .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 10/08/2022 .\" Manual: libtracefs Manual .\" Source: libtracefs 1.5.0 .\" Language: English .\" .TH "LIBTRACEFS" "3" "10/08/2022" "libtracefs 1\&.5\&.0" "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" tracefs_print_init, tracefs_print_close, tracefs_printf, tracefs_vprintf \- Open, close and write formated strings in the trace buffer\&. .SH "SYNOPSIS" .sp .nf \fB#include \fR int \fBtracefs_print_init\fR(struct tracefs_instance *\fIinstance\fR); int \fBtracefs_printf\fR(struct tracefs_instance *\fIinstance\fR, const char *\fIfmt\fR, \fI\&...\fR); int \fBtracefs_vprintf\fR(struct tracefs_instance *\fIinstance\fR, const char *\fIfmt\fR, va_list \fIap\fR); void \fBtracefs_print_close\fR(struct tracefs_instance *\fIinstance\fR); .fi .SH "DESCRIPTION" .sp Set of functions to write formated strings in the trace buffer\&. See Documentation/trace/ftrace\&.rst from the Linux kernel tree for more information about writing data from user space in the trace buffer\&. All these APIs have \fIinstance\fR as a first argument\&. If NULL is passed as \fIinstance\fR, the top trace instance is used\&. .sp The \fBtracefs_print_init()\fR function initializes the library for writing into the trace buffer of the selected \fIinstance\fR\&. It is not mandatory to call this API before writing strings, any of the printf APIs will call it automatically, if the library is not yet initialized\&. But calling \fBtracefs_print_init()\fR in advance will speed up the writing\&. .sp The \fBtracefs_printf()\fR function writes a formatted string in the trace buffer of the selected \fIinstance\fR\&. The \fIfmt\fR argument is a string in printf format, followed by variable arguments \fI\&...\fR\&. .sp The \fBtracefs_vprintf()\fR function writes a formatted string in the trace buffer of the selected \fIinstance\fR\&. The \fIfmt\fR argument is a string in printf format, followed by list \fIap\fR of arguments\&. .sp The \fBtracefs_print_close()\fR function closes the resources, used by the library for writing in the trace buffer of the selected instance\&. .SH "RETURN VALUE" .sp The \fBtracefs_print_init()\fR, \fBtracefs_printf()\fR, and \fBtracefs_vprintf()\fR functions return 0 if the operation is successful, or \-1 in case of an error\&. .SH "EXAMPLE" .sp .if n \{\ .RS 4 .\} .nf #include if (tracefs_print_init(NULL) < 0) { /* Failed to initialize the library for writing in the trace buffer of the top trace instance */ } void foo_print(char *format, \&.\&.\&.) { va_list ap; va_start(ap, format); if (tracefs_vprintf(NULL, format, ap) < 0) { /* Failed to print in the trace buffer */ } va_end(ap); } void foo_print_string(char *message) { if (tracefs_printf(NULL, "Message from user space: %s", message) < 0) { /* Failed to print in the trace buffer */ } } tracefs_print_close(); .fi .if n \{\ .RE .\} .SH "FILES" .sp .if n \{\ .RS 4 .\} .nf \fBtracefs\&.h\fR Header file to include in order to have access to the library APIs\&. \fB\-ltracefs\fR Linker switch to add when building a program that uses the library\&. .fi .if n \{\ .RE .\} .SH "SEE ALSO" .sp \fBlibtracefs\fR(3), \fBlibtraceevent\fR(3), \fBtrace\-cmd\fR(1), Documentation/trace/ftrace\&.rst from the Linux kernel tree .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 libtracefs is Free Software licensed under the GNU LGPL 2\&.1 .SH "RESOURCES" .sp \m[blue]\fBhttps://git\&.kernel\&.org/pub/scm/libs/libtrace/libtracefs\&.git/\fR\m[] .SH "COPYING" .sp Copyright (C) 2021 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