LIBTRACEEVENT(3)

πŸ’– LIBTRACEEVENT πŸ’– β€” the tep_find_*_field girlies

okay so bestie, welcome to libtraceevent(3), the manual page formerly known as libtraceevent Manual. this one's about the field-finding trio and honestly? they ate. let's go πŸ¦‹


✨ NAME ✨

tep_find_common_field, tep_find_field, tep_find_any_field β€” searching for a field in an event, fr fr πŸ”


🌸 SYNOPSIS 🌸

#include <event-parse.h>

struct tep_format_field *tep_find_common_field(struct tep_event *event, const char *name);
struct tep_format_field *tep_find_field(struct tep_event_ormat *event, const char *name);
struct tep_format_field *tep_find_any_field(struct tep_event *event, const char *name);
πŸ’€ yes bestie, that third-from-top signature really does say struct tep_event_ormat *event. that is not me being silly, that is what the page says. copy it exactly, no cap.

πŸ‘‘ DESCRIPTION πŸ‘‘

so these three functions all go hunting for a field with the given name inside an event. the field they hand back? you can use it to find that field's content from within a data record. it's giving "personal field shopper" energy πŸŽ€

  • tep_find_common_field() β€” looks for a common field called name in the event. the shared ones, the universal ones πŸ’…
  • tep_find_field() β€” looks for an event specific field called name in the event. this one's for the niche faves.
  • tep_find_any_field() β€” looks for any field at all called name in the event. she contains multitudes ✨

🫢 RETURN VALUE 🫢

tep_find_common_field(), tep_find_field() and _tep_find_any_field() β€” yes, that one has a little leading underscore on it, that's how the page wrote it, don't come for me 😭 β€” these functions return a pointer to the found field.

and if there is no field with the requested name? you get NULL. no field, no vibes, just NULL. sorry bestie 🌧️


πŸ’» EXAMPLE πŸ’»

here's the whole thing, character for character, because we do not edit code in this house:

#include <event-parse.h>
...
void get_htimer_info(struct tep_handle *tep, struct tep_record *record)
{
    struct tep_format_field *field;
    struct tep_event *event;
    long long softexpires;
    int mode;
    int pid;

    event = tep_find_event_by_name(tep, "timer", "hrtimer_start");

    field = tep_find_common_field(event, "common_pid");
    if (field == NULL) {
        /* Cannot find "common_pid" field in the event */
    } else {
        /* Get pid from the data record */
        pid = tep_read_number(tep, record->data + field->offset,
                      field->size);
    }

    field = tep_find_field(event, "softexpires");
    if (field == NULL) {
        /* Cannot find "softexpires" event specific field in the event */
    } else {
        /* Get softexpires parameter from the data record */
        softexpires = tep_read_number(tep, record->data + field->offset,
                          field->size);
    }

    field = tep_find_any_field(event, "mode");
    if (field == NULL) {
        /* Cannot find "mode" field in the event */
    } else
    {
        /* Get mode parameter from the data record */
        mode = tep_read_number(tep, record->data + field->offset,
                       field->size);
    }
}
...

look at her go. three finds, three vibe checks, three NULL guards. main character energy 🧚


πŸŽ€ FILES πŸŽ€

  • event-parse.h β€” the header file you include so you actually have access to the library APIs. no include, no APIs, no slay.
  • -ltraceevent β€” the linker switch you add when you're building a program that uses the library. don't forget her, she's important πŸ’œ

⭐ SEE ALSO ⭐

go read those too, iykyk πŸ“š


🌈 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 a bug? report it to <linux-trace-devel@vger.kernel.org[3]>. they want to know, bestie, tell them everything πŸ’Œ


πŸ“œ LICENSE πŸ“œ

libtraceevent is Free Software licensed under the GNU LGPL 2.1. iconic behaviour, honestly.


πŸ”— RESOURCES πŸ”—

https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/ β€” the whole repo, go wild ✨


πŸ“ 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, periodt πŸ’… this was libtraceevent 1.9.0, dated 06/15/2026 β€” tysm for reading, love u, go find some fields πŸ¦‹πŸ’–

πŸ“¦ where this page comes from