Commit | Line | Data |
---|---|---|
d7bfb9b0 JG |
1 | /* |
2 | * Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
3 | * | |
4 | * SPDX-License-Identifier: GPL-2.0-only | |
5 | * | |
6 | */ | |
7 | ||
8 | #ifndef LTTNG_UST_REGISTRY_EVENT_H | |
9 | #define LTTNG_UST_REGISTRY_EVENT_H | |
10 | ||
11 | #include "event-class.hpp" | |
12 | #include "field.hpp" | |
13 | ||
14 | #include <common/format.hpp> | |
15 | #include <common/hashtable/hashtable.hpp> | |
16 | #include <vendor/optional.hpp> | |
17 | ||
18 | #include <typeinfo> | |
19 | ||
20 | namespace lttng { | |
21 | namespace sessiond { | |
22 | namespace ust { | |
23 | ||
24 | /* | |
25 | * Event registered from a UST tracer sent to the session daemon. This is | |
26 | * indexed and matched by <event_name/signature>. | |
27 | */ | |
28 | class registry_event : public lttng::sessiond::trace::event_class { | |
29 | public: | |
30 | registry_event(unsigned int id, | |
31 | unsigned int stream_class_id, | |
32 | int session_objd, | |
33 | int channel_objd, | |
34 | std::string name, | |
35 | std::string signature, | |
36 | std::vector<lttng::sessiond::trace::field::cuptr> fields, | |
37 | int loglevel_value, | |
38 | nonstd::optional<std::string> model_emf_uri); | |
cd9adb8b | 39 | ~registry_event() override = default; |
9d89db29 JG |
40 | registry_event(const registry_event&) = delete; |
41 | registry_event(registry_event&&) = delete; | |
42 | registry_event& operator=(registry_event&&) = delete; | |
43 | registry_event& operator=(const registry_event&) = delete; | |
d7bfb9b0 JG |
44 | |
45 | /* Both objd are set by the tracer. */ | |
46 | const int session_objd; | |
47 | const int channel_objd; | |
48 | const std::string signature; | |
49 | ||
50 | /* | |
51 | * Flag for this channel if the metadata was dumped once during | |
52 | * registration. | |
53 | */ | |
54 | bool _metadata_dumped; | |
55 | ||
56 | /* | |
57 | * Node in the ust-registry hash table. The event name is used to | |
58 | * initialize the node and the event_name/signature for the match function. | |
59 | */ | |
f139a4f9 JG |
60 | struct cds_lfht_node _node; |
61 | struct rcu_head _head; | |
d7bfb9b0 JG |
62 | }; |
63 | ||
64 | void registry_event_destroy(registry_event *event); | |
65 | ||
66 | } /* namespace ust */ | |
67 | } /* namespace sessiond */ | |
68 | } /* namespace lttng */ | |
69 | ||
11bcbf89 JG |
70 | /* |
71 | * Due to a bug in g++ < 7.1, this specialization must be enclosed in the fmt namespace, | |
72 | * see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480. | |
73 | */ | |
e2c2bec2 | 74 | namespace fmt { |
d7bfb9b0 | 75 | template <> |
e2c2bec2 | 76 | struct formatter<lttng::sessiond::ust::registry_event> : formatter<std::string> { |
31375c42 JG |
77 | template <typename FormatContextType> |
78 | typename FormatContextType::iterator format( | |
79 | const lttng::sessiond::ust::registry_event& event, FormatContextType& ctx) | |
d7bfb9b0 | 80 | { |
e2c2bec2 | 81 | return format_to(ctx.out(), |
d7bfb9b0 JG |
82 | "{{ name = `{}`, signature = `{}`, id = {}, session objd = {}, channel objd = {} }}", |
83 | event.name, event.signature, event.id, event.session_objd, | |
84 | event.channel_objd); | |
85 | } | |
86 | }; | |
e2c2bec2 | 87 | } /* namespace fmt */ |
d7bfb9b0 JG |
88 | |
89 | #endif /* LTTNG_UST_REGISTRY_EVENT_H */ |