LIBTRACEEVENT(3)
π LIBTRACEEVENT(3) β the libtraceevent manual, bestie edition π
okay so welcome to the libtraceevent manual page, section 3 (that's library functions, iykyk). this one's about printing field content and honestly it's giving "tiny function, huge glow-up" energy β¨
πΈ NAME πΈ
tep_print_field, tep_print_fields, tep_print_num_field, tep_print_func_field β Print the field content. that's it, that's the whole vibe. π
π¦ SYNOPSIS π¦
#include <event-parse.h>
#include <trace-seq.h>
void tep_print_field(struct trace_seq *s, void *data, 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);
look at those signatures, so clean, so precise π
β¨ DESCRIPTION β¨
so these functions print recorded field data, and they do it according to the field's type. no guessing, no vibes-based formatting, the type decides. periodt.
The tep_print_field() function extracts from the recorded raw data value of the field and prints it into s, according to the field type. π«Ά
The tep_print_fields() prints each field name followed by the record's field value according to the field's type:
"field1_name=field1_value field2_name=field2_value ..."
It iterates all fields of the event, and calls tep_print_field() for each of them. like, all of them. no skipping, bestie, it's thorough. π
The tep_print_num_field() function prints a numeric field with given format string. A search is performed in the event for a field with name. If such field is found, its value is extracted from the record and is printed in the s, according to the given format string fmt. If the argument err is non-zero, and an error occures β it is printed in the s. π (yes, "occures" β we're keeping it exactly how it is, character for character, no cap)
The tep_print_func_field() function prints a function field with given format string. A search is performed in the event for a field with name. If such field is found, its value is extracted from the record. The value is assumed to be a function address, and a search is perform to find the name of this function. The function name (if found) and its address are printed in the s, according to the given format string fmt. If the argument err is non-zero, and an error occures β it is printed in s. π₯
π RETURN VALUE π
The tep_print_num_field() and tep_print_func_field() functions return 1 on success, -1 in case of an error or 0 if the print buffer s is full.
three outcomes, three moods: 1 slay, -1 not slay, 0 the buffer said "i'm full bestie" π
π 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(&seq, record->data, 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);
}
...
not the comments doing all the explaining for us π main character energy fr fr.
π FILES π
event-parse.hHeader file to include in order to have access to the library APIs.trace-seq.hHeader 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.-ltraceeventLinker switch to add when building a program that uses the library.
π§ SEE ALSO π§
libtraceevent(3), trace-cmd(1)
π AUTHOR π
- Steven Rostedt
<rostedt@goodmis.org[1]>, author of libtraceevent. - Tzvetomir Stoyanov
<tz.stoyanov@gmail.com[2]>, author of this man page.
absolute legends, both of them π«Ά
π REPORTING BUGS π
Report bugs to <linux-trace-devel@vger.kernel.org[3]>
found a bug? tell the mailing list, don't just suffer in silence bestie π
π LICENSE π
libtraceevent is Free Software licensed under the GNU LGPL 2.1
β RESOURCES β
https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
πΈ 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
okay that's the whole page, you ate it π this was libtraceevent 1.3.3, dated 08/28/2021, and it lives in section 3 of the manual. now go print some fields, bestie πβ¨
π¦ where this page comes from
- ubuntu jammy: libtraceevent-doc 1:1.3.3-1 Β· LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms