LIBTRACEEVENT(3)
π LIBTRACEEVENT(3) β the manual page, but make it make sense π
okay bestie, listen up π«Ά this is a page from the libtraceevent manual (section 3, the library-functions section, iykyk). It's all about printing field content. Yes really. And it's lowkey iconic.
πΈ NAME πΈ
tep_print_field_content, tep_print_fields, tep_print_num_field, tep_print_func_field, tep_record_print_fields, tep_record_print_selected_fields β literally all of these just print the field content. That's the whole job. Slay. β¨
π SYNOPSIS π
#include <event-parse.h>
#include <trace-seq.h>
void tep_print_field_content(struct trace_seq *s, void *data, int size, struct tep_format_field *field);
void tep_print_fields(struct trace_seq *s, void *data, int size, struct tep_event *event);
int tep_print_num_field(struct trace_seq *s, const char *fmt, struct tep_event *event, const char *name, struct tep_record *record, int err);
int tep_print_func_field(struct trace_seq *s, const char *fmt, struct tep_event *event, const char *name, struct tep_record *record, int err);
void tep_record_print_fields(struct trace_seq *s, struct tep_record *record, struct tep_event *event);
void tep_record_print_selected_fields(struct trace_seq *s, struct tep_record *record, struct tep_event *event, int select_mask);
π¦ DESCRIPTION π¦
so these functions print recorded field's data, and they figure out how to print it based on the field's type. no cap, that's the whole vibe. π
tep_print_field_content() β this one reaches into the recorded raw data, grabs the value of the field, and prints it into s, according to the field type. it's giving "extract and deliver". π
tep_print_fields() β prints every field name followed by that record's field value, according to the field's type, in exactly this shape:
"field1_name=field1_value field2_name=field2_value ..."
it loops over all the fields of the event, and calls tep_print_field_content() on each of them. obsessed with the delegation honestly. π
tep_print_num_field() β prints a numeric field using a format string you give it. it does a search in the event for a field with the given name. if it finds that field, the value gets extracted from the record and printed into s, according to the given format string fmt. and if the err argument is non-zero, and an error happens, that error gets printed into s too. π«Ά
tep_print_func_field() β prints a function field using a format string you give it. it searches the event for a field with the given name. if it finds it, the value is extracted from the record. the value is assumed to be a function address, and then a search happens to find the name of that function. the function name (if it was found) and its address get printed into s, according to the given format string fmt. if the err argument is non-zero and an error happens, it's printed into s. β¨
tep_record_print_fields() β prints the field's name followed by its value, for all of the record's fields. all of them. every single one. π
tep_record_print_selected_fields() β same idea, but for a selected subset of the record's fields. which ones? whichever ones the select_mask bit mask says. that bit mask is the whole mood. π
β RETURN VALUE β
tep_print_num_field() and tep_print_func_field() return 1 on success, -1 if there's an error, or 0 if the print buffer s is full. three outcomes, no in-between. π
π EXAMPLE π
#include <event-parse.h>
#include <trace-seq.h>
...
struct tep_handle *tep = tep_alloc();
...
struct trace_seq seq;
trace_seq_init(&seq);
struct tep_event *event = tep_find_event_by_name(tep, "timer", "hrtimer_start");
...
void process_record(struct tep_record *record)
{
struct tep_format_field *field_pid = tep_find_common_field(event, "common_pid");
trace_seq_reset(&seq);
/* Print the value of "common_pid" */
tep_print_field_content(&seq, record->data, record->size, field_pid);
/* Print all fields of the "hrtimer_start" event */
tep_print_fields(&seq, record->data, record->size, event);
/* Print the value of "expires" field with custom format string */
tep_print_num_field(&seq, " timer expires in %llu ", event, "expires", record, 0);
/* Print the address and the name of "function" field with custom format string */
tep_print_func_field(&seq, " timer function is %s ", event, "function", record, 0);
}
...
yes bestie, that's the whole sample. copy it, it eats. π₯
π FILES π
event-parse.hβ the header file you include so you can actually get at the library APIs. no include, no access, that's the rule.trace-seq.hβ the header file you include to get the trace sequences related APIs. trace sequences are what let a function call several other functions to build up a string of data to use. teamwork makes the dream work, fr fr. π-ltraceeventβ the linker switch you add when you're building a program that uses the library. don't forget it, she's required. π«Ά
πΈ SEE ALSO πΈ
libtraceevent(3), trace-cmd(1)
go read those next, bestie, the lore is deep.
β¨ AUTHOR β¨
- Steven Rostedt
<rostedt@goodmis.org[1]>β author of libtraceevent. the founder. the main character. π - Tzvetomir Stoyanov
<tz.stoyanov@gmail.com[2]>β author of this man page. yes this one. iconic behaviour. π
π REPORTING BUGS π
found a bug? report it to <linux-trace-devel@vger.kernel.org[3]>. they want to know. genuinely. don't be shy. π¦
π LICENSE π
libtraceevent is Free Software, licensed under the GNU LGPL 2.1. periodt.
π RESOURCES π
https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
the repo. the source of truth. go look. β¨
π NOTES π
rostedt@goodmis.orgmailto:rostedt@goodmis.orgtz.stoyanov@gmail.commailto:tz.stoyanov@gmail.comlinux-trace-devel@vger.kernel.orgmailto:linux-trace-devel@vger.kernel.org
and that's the whole page, bestie π this was libtraceevent 1.9.0, dated 06/15/2026 β write that down, cite it in your paper, put it on your vision board, whatever you need to do. mwah. πβ¨π·
π¦ where this page comes from
- ubuntu stonking: libtraceevent-doc 1:1.9.0-2 Β· LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms