]> git.proxmox.com Git - mirror_frr.git/blame - lib/libfrr_trace.h
Merge pull request #13278 from FRRouting/mergify/bp/stable/8.5/pr-13269
[mirror_frr.git] / lib / libfrr_trace.h
CommitLineData
0cbcadcc
QY
1/* Tracing
2 *
3 * Copyright (C) 2020 NVIDIA Corporation
4 * Quentin Young
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
912d45a1
QY
21#if !defined(_LIBFRR_TRACE_H_) || defined(TRACEPOINT_HEADER_MULTI_READ)
22#define _LIBFRR_TRACE_H_
0cbcadcc 23
c7bb4f00 24#include "trace.h"
0cbcadcc
QY
25
26#ifdef HAVE_LTTNG
27
28#undef TRACEPOINT_PROVIDER
29#define TRACEPOINT_PROVIDER frr_libfrr
30
31#undef TRACEPOINT_INCLUDE
912d45a1 32#define TRACEPOINT_INCLUDE "./libfrr_trace.h"
0cbcadcc 33
0cbcadcc 34#include <lttng/tracepoint.h>
abf96a87
QY
35
36#include "hash.h"
37#include "thread.h"
d92658f4
QY
38#include "memory.h"
39#include "linklist.h"
a72255a3 40#include "table.h"
abf96a87
QY
41
42/* clang-format off */
43
44TRACEPOINT_EVENT(
45 frr_libfrr,
46 hash_get,
47 TP_ARGS(struct hash *, hash, void *, data),
48 TP_FIELDS(
49 ctf_string(name, hash->name ? hash->name : "(unnamed)")
50 ctf_integer(unsigned int, index_size, hash->size)
51 ctf_integer(unsigned long, item_count, hash->count)
52 ctf_integer_hex(intptr_t, data_ptr, data)
53 )
54)
55
56TRACEPOINT_LOGLEVEL(frr_libfrr, hash_get, TRACE_INFO)
57
67a485d1
QY
58TRACEPOINT_EVENT(
59 frr_libfrr,
60 hash_insert,
61 TP_ARGS(struct hash *, hash, void *, data, unsigned int, key),
62 TP_FIELDS(
63 ctf_string(name, hash->name ? hash->name : "(unnamed)")
64 ctf_integer(unsigned int, key, hash->size)
65 ctf_integer(unsigned int, index_size, hash->size)
66 ctf_integer(unsigned long, item_count, hash->count)
67 ctf_integer_hex(intptr_t, data_ptr, data)
68 )
69)
70
71TRACEPOINT_LOGLEVEL(frr_libfrr, hash_insert, TRACE_INFO)
72
abf96a87
QY
73TRACEPOINT_EVENT(
74 frr_libfrr,
75 hash_release,
76 TP_ARGS(struct hash *, hash, void *, data, void *, released_item),
77 TP_FIELDS(
78 ctf_string(name, hash->name ? hash->name : "(unnamed)")
79 ctf_integer(unsigned int, index_size, hash->size)
80 ctf_integer(unsigned long, item_count, hash->count)
81 ctf_integer_hex(intptr_t, data_ptr, data)
82 ctf_integer_hex(intptr_t, released_item, data)
83 )
84)
85
86TRACEPOINT_LOGLEVEL(frr_libfrr, hash_release, TRACE_INFO)
87
88#define THREAD_SCHEDULE_ARGS \
89 TP_ARGS(struct thread_master *, master, const char *, funcname, \
90 const char *, schedfrom, int, fromln, struct thread **, \
91 thread_ptr, int, fd, int, val, void *, arg, long, time)
92
93TRACEPOINT_EVENT_CLASS(
94 frr_libfrr,
95 thread_operation,
96 THREAD_SCHEDULE_ARGS,
97 TP_FIELDS(
98 ctf_string(threadmaster_name, master->name)
99 ctf_string(function_name, funcname ? funcname : "(unknown function)")
100 ctf_string(scheduled_from, schedfrom ? schedfrom : "(unknown file)")
101 ctf_integer(int, scheduled_on_line, fromln)
102 ctf_integer_hex(intptr_t, thread_addr, thread_ptr ? *thread_ptr : NULL)
103 ctf_integer(int, file_descriptor, fd)
104 ctf_integer(int, event_value, val)
105 ctf_integer_hex(intptr_t, argument_ptr, arg)
106 ctf_integer(long, timer, time)
107 )
108)
109
110#define THREAD_OPERATION_TRACEPOINT_INSTANCE(name) \
111 TRACEPOINT_EVENT_INSTANCE(frr_libfrr, thread_operation, name, \
112 THREAD_SCHEDULE_ARGS) \
113 TRACEPOINT_LOGLEVEL(frr_libfrr, name, TRACE_INFO)
114
115THREAD_OPERATION_TRACEPOINT_INSTANCE(schedule_timer)
116THREAD_OPERATION_TRACEPOINT_INSTANCE(schedule_event)
117THREAD_OPERATION_TRACEPOINT_INSTANCE(schedule_read)
118THREAD_OPERATION_TRACEPOINT_INSTANCE(schedule_write)
119THREAD_OPERATION_TRACEPOINT_INSTANCE(thread_cancel)
120THREAD_OPERATION_TRACEPOINT_INSTANCE(thread_cancel_async)
121THREAD_OPERATION_TRACEPOINT_INSTANCE(thread_call)
122
87879a5e
QY
123TRACEPOINT_EVENT(
124 frr_libfrr,
125 frr_pthread_run,
126 TP_ARGS(
127 char *, name
128 ),
129 TP_FIELDS(
130 ctf_string(frr_pthread_name, name)
131 )
132)
133
134TRACEPOINT_EVENT(
135 frr_libfrr,
136 frr_pthread_stop,
137 TP_ARGS(
138 char *, name
139 ),
140 TP_FIELDS(
141 ctf_string(frr_pthread_name, name)
142 )
143)
144
d92658f4
QY
145TRACEPOINT_EVENT(
146 frr_libfrr,
147 memalloc,
148 TP_ARGS(
149 struct memtype *, mt, void *, ptr, size_t, size
150 ),
151 TP_FIELDS(
152 ctf_string(memtype, mt->name)
153 ctf_integer(size_t, size, size)
154 ctf_integer_hex(intptr_t, ptr, ptr)
155 )
156)
157
158TRACEPOINT_EVENT(
159 frr_libfrr,
160 memfree,
161 TP_ARGS(
162 struct memtype *, mt, void *, ptr
163 ),
164 TP_FIELDS(
165 ctf_string(memtype, mt->name)
166 ctf_integer_hex(intptr_t, ptr, ptr)
167 )
168)
169
170TRACEPOINT_EVENT(
171 frr_libfrr,
172 list_add,
173 TP_ARGS(
174 struct list *, list, const void *, ptr
175 ),
176 TP_FIELDS(
177 ctf_integer_hex(intptr_t, list, list)
178 ctf_integer(unsigned int, count, list->count)
179 ctf_integer_hex(intptr_t, ptr, ptr)
180 )
181)
182
183TRACEPOINT_EVENT(
184 frr_libfrr,
185 list_remove,
186 TP_ARGS(
187 struct list *, list, const void *, ptr
188 ),
189 TP_FIELDS(
190 ctf_integer_hex(intptr_t, list, list)
191 ctf_integer(unsigned int, count, list->count)
192 ctf_integer_hex(intptr_t, ptr, ptr)
193 )
194)
195
196TRACEPOINT_EVENT(
197 frr_libfrr,
198 list_delete_node,
199 TP_ARGS(
200 struct list *, list, const void *, node
201 ),
202 TP_FIELDS(
203 ctf_integer_hex(intptr_t, list, list)
204 ctf_integer(unsigned int, count, list->count)
205 ctf_integer_hex(intptr_t, node, node)
206 )
207)
208
209TRACEPOINT_EVENT(
210 frr_libfrr,
211 list_sort,
212 TP_ARGS(
213 struct list *, list
214 ),
215 TP_FIELDS(
216 ctf_integer_hex(intptr_t, list, list)
217 ctf_integer(unsigned int, count, list->count)
218 )
219)
220
a72255a3
QY
221TRACEPOINT_EVENT(
222 frr_libfrr,
223 route_node_get,
224 TP_ARGS(
225 struct route_table *, table, char *, prefix
226 ),
227 TP_FIELDS(
228 ctf_integer_hex(intptr_t, table, table)
229 ctf_string(prefix, prefix)
230 )
231)
232
abf96a87
QY
233/* clang-format on */
234
0cbcadcc 235#include <lttng/tracepoint-event.h>
1bd1ebaa 236#include <lttng/tracelog.h>
0cbcadcc 237
0cbcadcc
QY
238#endif /* HAVE_LTTNG */
239
c7bb4f00 240#endif /* _LIBFRR_TRACE_H_ */