| 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); |
| 39 | ~registry_event() override = default; |
| 40 | |
| 41 | /* Both objd are set by the tracer. */ |
| 42 | const int session_objd; |
| 43 | const int channel_objd; |
| 44 | const std::string signature; |
| 45 | |
| 46 | /* |
| 47 | * Flag for this channel if the metadata was dumped once during |
| 48 | * registration. |
| 49 | */ |
| 50 | bool _metadata_dumped; |
| 51 | |
| 52 | /* |
| 53 | * Node in the ust-registry hash table. The event name is used to |
| 54 | * initialize the node and the event_name/signature for the match function. |
| 55 | */ |
| 56 | struct cds_lfht_node _node; |
| 57 | struct rcu_head _head; |
| 58 | }; |
| 59 | |
| 60 | void registry_event_destroy(registry_event *event); |
| 61 | |
| 62 | } /* namespace ust */ |
| 63 | } /* namespace sessiond */ |
| 64 | } /* namespace lttng */ |
| 65 | |
| 66 | /* |
| 67 | * Due to a bug in g++ < 7.1, this specialization must be enclosed in the fmt namespace, |
| 68 | * see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480. |
| 69 | */ |
| 70 | namespace fmt { |
| 71 | template <> |
| 72 | struct formatter<lttng::sessiond::ust::registry_event> : formatter<std::string> { |
| 73 | template <typename FormatCtx> |
| 74 | typename FormatCtx::iterator format( |
| 75 | const lttng::sessiond::ust::registry_event& event, FormatCtx& ctx) |
| 76 | { |
| 77 | return format_to(ctx.out(), |
| 78 | "{{ name = `{}`, signature = `{}`, id = {}, session objd = {}, channel objd = {} }}", |
| 79 | event.name, event.signature, event.id, event.session_objd, |
| 80 | event.channel_objd); |
| 81 | } |
| 82 | }; |
| 83 | } /* namespace fmt */ |
| 84 | |
| 85 | #endif /* LTTNG_UST_REGISTRY_EVENT_H */ |