'\" t
.\"     Title: libtraceevent
.\"    Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\"      Date: 01/16/2026
.\"    Manual: libtraceevent Manual
.\"    Source: libtraceevent 1.8.4
.\"  Language: English
.\"
.TH "LIBTRACEEVENT" "3" "01/16/2026" "libtraceevent 1\&.8\&.4" "libtraceevent 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"
tep_get_any_field_val, tep_get_common_field_val, tep_get_field_val, tep_get_field_raw \- Get value of a field\&.
.SH "SYNOPSIS"
.sp
.nf
\fB#include <event\-parse\&.h>\fR
\fB#include <trace\-seq\&.h>\fR

int \fBtep_get_any_field_val\fR(struct trace_seq *\fIs\fR, struct tep_event *\fIevent\fR, const char *\fIname\fR, struct tep_record *\fIrecord\fR, unsigned long long *\fIval\fR, int \fIerr\fR);
int \fBtep_get_common_field_val\fR(struct trace_seq *\fIs\fR, struct tep_event *\fIevent\fR, const char *\fIname\fR, struct tep_record *\fIrecord\fR, unsigned long long *\fIval\fR, int \fIerr\fR);
int \fBtep_get_field_val\fR(struct trace_seq *\fIs\fR, struct tep_event *\fIevent\fR, const char *\fIname\fR, struct tep_record *\fIrecord\fR, unsigned long long *\fIval\fR, int \fIerr\fR);
void *\fBtep_get_field_raw\fR(struct trace_seq *\fIs\fR, struct tep_event *\fIevent\fR, const char *\fIname\fR, struct tep_record *\fIrecord\fR, int *\fIlen\fR, int \fIerr\fR);
.fi
.SH "DESCRIPTION"
.sp
These functions can be used to find a field and retrieve its value\&.
.sp
The \fBtep_get_any_field_val()\fR function searches in the \fIrecord\fR for a field with \fIname\fR, part of the \fIevent\fR\&. If the field is found, its value is stored in \fIval\fR\&. If there is an error and \fIerr\fR is not zero, then an error string is written into \fIs\fR\&.
.sp
The \fBtep_get_common_field_val()\fR function does the same as \fBtep_get_any_field_val()\fR, but searches only in the common fields\&. This works for any event as all events include the common fields\&.
.sp
The \fBtep_get_field_val()\fR function does the same as \fBtep_get_any_field_val()\fR, but searches only in the event specific fields\&.
.sp
The \fBtep_get_field_raw()\fR function searches in the \fIrecord\fR for a field with \fIname\fR, part of the \fIevent\fR\&. If the field is found, a pointer to where the field exists in the record\(cqs raw data is returned\&. The size of the data is stored in \fIlen\fR\&. If there is an error and \fIerr\fR is not zero, then an error string is written into \fIs\fR\&.
.SH "RETURN VALUE"
.sp
The \fBtep_get_any_field_val()\fR, \fBtep_get_common_field_val()\fR and \fBtep_get_field_val()\fR functions return 0 on success, or \-1 in case of an error\&.
.sp
The \fBtep_get_field_raw()\fR function returns a pointer to field\(cqs raw data, and places the length of this data in \fIlen\fR\&. In case of an error NULL is returned\&.
.SH "EXAMPLE"
.sp
.if n \{\
.RS 4
.\}
.nf
#include <event\-parse\&.h>
#include <trace\-seq\&.h>
\&.\&.\&.
struct tep_handle *tep = tep_alloc();
\&.\&.\&.
struct tep_event *event = tep_find_event_by_name(tep, "kvm", "kvm_exit");
\&.\&.\&.
void process_record(struct tep_record *record)
{
        int len;
        char *comm;
        struct tep_event *event;
        unsigned long long val;

        event = tep_find_event_by_record(tep, record);
        if (event != NULL) {
                if (tep_get_common_field_val(NULL, event, "common_type",
                                             record, &val, 0) == 0) {
                        /* Got the value of common type field */
                }
                if (tep_get_field_val(NULL, event, "pid", record, &val, 0) == 0) {
                        /* Got the value of pid specific field */
                }
                comm = tep_get_field_raw(NULL, event, "comm", record, &len, 0);
                if (comm != NULL) {
                        /* Got a pointer to the comm event specific field */
                }
        }
}
.fi
.if n \{\
.RE
.\}
.SH "FILES"
.sp
.if n \{\
.RS 4
.\}
.nf
\fBevent\-parse\&.h\fR
        Header file to include in order to have access to the library APIs\&.
\fBtrace\-seq\&.h\fR
        Header file to include in order to have access to trace sequences
        related APIs\&. Trace sequences are used to allow a function to call
        several other functions to create a string of data to use\&.
\fB\-ltraceevent\fR
        Linker switch to add when building a program that uses the library\&.
.fi
.if n \{\
.RE
.\}
.SH "SEE ALSO"
.sp
\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>, author of \fBlibtraceevent\fR\&.
\fBTzvetomir Stoyanov\fR <\m[blue]\fBtz\&.stoyanov@gmail\&.com\fR\m[]\&\s-2\u[2]\d\s+2>, author of this man page\&.
.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
libtraceevent is Free Software licensed under the GNU LGPL 2\&.1
.SH "RESOURCES"
.sp
\m[blue]\fBhttps://git\&.kernel\&.org/pub/scm/libs/libtrace/libtraceevent\&.git/\fR\m[]
.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
