1LIBTRACEEVENT(3) libtraceevent Manual LIBTRACEEVENT(3)
2
3
4
6 tep_find_function, tep_find_function_address, tep_find_function_info -
7 Find function name / start address.
8
10 #include <event-parse.h>
11
12 const char *tep_find_function(struct tep_handle *tep, unsigned long long addr);
13 unsigned long long tep_find_function_address(struct tep_handle *tep, unsigned long long addr);
14 int tep_find_function_info(struct tep_handle *tep, unsigned long long addr, const char **name,
15 unsigned long long *start, unsigned long *size);
16
18 These functions can be used to find function name and start address, by
19 given address. The given address does not have to be exact, it will
20 select the function that would contain it.
21
22 The tep_find_function() function returns the function name, which
23 contains the given address addr. The tep argument is the trace event
24 parser context.
25
26 The tep_find_function_address() function returns the function start
27 address, by given address addr. The addr does not have to be exact, it
28 will select the function that would contain it. The tep argument is the
29 trace event parser context.
30
31 The tep_find_function_info() function retrieves the name, starting
32 address (start), and the function text size of the function at address,
33 if it is found. Note, if the tep handle has a function resolver (used
34 by perf), then size is set to zero.
35
37 The tep_find_function() function returns the function name, or NULL in
38 case it cannot be found.
39
40 The tep_find_function_address() function returns the function start
41 address, or 0 in case it cannot be found.
42
43 The tep_find_function_info() function returns 1 if a function is found
44 for the given address, or 0 if it is not.
45
47 #include <event-parse.h>
48 ...
49 struct tep_handle *tep = tep_alloc();
50 ...
51 void show_function_name(unsigned long long addr)
52 {
53 const char *fname = tep_find_function(tep, addr);
54
55 if (fname)
56 printf("Found function %s at 0x%0llx\n", fname, addr);
57 else
58 printf("No function found at 0x%0llx\n", addr);
59 }
60
61 void show_function_start_addr(unsigned long long addr)
62 {
63 const char *fname = tep_find_function(tep, addr);
64 unsigned long long fstart;
65
66 if (!fname) {
67 printf("No function found at 0x%0llx\n", addr);
68 return;
69 }
70
71 fstart = tep_find_function_address(tep, addr);
72 printf("Function %s at 0x%llx starts at 0x%0llx\n",
73 fname, addr, fstart);
74 }
75
76 void show_function_info(unsigned long long addr)
77 {
78 const char *fname;
79 unsigned long long fstart;
80 unsigned long size;
81
82 ret = tep_find_function_info(tep, addr, &fname, &fstart, &size);
83 if (!ret) {
84 printf("No function found at 0x%0lx\n", addr);
85 return;
86 }
87
88 printf("Function %s at 0x%lx starts at 0x%0lx and is %ld in size\n",
89 fname, addr, fstart, size);
90 }
91 ...
92
94 event-parse.h
95 Header file to include in order to have access to the library APIs.
96 -ltraceevent
97 Linker switch to add when building a program that uses the library.
98
100 libtraceevent(3), trace-cmd(1)
101
103 Steven Rostedt <rostedt@goodmis.org[1]>, author of libtraceevent.
104 Tzvetomir Stoyanov <tz.stoyanov@gmail.com[2]>, author of this man page.
105
107 Report bugs to <linux-trace-devel@vger.kernel.org[3]>
108
110 libtraceevent is Free Software licensed under the GNU LGPL 2.1
111
113 https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
114
116 1. rostedt@goodmis.org
117 mailto:rostedt@goodmis.org
118
119 2. tz.stoyanov@gmail.com
120 mailto:tz.stoyanov@gmail.com
121
122 3. linux-trace-devel@vger.kernel.org
123 mailto:linux-trace-devel@vger.kernel.org
124
125
126
127libtraceevent 1.7.2 07/20/2023 LIBTRACEEVENT(3)