]>
Commit | Line | Data |
---|---|---|
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 | ||
21 | #if !defined(_TRACE_H) || defined(TRACEPOINT_HEADER_MULTI_READ) | |
22 | #define _TRACE_H | |
23 | ||
24 | #ifdef HAVE_CONFIG_H | |
25 | #include "config.h" | |
26 | #endif /* HAVE_CONFIG_H */ | |
27 | ||
28 | #ifdef HAVE_LTTNG | |
29 | ||
30 | #undef TRACEPOINT_PROVIDER | |
31 | #define TRACEPOINT_PROVIDER frr_libfrr | |
32 | ||
33 | #undef TRACEPOINT_INCLUDE | |
34 | #define TRACEPOINT_INCLUDE "./trace.h" | |
35 | ||
0cbcadcc | 36 | #include <lttng/tracepoint.h> |
abf96a87 QY |
37 | |
38 | #include "hash.h" | |
39 | #include "thread.h" | |
40 | ||
41 | /* clang-format off */ | |
42 | ||
43 | TRACEPOINT_EVENT( | |
44 | frr_libfrr, | |
45 | hash_get, | |
46 | TP_ARGS(struct hash *, hash, void *, data), | |
47 | TP_FIELDS( | |
48 | ctf_string(name, hash->name ? hash->name : "(unnamed)") | |
49 | ctf_integer(unsigned int, index_size, hash->size) | |
50 | ctf_integer(unsigned long, item_count, hash->count) | |
51 | ctf_integer_hex(intptr_t, data_ptr, data) | |
52 | ) | |
53 | ) | |
54 | ||
55 | TRACEPOINT_LOGLEVEL(frr_libfrr, hash_get, TRACE_INFO) | |
56 | ||
67a485d1 QY |
57 | TRACEPOINT_EVENT( |
58 | frr_libfrr, | |
59 | hash_insert, | |
60 | TP_ARGS(struct hash *, hash, void *, data, unsigned int, key), | |
61 | TP_FIELDS( | |
62 | ctf_string(name, hash->name ? hash->name : "(unnamed)") | |
63 | ctf_integer(unsigned int, key, hash->size) | |
64 | ctf_integer(unsigned int, index_size, hash->size) | |
65 | ctf_integer(unsigned long, item_count, hash->count) | |
66 | ctf_integer_hex(intptr_t, data_ptr, data) | |
67 | ) | |
68 | ) | |
69 | ||
70 | TRACEPOINT_LOGLEVEL(frr_libfrr, hash_insert, TRACE_INFO) | |
71 | ||
abf96a87 QY |
72 | TRACEPOINT_EVENT( |
73 | frr_libfrr, | |
74 | hash_release, | |
75 | TP_ARGS(struct hash *, hash, void *, data, void *, released_item), | |
76 | TP_FIELDS( | |
77 | ctf_string(name, hash->name ? hash->name : "(unnamed)") | |
78 | ctf_integer(unsigned int, index_size, hash->size) | |
79 | ctf_integer(unsigned long, item_count, hash->count) | |
80 | ctf_integer_hex(intptr_t, data_ptr, data) | |
81 | ctf_integer_hex(intptr_t, released_item, data) | |
82 | ) | |
83 | ) | |
84 | ||
85 | TRACEPOINT_LOGLEVEL(frr_libfrr, hash_release, TRACE_INFO) | |
86 | ||
87 | #define THREAD_SCHEDULE_ARGS \ | |
88 | TP_ARGS(struct thread_master *, master, const char *, funcname, \ | |
89 | const char *, schedfrom, int, fromln, struct thread **, \ | |
90 | thread_ptr, int, fd, int, val, void *, arg, long, time) | |
91 | ||
92 | TRACEPOINT_EVENT_CLASS( | |
93 | frr_libfrr, | |
94 | thread_operation, | |
95 | THREAD_SCHEDULE_ARGS, | |
96 | TP_FIELDS( | |
97 | ctf_string(threadmaster_name, master->name) | |
98 | ctf_string(function_name, funcname ? funcname : "(unknown function)") | |
99 | ctf_string(scheduled_from, schedfrom ? schedfrom : "(unknown file)") | |
100 | ctf_integer(int, scheduled_on_line, fromln) | |
101 | ctf_integer_hex(intptr_t, thread_addr, thread_ptr ? *thread_ptr : NULL) | |
102 | ctf_integer(int, file_descriptor, fd) | |
103 | ctf_integer(int, event_value, val) | |
104 | ctf_integer_hex(intptr_t, argument_ptr, arg) | |
105 | ctf_integer(long, timer, time) | |
106 | ) | |
107 | ) | |
108 | ||
109 | #define THREAD_OPERATION_TRACEPOINT_INSTANCE(name) \ | |
110 | TRACEPOINT_EVENT_INSTANCE(frr_libfrr, thread_operation, name, \ | |
111 | THREAD_SCHEDULE_ARGS) \ | |
112 | TRACEPOINT_LOGLEVEL(frr_libfrr, name, TRACE_INFO) | |
113 | ||
114 | THREAD_OPERATION_TRACEPOINT_INSTANCE(schedule_timer) | |
115 | THREAD_OPERATION_TRACEPOINT_INSTANCE(schedule_event) | |
116 | THREAD_OPERATION_TRACEPOINT_INSTANCE(schedule_read) | |
117 | THREAD_OPERATION_TRACEPOINT_INSTANCE(schedule_write) | |
118 | THREAD_OPERATION_TRACEPOINT_INSTANCE(thread_cancel) | |
119 | THREAD_OPERATION_TRACEPOINT_INSTANCE(thread_cancel_async) | |
120 | THREAD_OPERATION_TRACEPOINT_INSTANCE(thread_call) | |
121 | ||
87879a5e QY |
122 | TRACEPOINT_EVENT( |
123 | frr_libfrr, | |
124 | frr_pthread_run, | |
125 | TP_ARGS( | |
126 | char *, name | |
127 | ), | |
128 | TP_FIELDS( | |
129 | ctf_string(frr_pthread_name, name) | |
130 | ) | |
131 | ) | |
132 | ||
133 | TRACEPOINT_EVENT( | |
134 | frr_libfrr, | |
135 | frr_pthread_stop, | |
136 | TP_ARGS( | |
137 | char *, name | |
138 | ), | |
139 | TP_FIELDS( | |
140 | ctf_string(frr_pthread_name, name) | |
141 | ) | |
142 | ) | |
143 | ||
abf96a87 QY |
144 | /* clang-format on */ |
145 | ||
0cbcadcc | 146 | #include <lttng/tracepoint-event.h> |
1bd1ebaa | 147 | #include <lttng/tracelog.h> |
0cbcadcc QY |
148 | |
149 | #else /* HAVE_LTTNG */ | |
150 | ||
151 | #define tracepoint(...) | |
152 | #define tracef(...) | |
153 | #define tracelog(...) | |
154 | #define tracepoint_enabled(...) true | |
155 | ||
156 | #endif /* HAVE_LTTNG */ | |
157 | ||
158 | #endif /* _TRACE_H */ |