LIBTRACEEVENT(3)

πŸ’– NAME πŸ’–

tep_read_number_field β€” bestie, it reads a number out of raw data. that's it, that's the whole job πŸ’…

so like, this is your girl libtraceevent(3) and she's here to help you pull an actual number out of a pile of raw bytes. iconic behavior tbh.


✨ SYNOPSIS ✨

#include <event-parse.h>

int tep_read_number_field(struct tep_format_field *field, const void *data, unsigned long long *value);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so the way tep_read_number_field() works is: it reads the value of the field straight out of the raw data, and then it stores it in value. no cap.

and here's the cute part β€” it sets that value according to the endianness of the raw data and the endianness of the current machine, then stores it in value. so it's giving endianness-aware, it's giving portability, it's literally doing the byte math so you don't have to πŸ™ˆβœ¨


πŸŽ€ RETURN VALUE πŸŽ€

  • 0 β€” slay, success, we ate πŸ“
  • -1 β€” uh oh, an error happened 😭

🌸 EXAMPLE 🌸

#include <event-parse.h>
...
struct tep_handle *tep = tep_alloc();
...
struct tep_event *event = tep_find_event_by_name(tep, "timer", "hrtimer_start");
...
void process_record(struct tep_record *record)
{
        unsigned long long pid;
        struct tep_format_field *field_pid = tep_find_common_field(event, "common_pid");

        if (tep_read_number_field(field_pid, record->data, &pid) != 0) {
                /* Failed to get "common_pid" value */
        }
}
...

see how she grabbed the common_pid field and just… pulled the number right out of record->data? main character energy fr fr πŸ‘‘


🧚 FILES 🧚

  • event-parse.h β€” the header file you gotta include so you can have access to the library APIs. yes bestie, you need it, don't skip it πŸ’œ
  • -ltraceevent β€” the linker switch you add when building a program that uses the library. it's giving "don't forget to link me" 🌈

πŸ’« SEE ALSO πŸ’«

libtraceevent(3), trace-cmd(1)

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.

(the legends themselves, no big deal πŸ’…)


😭 REPORTING BUGS 😭

found something cursed? report bugs to <linux-trace-devel@vger.kernel.org[3]> β€” they wanna know, fr fr πŸ’€


πŸ’– LICENSE πŸ’–

libtraceevent is Free Software licensed under the GNU LGPL 2.1. free as in freedom, bestie πŸ¦‹


⭐ RESOURCES ⭐

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

(the sacred texts πŸ“œβœ¨)


πŸŽ€ 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 it lives in section LIBTRACEEVENT(3) of the manual. periodt. πŸ’…πŸŒΈ

πŸ“¦ where this page comes from