]> git.proxmox.com Git - mirror_frr.git/blame - lib/trace.h
lib: add tracepoints for hash ops, thread events
[mirror_frr.git] / lib / 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
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
43TRACEPOINT_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
55TRACEPOINT_LOGLEVEL(frr_libfrr, hash_get, TRACE_INFO)
56
57TRACEPOINT_EVENT(
58 frr_libfrr,
59 hash_release,
60 TP_ARGS(struct hash *, hash, void *, data, void *, released_item),
61 TP_FIELDS(
62 ctf_string(name, hash->name ? hash->name : "(unnamed)")
63 ctf_integer(unsigned int, index_size, hash->size)
64 ctf_integer(unsigned long, item_count, hash->count)
65 ctf_integer_hex(intptr_t, data_ptr, data)
66 ctf_integer_hex(intptr_t, released_item, data)
67 )
68)
69
70TRACEPOINT_LOGLEVEL(frr_libfrr, hash_release, TRACE_INFO)
71
72#define THREAD_SCHEDULE_ARGS \
73 TP_ARGS(struct thread_master *, master, const char *, funcname, \
74 const char *, schedfrom, int, fromln, struct thread **, \
75 thread_ptr, int, fd, int, val, void *, arg, long, time)
76
77TRACEPOINT_EVENT_CLASS(
78 frr_libfrr,
79 thread_operation,
80 THREAD_SCHEDULE_ARGS,
81 TP_FIELDS(
82 ctf_string(threadmaster_name, master->name)
83 ctf_string(function_name, funcname ? funcname : "(unknown function)")
84 ctf_string(scheduled_from, schedfrom ? schedfrom : "(unknown file)")
85 ctf_integer(int, scheduled_on_line, fromln)
86 ctf_integer_hex(intptr_t, thread_addr, thread_ptr ? *thread_ptr : NULL)
87 ctf_integer(int, file_descriptor, fd)
88 ctf_integer(int, event_value, val)
89 ctf_integer_hex(intptr_t, argument_ptr, arg)
90 ctf_integer(long, timer, time)
91 )
92)
93
94#define THREAD_OPERATION_TRACEPOINT_INSTANCE(name) \
95 TRACEPOINT_EVENT_INSTANCE(frr_libfrr, thread_operation, name, \
96 THREAD_SCHEDULE_ARGS) \
97 TRACEPOINT_LOGLEVEL(frr_libfrr, name, TRACE_INFO)
98
99THREAD_OPERATION_TRACEPOINT_INSTANCE(schedule_timer)
100THREAD_OPERATION_TRACEPOINT_INSTANCE(schedule_event)
101THREAD_OPERATION_TRACEPOINT_INSTANCE(schedule_read)
102THREAD_OPERATION_TRACEPOINT_INSTANCE(schedule_write)
103THREAD_OPERATION_TRACEPOINT_INSTANCE(thread_cancel)
104THREAD_OPERATION_TRACEPOINT_INSTANCE(thread_cancel_async)
105THREAD_OPERATION_TRACEPOINT_INSTANCE(thread_call)
106
107/* clang-format on */
108
0cbcadcc
QY
109#include <lttng/tracepoint-event.h>
110
111#else /* HAVE_LTTNG */
112
113#define tracepoint(...)
114#define tracef(...)
115#define tracelog(...)
116#define tracepoint_enabled(...) true
117
118#endif /* HAVE_LTTNG */
119
120#endif /* _TRACE_H */