LIBTRACEEVENT(3)

πŸ’– LIBTRACEEVENT(3) πŸ’–

okay bestie, welcome to the libtraceevent manual ✨ you're in the right place, this is where the lore lives 🫢


🌸 NAME 🌸

tep_find_function, tep_find_function_address, tep_find_function_info β€” the trio that goes "hey, what function is at this address, and where does it start?" πŸ”


✨ SYNOPSIS ✨

#include <event-parse.h>

const char *tep_find_function(struct tep_handle *tep, unsigned long long addr);
unsigned long long tep_find_function_address(struct tep_handle *tep, unsigned long long addr);
int tep_find_function_info(struct tep_handle *tep, unsigned long long addr, const char **name,
                           unsigned long long *start, unsigned long *size);

πŸ‘‘ DESCRIPTION πŸ‘‘

so like, these functions are your little address detectives πŸ•΅οΈβ™€οΈ you hand them an address, and they find the function name and the start address for you. and here's the cute part β€” the address you give does NOT have to be exact. it'll just pick the function that would contain it. no precision anxiety needed, she's flexible πŸ’…

tep_find_function() gives you back the function name, the one that contains the address addr you passed in. the tep argument is the trace event parser context, keep that close, she's important.

tep_find_function_address() gives you back the function's start address, based on the address addr you gave it. and again β€” addr doesn't need to be exact, it selects whatever function would contain it. tep is the trace event parser context, same as always 🫢

tep_find_function_info() gets you the name, the starting address (start), and the function text size of the function at that address β€” but only if it's found. ⚠️ lil heads up: if the tep handle has a function resolver (that's the one perf uses), then size gets set to zero. not a bug, just how it is, iykyk.


πŸ¦‹ RETURN VALUE πŸ¦‹

  • tep_find_function() β€” returns the function name, or NULL if it can't be found 😭
  • tep_find_function_address() β€” returns the function start address, or 0 if it can't be found πŸ™ˆ
  • tep_find_function_info() β€” returns 1 if a function is found for that address, or 0 if it's not ✨

πŸ“ EXAMPLE πŸ“

here's how it looks in the wild, fr fr:

#include <event-parse.h>
...
struct tep_handle *tep = tep_alloc();
...
void show_function_name(unsigned long long addr)
{
        const char *fname = tep_find_function(tep, addr);

        if (fname)
                printf("Found function %s at 0x%0llx\n", fname, addr);
        else
                printf("No function found at 0x%0llx\n", addr);
}

void show_function_start_addr(unsigned long long addr)
{
        const char *fname = tep_find_function(tep, addr);
        unsigned long long fstart;

        if (!fname) {
                printf("No function found at 0x%0llx\n", addr);
                return;
        }

        fstart = tep_find_function_address(tep, addr);
        printf("Function %s at 0x%llx starts at 0x%0llx\n",
               fname, addr, fstart);
}

void show_function_info(unsigned long long addr)
{
        const char *fname;
        unsigned long long fstart;
        unsigned long size;

        ret = tep_find_function_info(tep, addr, &fname, &fstart, &size);
        if (!ret) {
                printf("No function found at 0x%0lx\n", addr);
                return;
        }

        printf("Function %s at 0x%lx starts at 0x%0lx and is %ld in size\n",
               fname, addr, fstart, size);
}
...

πŸŽ€ FILES πŸŽ€

  • event-parse.h β€” the header file you include so you can actually touch the library APIs πŸ’–
  • -ltraceevent β€” the linker switch you add when building a program that uses this library πŸ”—

🌈 SEE ALSO 🌈

libtraceevent(3), trace-cmd(1)


πŸ’œ AUTHOR πŸ’œ

  • Steven Rostedt <rostedt@goodmis.org[1]>, author of libtraceevent. absolute icon πŸ‘‘
  • Tzvetomir Stoyanov <tz.stoyanov@gmail.com[2]>, author of this man page. thank you for your service 🫑

😀 REPORTING BUGS 😀

found a bug? don't suffer in silence bestie, report it to <linux-trace-devel@vger.kernel.org[3]> πŸ“¬


⭐ LICENSE ⭐

libtraceevent is Free Software licensed under the GNU LGPL 2.1 β€” free as in freedom, periodt πŸ’…


🧚 RESOURCES 🧚

https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/


πŸ“ NOTES πŸ“

  1. rostedt@goodmis.org mailto:rostedt@goodmis.org
  2. tz.stoyanov@gmail.com mailto:tz.stoyanov@gmail.com
  3. linux-trace-devel@vger.kernel.org mailto:linux-trace-devel@vger.kernel.org

and that's the whole vibe check βœ… this was libtraceevent 1.9.0, dated 06/15/2026, and you've been reading the LIBTRACEEVENT(3) page the whole time πŸŽ€ ily, go find some functions πŸ’–βœ¨

πŸ“¦ where this page comes from