'\" t .\" Title: libtracefs .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 07/25/2024 .\" Manual: libtracefs Manual .\" Source: libtracefs 1.8.1 .\" Language: English .\" .TH "LIBTRACEFS" "3" "07/25/2024" "libtracefs 1\&.8\&.1" "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_error_last, tracefs_error_all, tracefs_error_clear \- functions to read and clear the tracefs error log\&. .SH "SYNOPSIS" .sp .nf \fB#include \fR char *\fBtracefs_error_last\fR(struct tracefs_instance *\fIinstance\fR); char *\fBtracefs_error_all\fR(struct tracefs_instance *\fIinstance\fR); int \fBtracefs_error_clear\fR(struct tracefs_instance *\fIinstance\fR); .fi .SH "DESCRIPTION" .sp The \fBtracefs_error_last\fR() returns the last error message in the tracefs error log\&. Several actions that require proper syntax written into the tracefs file system may produce error messages in the error log\&. This function will show the most recent error in the error log\&. .sp The \fBtracefs_error_all\fR() returns all messages saved in the error log\&. Note, this may not be all messages that were ever produced, as the kernel only keeps a limited amount of messages, and older ones may be discarded by the kernel\&. .sp The \fBtracefs_error_clear\fR() will clear the error log\&. .SH "RETURN VALUE" .sp Both \fBtracefs_error_last\fR() and \fBtracefs_error_all\fR() will return an allocated string an error exists in the log, otherwise NULL is returned\&. If an error occurs, errno will be set, otherwise if there is no error messages to display then errno is not touched\&. .sp \fBtracefs_error_clear\fR() returns 0 on success or \-1 on error\&. .SH "EXAMPLE" .sp .if n \{\ .RS 4 .\} .nf #include #include #include #include int main (int argc, char **argv, char **env) { struct tracefs_dynevent *kevent; char *system = NULL; char *kprobe; char *format; char *addr; int arg = 1; int ret; if (argc < 4) { printf("usage: %s [system] kprobe addr fmt\en", argv[0]); exit(\-1); } if (argc > 5) system = argv[arg++]; kprobe = argv[arg++]; addr = argv[arg++]; format = argv[arg++]; tracefs_error_clear(NULL); kevent = tracefs_dynevent_get(TRACEFS_DYNEVENT_KPROBE, system, kprobe); if (kevent) { tracefs_dynevent_destroy(kevent, true); tracefs_dynevent_free(kevent); } ret = tracefs_kprobe_raw(system, kprobe, addr, format); if (ret < 0) { char *err; perror("Failed creating kprobe"); errno = 0; err = tracefs_error_last(NULL); if (err) fprintf(stderr, "%s\en", err); else if (errno) perror("Failed reading error log"); free(err); } exit(ret); } .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) .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) 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