|
NAME | SYNOPSIS | DESCRIPTION | RETURN VALUE | EXAMPLE | FILES | SEE ALSO | AUTHOR | REPORTING BUGS | LICENSE | RESOURCES | NOTES | COLOPHON |
|
|
|
LIBTRACEEVENT(3) libtraceevent Manual LIBTRACEEVENT(3)
tep_btf_list_args - Show the arguments of a function from BTF
#include <event-parse.h>
int tep_btf_list_args(struct tep_handle *tep, struct trace_seq *s, const char *func);
If the Linux kernel has BTF configured, then a binary file will
exist in the path of /sys/kernel/btf/vmlinux. If this file is read
into memory and passed to tep_load_btf() function, then it can be
used to read the arguments of a given function, if that function
data is found within the BTF file.
The tep_btf_print_args() takes a tep handle, a trace_seq s pointer
(that was initialized by trace_seq_init(3)), and a func string
that is the name of the function to find the BTF information to
use to print the function’s prototype. If BTF is not loaded or the
func name is not found it will return a negative.
tep_btf_list_args() returns the number of arguments read on
success and -1 on failure (for example, if the function is not
found).
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <event-parse.h>
#include <sys/stat.h>
#include <unistd.h>
#define BTF_FILE "/sys/kernel/btf/vmlinux"
int main(int argc, char **argv)
{
struct tep_handle *tep;
struct trace_seq s;
struct stat st;
char *buf;
int fd, r, z;
if (argc < 2)
exit(-1);
if (stat(BTF_FILE, &st) < 0) {
perror(BTF_FILE);
exit(-1);
}
buf = malloc(st.st_size);
if (!buf)
exit(-1);
fd = open(BTF_FILE, O_RDONLY);
if (fd < 0) {
perror(BTF_FILE);
exit(-1);
}
for (z = 0; z < st.st_size; ) {
r = read(fd, buf + z, st.st_size - z);
if (r <= 0)
break;
z += r;
}
close(fd);
tep = tep_alloc();
if (!tep)
exit(-1);
tep_load_btf(tep, buf, z);
free(buf);
trace_seq_init(&s);
tep_btf_list_args(tep, &s, argv[1]);
printf("%s(", argv[1]);
trace_seq_do_printf(&s);
printf(")\n");
exit(0);
}
event-parse.h
Header file to include in order to have access to the library APIs.
-ltraceevent
Linker switch to add when building a program that uses the library.
tep_btf_load(3), tep_btf_print_args(3), libtraceevent(3),
trace-cmd(1)
Steven Rostedt <rostedt@goodmis.org[1]>, author of libtraceevent.
Report bugs to <linux-trace-devel@vger.kernel.org[2]>
libtraceevent is Free Software licensed under the GNU LGPL 2.1
https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
1. rostedt@goodmis.org
mailto:rostedt@goodmis.org
2. linux-trace-devel@vger.kernel.org
mailto:linux-trace-devel@vger.kernel.org
This page is part of the libtraceevent (Linux kernel trace event
library) project. Information about the project can be found at
⟨https://www.trace-cmd.org/⟩. If you have a bug report for this
manual page, see ⟨https://www.trace-cmd.org/⟩. This page was
obtained from the project's upstream Git repository
⟨https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git⟩
on 2026-05-24. (At that time, the date of the most recent commit
that was found in the repository was 2026-02-04.) If you discover
any rendering problems in this HTML version of the page, or you
believe there is a better or more up-to-date source for the page,
or you have corrections or improvements to the information in this
COLOPHON (which is not part of the original manual page), send a
mail to man-pages@man7.org
libtraceevent 1.9.0 05/24/2026 LIBTRACEEVENT(3)