LIBTRACEEVENT(3)

πŸ’– libtraceevent β€” the pretty-girl guide to LIBTRACEEVENT(3) πŸ’–

okay so bestie, welcome to the manual page for libtraceevent's field-getting era ✨ this is section 3 of the manual, and we're about to be so normal about retrieving field values, i promise πŸŽ€


✨ NAME ✨

tep_get_any_field_val, tep_get_common_field_val, tep_get_field_val, tep_get_field_raw β€” the girlies that go get you the value of a field πŸ’…


✨ SYNOPSIS ✨

#include <event-parse.h>
#include <trace-seq.h>

int tep_get_any_field_val(struct trace_seq *s, struct tep_event *event, const char *name, struct tep_record *record, unsigned long long *val, int err);
int tep_get_common_field_val(struct trace_seq *s, struct tep_event *event, const char *name, struct tep_record *record, unsigned long long *val, int err);
int tep_get_field_val(struct trace_seq *s, struct tep_event *event, const char *name, struct tep_record *record, unsigned long long *val, int err);
void *tep_get_field_raw(struct trace_seq *s, struct tep_event *event, const char *name, struct tep_record *record, int *len, int err);

✨ DESCRIPTION ✨

so these four functions are literally your little search party πŸ•΅οΈβ€β™€οΈ they go find a field and pull out its value, no cap.

tep_get_any_field_val() β€” she searches through the record for a field with name, part of the event. πŸ‘‘ if the field is found, its value gets stored in val. and if something goes wrong and err is not zero, then an error string gets written into s. not me exposing the error like that 😭

tep_get_common_field_val() β€” does the exact same thing as tep_get_any_field_val(), but she only searches the common fields. and this lowkey works for literally any event, because every single event includes the common fields. it's giving universal access, periodt. 🌈

tep_get_field_val() β€” again, same energy as tep_get_any_field_val(), but she only searches the event specific fields. so niche of her, we stan. πŸ¦‹

tep_get_field_raw() β€” she searches the record for a field with name, part of the event. if the field is found, you get back a pointer to where that field actually lives inside the record's raw data πŸ”₯. the size of the data gets stored in len. and again, if there's an error and err is not zero, an error string gets written into s 🀧


✨ RETURN VALUE ✨

tep_get_any_field_val(), tep_get_common_field_val() and tep_get_field_val() return 0 on success πŸ’š, or -1 in case of an error πŸ’€.

tep_get_field_raw() returns a pointer to the field's raw data, and places the length of that data in len. in case of an error, NULL is returned πŸ™ˆ


✨ EXAMPLE ✨

bestie this is the whole vibe, look:

#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 */
                }
        }
}

✨ FILES ✨

  • event-parse.h β€” the header file you include to get access to the library APIs πŸ’œ
  • trace-seq.h β€” the header file you include to get access to trace sequences related APIs. trace sequences are used to let a function call a bunch of other functions and cook up a string of data to use. chef's kiss πŸ‘©β€πŸ³
  • -ltraceevent β€” the linker switch you add when you're building a program that uses the library πŸ”—

✨ SEE ALSO ✨

libtraceevent(3), trace-cmd(1) β€” go read these too, i'm obsessed 🫢


✨ AUTHOR ✨

  • Steven Rostedt <rostedt@goodmis.org[1]>, author of libtraceevent πŸ‘‘
  • Tzvetomir Stoyanov <tz.stoyanov@gmail.com[2]>, author of this man page πŸŽ€

✨ REPORTING BUGS ✨

found something cursed?? report bugs to <linux-trace-devel@vger.kernel.org[3]> πŸ“¬


✨ LICENSE ✨

libtraceevent is Free Software licensed under the GNU LGPL 2.1 βš–οΈ


✨ RESOURCES ✨

https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/


✨ NOTES ✨

  1. rostedt@goodmis.org mailto:rostedt@goodmis.org
  2. tz.stoyanov@gmail.com mailto:tz.stoyanov@gmail.com
  3. linux-trace-devel@vger.kernel.org mailto:linux-trace-devel@vger.kernel.org

~ and that's the whole page, bestie ~ this was libtraceevent 1.9.0, dated 06/15/2026, and you just read LIBTRACEEVENT(3) πŸ’–βœ¨πŸŽ€ slay, go get those field values, i'll be right here cheering πŸ¦‹πŸ’…

πŸ“¦ where this page comes from