That's sort of how Linux kernel trace-events are implemented [1]. E.g.<p><pre><code> DECLARE_EVENT_CLASS(sched_wakeup_template,
TP_PROTO(struct task_struct *p),
TP_ARGS(__perf_task(p)),
TP_STRUCT__entry(
__array( char, comm, TASK_COMM_LEN )
__field( pid_t, pid )
__field( int, prio )
__field( int, target_cpu )
),
TP_fast_assign(
memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
__entry->pid = p->pid;
__entry->prio = p->prio; /* XXX SCHED_DEADLINE */
__entry->target_cpu = task_cpu(p);
),
TP_printk("comm=%s pid=%d prio=%d target_cpu=%03d",
__entry->comm, __entry->pid, __entry->prio,
__entry->target_cpu)
);
</code></pre>
[1] <a href="https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/trace/events/sched.h?h=v6.14" rel="nofollow">https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds...</a>