From: Steven Rostedt <rostedt@goodmis.org>
To: "MOESSBAUER, Felix" <felix.moessbauer@siemens.com>
Cc: "Kiszka, Jan" <jan.kiszka@siemens.com>,
"Poljakow, Andre" <andre.poljakow@siemens.com>,
"linux-trace-devel@vger.kernel.org"
<linux-trace-devel@vger.kernel.org>
Subject: Re: libtraceevent | API clarifications needed
Date: Wed, 3 Dec 2025 11:07:05 -0500 [thread overview]
Message-ID: <20251203110705.714daa5e@gandalf.local.home> (raw)
In-Reply-To: <a22fa13aad752c43c927ab42b71d8e9caf7bf573.camel@siemens.com>
On Wed, 3 Dec 2025 11:20:34 +0000
"MOESSBAUER, Felix" <felix.moessbauer@siemens.com> wrote:
> > First I'll say that I absolutely hate the libtraceevent interface.
> > Unfortunately, it was ported over to perf before it was "sanitized". But oh
> > well, I have to live with it. I would love to come up with a new interface
> > that would make all this easier.
>
> No need for excuses. The library is great and tremendously simplifies
> working with trace events. Thank you!
Not an excuse. I curse the API all the time ;-)
I wrote it, but I still need to reference the man pages to figure out how
to use it. If the author can't use their own API without referencing a
manual, that's a sure sign that the API sucks!
> > If tep->file_bigendian != tep_is_bigendian() then a swap is needed.
>
> Ok, but I just found the tep_read_number() interface which I'm now
> using as following:
>
> data_raw=tep_get_field_raw(NULL, trace_event, field->name, rec, &len,
> 0);
> item_size=len / field->arraylen;
> val=tep_read_number(field->event->tep, &data_raw[i * item_size], len);
>
> This should also do the job, as tep_read_number() takes care of the
> endianess handling.
Great!
> > >
> > > symbolic fields
> > >
> > > How to get the symbolic representation of fields that are marked
> > > TEP_FIELD_IS_SYMBOLIC (example: softirq_entry->vec)? I tried
> > > tep_print_field_content, but this converts the data to a string integer
> > > instead of the symbolic representation (e.g. I get a "0" instead of a
> > > "HI").
> >
> > This is something I even wanted, but there's not really a good way to do
> > it. Although, I wanted a generic way, but if a field is marked symbolic, we
> > could use that. That is, we would need to parse the print_fmt array itself,
> > and find the:
> >
> > "__print_symbolic(REC->vec, { 0, "HI" }, { 1, "TIMER" }, { 2, "NET_TX" }, { 3, "NET_RX" }, { 4, "BLOCK" }, { 5, "IRQ_POLL" }, { 6, "TASKLET" }, { 7, "SCHED" }, { 8, "HRTIMER" }, { 9, "RCU" })"
> >
> > That is, look for the "__print_symbolic(REC->[FIELD-NAME], ..." and parse that.
>
> The trace-cmd report seems to be able to symbolize this, as well as
> symbolizing instruction pointers (e.g. the caller field of the ftrace
> kernel_stack). Not that I currently need this, but I'm wondering how
> trace-cmd is able to do this. Probably need to check the sources.
>
Probably due to plugins. Run: trace-cmd report -N
If it still shows things properly, then it did do something special.
Otherwise a plugin took over. They are in libtraceevent, in the plugins
directory. There are several plugins that override how an event is read and
it does the work manually.
-- Steve
prev parent reply other threads:[~2025-12-03 16:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 15:38 libtraceevent | API clarifications needed MOESSBAUER, Felix
2025-12-02 16:25 ` Steven Rostedt
2025-12-03 11:20 ` MOESSBAUER, Felix
2025-12-03 16:07 ` Steven Rostedt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251203110705.714daa5e@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=andre.poljakow@siemens.com \
--cc=felix.moessbauer@siemens.com \
--cc=jan.kiszka@siemens.com \
--cc=linux-trace-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox