vscode: Add configurations to run the executables under the debugger
[lttng-tools.git] / src / bin / lttng-sessiond / ust-registry.cpp
1 /*
2 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8 #define _LGPL_SOURCE
9
10 #include "lttng-sessiond.hpp"
11 #include "notification-thread-commands.hpp"
12 #include "ust-app.hpp"
13 #include "ust-registry-session-pid.hpp"
14 #include "ust-registry-session-uid.hpp"
15 #include "ust-registry.hpp"
16 #include "utils.hpp"
17
18 #include <common/common.hpp>
19 #include <common/exception.hpp>
20 #include <common/format.hpp>
21 #include <common/hashtable/utils.hpp>
22 #include <common/make-unique-wrapper.hpp>
23
24 #include <lttng/lttng.h>
25
26 #include <inttypes.h>
27
28 namespace ls = lttng::sessiond;
29 namespace lst = lttng::sessiond::trace;
30 namespace lsu = lttng::sessiond::ust;
31
32 /*
33 * Destroy event function call of the call RCU.
34 */
35 static void ust_registry_event_destroy_rcu(struct rcu_head *head)
36 {
37 DIAGNOSTIC_PUSH
38 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
39 lttng::sessiond::ust::registry_event *event =
40 lttng::utils::container_of(head, &lttng::sessiond::ust::registry_event::_head);
41 DIAGNOSTIC_POP
42
43 lttng::sessiond::ust::registry_event_destroy(event);
44 }
45
46 /*
47 * For a given event in a registry, delete the entry and destroy the event.
48 * This MUST be called within a RCU read side lock section.
49 */
50 void ust_registry_channel_destroy_event(lsu::registry_channel *chan,
51 lttng::sessiond::ust::registry_event *event)
52 {
53 int ret;
54 struct lttng_ht_iter iter;
55
56 LTTNG_ASSERT(chan);
57 LTTNG_ASSERT(event);
58 ASSERT_RCU_READ_LOCKED();
59
60 /* Delete the node first. */
61 iter.iter.node = &event->_node;
62 ret = lttng_ht_del(chan->_events, &iter);
63 LTTNG_ASSERT(!ret);
64
65 call_rcu(&event->_head, ust_registry_event_destroy_rcu);
66
67 return;
68 }
69
70 lsu::registry_session *ust_registry_session_per_uid_create(const lttng::sessiond::trace::abi& abi,
71 uint32_t major,
72 uint32_t minor,
73 const char *root_shm_path,
74 const char *shm_path,
75 uid_t euid,
76 gid_t egid,
77 uint64_t tracing_id,
78 uid_t tracing_uid)
79 {
80 try {
81 return new lsu::registry_session_per_uid(abi,
82 major,
83 minor,
84 root_shm_path,
85 shm_path,
86 euid,
87 egid,
88 tracing_id,
89 tracing_uid);
90 } catch (const std::exception& ex) {
91 ERR("Failed to create per-uid registry session: %s", ex.what());
92 return nullptr;
93 }
94 }
95
96 lsu::registry_session *ust_registry_session_per_pid_create(struct ust_app *app,
97 const lttng::sessiond::trace::abi& abi,
98 uint32_t major,
99 uint32_t minor,
100 const char *root_shm_path,
101 const char *shm_path,
102 uid_t euid,
103 gid_t egid,
104 uint64_t tracing_id)
105 {
106 try {
107 return new lsu::registry_session_per_pid(
108 *app, abi, major, minor, root_shm_path, shm_path, euid, egid, tracing_id);
109 } catch (const std::exception& ex) {
110 ERR("Failed to create per-pid registry session: %s", ex.what());
111 return nullptr;
112 }
113 }
114
115 /*
116 * Destroy session registry. This does NOT free the given pointer since it
117 * might get passed as a reference. The registry lock should NOT be acquired.
118 */
119 void ust_registry_session_destroy(lsu::registry_session *reg)
120 {
121 delete reg;
122 }
123
124 lsu::registry_enum::registry_enum(std::string in_name,
125 enum lst::integer_type::signedness in_signedness) :
126 name{ std::move(in_name) }, signedness{ in_signedness }
127 {
128 cds_lfht_node_init(&this->node.node);
129 this->rcu_head = {};
130 }
131
132 bool lsu::operator==(const lsu::registry_enum& lhs, const lsu::registry_enum& rhs) noexcept
133 {
134 if (lhs.signedness != rhs.signedness) {
135 return false;
136 }
137
138 return lhs._is_equal(rhs);
139 }
This page took 0.031753 seconds and 4 git commands to generate.